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 | c08b693e309baa80f0a3dd7794af130c3393c777 (patch) | |
tree | 30986154bf0d7997794a5746ca6270df4d53f40c /clang/test/SemaTemplate/template-id-expr.cpp | |
parent | 93979f67f8cc49f596ae34c45699371bd3cda785 (diff) | |
download | bcm5719-llvm-c08b693e309baa80f0a3dd7794af130c3393c777.tar.gz bcm5719-llvm-c08b693e309baa80f0a3dd7794af130c3393c777.zip |
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).
llvm-svn: 331013
Diffstat (limited to 'clang/test/SemaTemplate/template-id-expr.cpp')
-rw-r--r-- | clang/test/SemaTemplate/template-id-expr.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/template-id-expr.cpp b/clang/test/SemaTemplate/template-id-expr.cpp index 4e6e22479b3..e9f63fa7540 100644 --- a/clang/test/SemaTemplate/template-id-expr.cpp +++ b/clang/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 { |