diff options
-rw-r--r-- | clang/lib/Sema/SemaType.cpp | 19 | ||||
-rw-r--r-- | clang/test/SemaCXX/auto-cxx0x.cpp | 8 |
2 files changed, 26 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index d5516bc7a95..ba028b07e3b 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -255,6 +255,23 @@ namespace { return T; } + /// Completely replace the \c auto in \p TypeWithAuto by + /// \p Replacement. Also replace \p TypeWithAuto in \c TypeAttrPair if + /// necessary. + QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement) { + QualType T = sema.ReplaceAutoType(TypeWithAuto, Replacement); + if (auto *AttrTy = TypeWithAuto->getAs<AttributedType>()) { + // Attributed type still should be an attributed type after replacement. + auto *NewAttrTy = cast<AttributedType>(T.getTypePtr()); + for (TypeAttrPair &A : AttrsForTypes) { + if (A.first == AttrTy) + A.first = NewAttrTy; + } + AttrsForTypesSorted = false; + } + return T; + } + /// Extract and remove the Attr* for a given attributed type. const Attr *takeAttrForAttributedType(const AttributedType *AT) { if (!AttrsForTypesSorted) { @@ -2938,7 +2955,7 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, // template type parameter. // FIXME: Retain some type sugar to indicate that this was written // as 'auto'. - T = SemaRef.ReplaceAutoType( + T = state.ReplaceAutoType( T, QualType(CorrespondingTemplateParam->getTypeForDecl(), 0)); } break; diff --git a/clang/test/SemaCXX/auto-cxx0x.cpp b/clang/test/SemaCXX/auto-cxx0x.cpp index 074a01bb839..b4da3f9330c 100644 --- a/clang/test/SemaCXX/auto-cxx0x.cpp +++ b/clang/test/SemaCXX/auto-cxx0x.cpp @@ -15,3 +15,11 @@ void g() { // expected-error@-2 {{'auto' not allowed in lambda parameter}} #endif } + +void rdar47689465() { + int x = 0; + [](auto __attribute__((noderef)) *){}(&x); +#if __cplusplus == 201103L + // expected-error@-2 {{'auto' not allowed in lambda parameter}} +#endif +} |