aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/TreeTransform.h11
-rw-r--r--lib/Sema/TypeLocBuilder.h18
2 files changed, 17 insertions, 12 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();
}
}
diff --git a/lib/Sema/TypeLocBuilder.h b/lib/Sema/TypeLocBuilder.h
index 792bd1fc72..f7889e9c64 100644
--- a/lib/Sema/TypeLocBuilder.h
+++ b/lib/Sema/TypeLocBuilder.h
@@ -147,7 +147,7 @@ private:
Index -= LocalSize;
- return getTypeLoc(T);
+ return getTemporaryTypeLoc(T);
}
/// Grow to the given capacity.
@@ -179,15 +179,17 @@ private:
reserve(Size);
Index -= Size;
- return getTypeLoc(T);
+ return getTemporaryTypeLoc(T);
}
-
- // This is private because, when we kill off TypeSourceInfo in favor
- // of TypeLoc, we'll want an interface that creates a TypeLoc given
- // an ASTContext, and we don't want people to think they can just
- // use this as an equivalent.
- TypeLoc getTypeLoc(QualType T) {
+public:
+ /// \brief Retrieve a temporary TypeLoc that refers into this \c TypeLocBuilder
+ /// object.
+ ///
+ /// The resulting \c TypeLoc should only be used so long as the
+ /// \c TypeLocBuilder is active and has not had more type information
+ /// pushed into it.
+ TypeLoc getTemporaryTypeLoc(QualType T) {
#ifndef NDEBUG
assert(LastTy == T && "type doesn't match last type pushed!");
#endif