diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-04-27 02:00:13 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-04-27 02:00:13 +0000 |
commit | 497bb750601e02f3c4317b7134651120224991a2 (patch) | |
tree | 1a353af53a64ed7f1db269ad0eb28127f8d1b2fa /test/SemaTemplate | |
parent | 2cf0bade66e1ad92328259cf00ec5c7514d0bcde (diff) | |
download | clang-497bb750601e02f3c4317b7134651120224991a2.tar.gz |
Parse A::template B as an identifier rather than as a template-id with no
template arguments.
This fixes some cases where we'd incorrectly accept "A::template B" when B is a
kind of template that requires template arguments (in particular, a variable
template or a concept).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331013 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r-- | test/SemaTemplate/template-id-expr.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/SemaTemplate/template-id-expr.cpp b/test/SemaTemplate/template-id-expr.cpp index 4e6e22479b..e9f63fa754 100644 --- a/test/SemaTemplate/template-id-expr.cpp +++ b/test/SemaTemplate/template-id-expr.cpp @@ -85,6 +85,52 @@ struct Y0 { } }; +template<typename U> void Y0 + ::template // expected-error {{expected unqualified-id}} + f1(U) {} + +// FIXME: error recovery is awful without this. + ; + +template<typename T> +struct Y1 { + template<typename U> + void f1(U); + + template<typename U> + static void f2(U); + + void f3(int); + + static int f4(int); + template<typename U> + static void f4(U); + + template<typename U> + void f() { + Y1::template f1<U>(0); + Y1::template f1(0); + this->template f1(0); + + Y1::template f2<U>(0); + Y1::template f2(0); + + Y1::template f3(0); // expected-error {{'f3' following the 'template' keyword does not refer to a template}} + Y1::template f3(); // expected-error {{'f3' following the 'template' keyword does not refer to a template}} + + int x; + x = Y1::f4(0); + x = Y1::f4<int>(0); // expected-error {{assigning to 'int' from incompatible type 'void'}} + x = Y1::template f4(0); // expected-error {{assigning to 'int' from incompatible type 'void'}} + + x = this->f4(0); + x = this->f4<int>(0); // expected-error {{assigning to 'int' from incompatible type 'void'}} + x = this->template f4(0); // expected-error {{assigning to 'int' from incompatible type 'void'}} + } +}; + +void use_Y1(Y1<int> y1) { y1.f<int>(); } // expected-note {{in instantiation of}} + struct A { template<int I> struct B { |