aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/TreeTransform.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-06-17 23:16:24 +0000
committerDouglas Gregor <dgregor@apple.com>2011-06-17 23:16:24 +0000
commit4020caec546d221170072d2388b57d151cb26111 (patch)
tree44f10839a53c7c9b89294536172b84e71ba5927f /lib/Sema/TreeTransform.h
parentc22d699d3aa1d7fbd32c4e35cf75abdca94bb5ef (diff)
Objective-C++ ARC: eliminate the utterly unjustified loophole that
silently dropped ownership qualifiers that were being applied to ownership-qualified, substituted type that was *not* a substituted template type parameter. We now provide a diagnostic in such cases, and recover by dropping the added qualifiers. Document this behavior in the ARC specification. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133309 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/TreeTransform.h')
-rw-r--r--lib/Sema/TreeTransform.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index d33e7a5c4c..121ff00628 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -3177,8 +3177,7 @@ TreeTransform<Derived>::TransformQualifiedType(TypeLocBuilder &TLB,
if (Quals.hasObjCLifetime()) {
if (!Result->isObjCLifetimeType() && !Result->isDependentType())
Quals.removeObjCLifetime();
- else if (Result.getObjCLifetime() &&
- Result.getObjCLifetime() != Quals.getObjCLifetime()) {
+ else if (Result.getObjCLifetime()) {
// Objective-C ARC:
// A lifetime qualifier applied to a substituted template parameter
// overrides the lifetime qualifier from the template argument.
@@ -3195,8 +3194,12 @@ TreeTransform<Derived>::TransformQualifiedType(TypeLocBuilder &TLB,
Replacement);
TLB.TypeWasModifiedSafely(Result);
} else {
- // Otherwise, drop the new qualifier.
- // FIXME: I don't recall the justification for this!
+ // Otherwise, complain about the addition of a qualifier to an
+ // already-qualified type.
+ SourceRange R = TLB.getTemporaryTypeLoc(Result).getSourceRange();
+ SemaRef.Diag(R.getBegin(), diag::err_attr_objc_lifetime_redundant)
+ << Result << R;
+
Quals.removeObjCLifetime();
}
}