diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1269,11 +1269,10 @@ llvm::SmallVector TemplateArgs; for (auto &ArgLoc : TemplateArgsInfo.arguments()) TemplateArgs.push_back(ArgLoc.getArgument()); - return S.Context.getAutoType(QualType(), AutoTypeKeyword::Auto, false, - /*IsPack=*/false, - cast(TemplateId->Template.get() - .getAsTemplateDecl()), - TemplateArgs); + return S.Context.getAutoType( + QualType(), AutoKW, false, /*IsPack=*/false, + cast(TemplateId->Template.get().getAsTemplateDecl()), + TemplateArgs); } /// Convert the specified declspec to the appropriate type diff --git a/clang/test/CXX/dcl/dcl.fct/p17.cpp b/clang/test/CXX/dcl/dcl.fct/p17.cpp --- a/clang/test/CXX/dcl/dcl.fct/p17.cpp +++ b/clang/test/CXX/dcl/dcl.fct/p17.cpp @@ -186,7 +186,7 @@ static_assert(is_same_v); // expected-error@-1{{no matching}} static_assert(is_same_v); - void f10(C decltype(auto) x); + void f10(C decltype(auto) x); // expected-error{{decltype(auto)' not allowed in function prototype}} auto f11 = [] (C auto x) { }; // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}} static_assert(is_same_v); @@ -238,7 +238,7 @@ static_assert(is_same_v); // expected-error@-1{{no matching}} static_assert(is_same_v); - void f21(C2 decltype(auto) x); + void f21(C2 decltype(auto) x); // expected-error{{decltype(auto)' not allowed in function prototype}} auto f22 = [] (C2 auto x) { }; // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}} static_assert(is_same_v); diff --git a/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp b/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp --- a/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp +++ b/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -std=c++2a -verify %s +template constexpr bool is_same_v = false; +template constexpr bool is_same_v = true; template concept LargerThan = sizeof(T) > size; @@ -41,4 +43,22 @@ auto test6() -> Large auto { return 1; } X::Small auto test7() { return 'a'; } -X::SmallerThan<5> auto test8() { return 10; } \ No newline at end of file +X::SmallerThan<5> auto test8() { return 10; } + +namespace { + int a = 0; + int &b = a; + template concept True = true; + + True auto c = a; + static_assert(is_same_v); + + True auto d = b; + static_assert(is_same_v); + + True decltype(auto) e = a; + static_assert(is_same_v); + + True decltype(auto) f = b; + static_assert(is_same_v); +} diff --git a/clang/test/Parser/cxx2a-placeholder-type-constraint.cpp b/clang/test/Parser/cxx2a-placeholder-type-constraint.cpp --- a/clang/test/Parser/cxx2a-placeholder-type-constraint.cpp +++ b/clang/test/Parser/cxx2a-placeholder-type-constraint.cpp @@ -23,13 +23,13 @@ {C<> decltype(auto) a = 1;} {C decltype(auto) a = 1;} {const C<> decltype(auto) &a = 1;} // expected-error{{'decltype(auto)' cannot be combined with other type specifiers}} - // expected-error@-1{{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}} + // expected-error@-1{{cannot form reference to 'decltype(auto)'}} {const C decltype(auto) &a = 1;} // expected-error{{'decltype(auto)' cannot be combined with other type specifiers}} - // expected-error@-1{{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}} + // expected-error@-1{{cannot form reference to 'decltype(auto)'}} {C a = 1;} // expected-error@-1{{expected 'auto' or 'decltype(auto)' after concept name}} {C decltype a19 = 1;} // expected-error@-1{{expected '('}} {C decltype(1) a20 = 1;} // expected-error@-1{{expected 'auto' or 'decltype(auto)' after concept name}} -} \ No newline at end of file +}