diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 66eeaa8e6f777..c2a6377ee19d1 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7416,10 +7416,10 @@ NamedDecl *Sema::ActOnVariableDeclarator( tryToFixVariablyModifiedVarType(TInfo, R, D.getIdentifierLoc(), /*DiagID=*/0); - if (const AutoType *AutoT = R->getAs()) - CheckConstrainedAuto( - AutoT, - TInfo->getTypeLoc().getContainedAutoTypeLoc().getConceptNameLoc()); + if (AutoTypeLoc TL = TInfo->getTypeLoc().getContainedAutoTypeLoc()) { + const AutoType *AT = TL.getTypePtr(); + CheckConstrainedAuto(AT, TL.getConceptNameLoc()); + } bool IsMemberSpecialization = false; bool IsVariableTemplateSpecialization = false; diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 714409f927a8d..6e968f1802817 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -6308,11 +6308,10 @@ TypeResult Sema::ActOnTypeName(Declarator &D) { CheckExtraCXXDefaultArguments(D); } - if (const AutoType *AutoT = T->getAs()) - CheckConstrainedAuto( - AutoT, - TInfo->getTypeLoc().getContainedAutoTypeLoc().getConceptNameLoc()); - + if (AutoTypeLoc TL = TInfo->getTypeLoc().getContainedAutoTypeLoc()) { + const AutoType *AT = TL.getTypePtr(); + CheckConstrainedAuto(AT, TL.getConceptNameLoc()); + } return CreateParsedType(T, TInfo); } diff --git a/clang/test/CXX/drs/cwg24xx.cpp b/clang/test/CXX/drs/cwg24xx.cpp index 16b8ec07fc50f..00b6bb5a865df 100644 --- a/clang/test/CXX/drs/cwg24xx.cpp +++ b/clang/test/CXX/drs/cwg24xx.cpp @@ -82,6 +82,15 @@ auto h() -> C auto { C auto foo = T(); // expected-warning@-1 {{'C' is deprecated}} // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}} + C auto *bar = T(); + // expected-warning@-1 {{'C' is deprecated}} + // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}} + C auto &baz = T(); + // expected-warning@-1 {{'C' is deprecated}} + // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}} + C auto &&quux = T(); + // expected-warning@-1 {{'C' is deprecated}} + // expected-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}} return foo; } #endif diff --git a/clang/test/SemaCXX/cxx-deprecated.cpp b/clang/test/SemaCXX/cxx-deprecated.cpp index 81eb07608300d..d7de609d58cdd 100644 --- a/clang/test/SemaCXX/cxx-deprecated.cpp +++ b/clang/test/SemaCXX/cxx-deprecated.cpp @@ -36,4 +36,13 @@ template // expected-warning@-1 {{'C' is deprecated}} // expected-note@#C {{'C' has been explicitly marked deprecated here}} void f(); + +namespace GH98164 { +template +auto b() = delete; // #b + +decltype(b<0>()) x; +// expected-error@-1 {{call to deleted function 'b'}} +// expected-note@#b {{candidate function [with $0 = 0] has been explicitly deleted}} +} // namespace GH98164 } // namespace cxx20_concept