mizvekov updated this revision to Diff 328689. mizvekov added a comment. Added new tests as suggested by rsmith.
By the way, I still need help commiting this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D98087/new/ https://reviews.llvm.org/D98087 Files: clang/lib/Sema/SemaType.cpp clang/test/CXX/dcl/dcl.fct/p17.cpp clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp clang/test/Parser/cxx2a-placeholder-type-constraint.cpp
Index: clang/test/Parser/cxx2a-placeholder-type-constraint.cpp =================================================================== --- clang/test/Parser/cxx2a-placeholder-type-constraint.cpp +++ clang/test/Parser/cxx2a-placeholder-type-constraint.cpp @@ -23,13 +23,13 @@ {C<> decltype(auto) a = 1;} {C<int> 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<int> 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 +} Index: clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp =================================================================== --- clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp +++ 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<typename T, typename U> constexpr bool is_same_v = false; +template<typename T> constexpr bool is_same_v<T, T> = true; template<typename T, unsigned size> concept LargerThan = sizeof(T) > size; @@ -41,4 +43,28 @@ 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 <class T> concept True = true; + + True auto c = a; + static_assert(is_same_v<decltype(c), int>); + + True auto d = b; + static_assert(is_same_v<decltype(d), int>); + + True decltype(auto) e = a; + static_assert(is_same_v<decltype(e), int>); + + True decltype(auto) f = b; + static_assert(is_same_v<decltype(f), int&>); + + True decltype(auto) g = (a); + static_assert(is_same_v<decltype(g), int&>); + + True decltype(auto) h = (b); + static_assert(is_same_v<decltype(h), int&>); +} Index: clang/test/CXX/dcl/dcl.fct/p17.cpp =================================================================== --- clang/test/CXX/dcl/dcl.fct/p17.cpp +++ clang/test/CXX/dcl/dcl.fct/p17.cpp @@ -186,7 +186,7 @@ static_assert(is_same_v<decltype(f9(i, c)), void>); // expected-error@-1{{no matching}} static_assert(is_same_v<decltype(f9(i, i, ci)), void>); - 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<decltype(f11(1)), void>); @@ -238,7 +238,7 @@ static_assert(is_same_v<decltype(f20(i, c)), void>); // expected-error@-1{{no matching}} static_assert(is_same_v<decltype(f20(c, c, cc)), void>); - void f21(C2<char> decltype(auto) x); + void f21(C2<char> decltype(auto) x); // expected-error{{decltype(auto)' not allowed in function prototype}} auto f22 = [] (C2<char> auto x) { }; // expected-note@-1{{candidate template ignored}} expected-note@-1{{because}} static_assert(is_same_v<decltype(f22(1)), void>); Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -1269,11 +1269,10 @@ llvm::SmallVector<TemplateArgument, 8> TemplateArgs; for (auto &ArgLoc : TemplateArgsInfo.arguments()) TemplateArgs.push_back(ArgLoc.getArgument()); - return S.Context.getAutoType(QualType(), AutoTypeKeyword::Auto, false, - /*IsPack=*/false, - cast<ConceptDecl>(TemplateId->Template.get() - .getAsTemplateDecl()), - TemplateArgs); + return S.Context.getAutoType( + QualType(), AutoKW, false, /*IsPack=*/false, + cast<ConceptDecl>(TemplateId->Template.get().getAsTemplateDecl()), + TemplateArgs); } /// Convert the specified declspec to the appropriate type
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits