diff options
Diffstat (limited to 'test/SemaTemplate')
| -rw-r--r-- | test/SemaTemplate/deduction-crash.cpp | 2 | ||||
| -rw-r--r-- | test/SemaTemplate/default-arguments.cpp | 16 | ||||
| -rw-r--r-- | test/SemaTemplate/explicit-instantiation.cpp | 2 | ||||
| -rw-r--r-- | test/SemaTemplate/explicit-specialization-member.cpp | 11 | ||||
| -rw-r--r-- | test/SemaTemplate/ms-lookup-template-base-classes.cpp | 3 | ||||
| -rw-r--r-- | test/SemaTemplate/typo-template-name.cpp | 43 |
6 files changed, 72 insertions, 5 deletions
diff --git a/test/SemaTemplate/deduction-crash.cpp b/test/SemaTemplate/deduction-crash.cpp index ff7421a910bd3..c94c9db94e064 100644 --- a/test/SemaTemplate/deduction-crash.cpp +++ b/test/SemaTemplate/deduction-crash.cpp @@ -2,7 +2,7 @@ // Note that the error count below doesn't matter. We just want to // make sure that the parser doesn't crash. -// CHECK: 16 errors +// CHECK: 17 errors // PR7511 template<a> diff --git a/test/SemaTemplate/default-arguments.cpp b/test/SemaTemplate/default-arguments.cpp index d3e249db7ee27..b5b042c64a71e 100644 --- a/test/SemaTemplate/default-arguments.cpp +++ b/test/SemaTemplate/default-arguments.cpp @@ -207,3 +207,19 @@ Y<false> y2; } // end ns1 } // end ns PR26134 + +namespace friends { + namespace ns { + template<typename> struct A { + template<typename> friend void f(); + template<typename> friend struct X; + }; + template<typename = int> void f(); // expected-warning 0-1{{extension}} + template<typename = int> struct X; + A<int> a; + } + namespace ns { + void g() { f(); } + X<int> *p; + } +} diff --git a/test/SemaTemplate/explicit-instantiation.cpp b/test/SemaTemplate/explicit-instantiation.cpp index 010716dd14266..42d9f4d332a99 100644 --- a/test/SemaTemplate/explicit-instantiation.cpp +++ b/test/SemaTemplate/explicit-instantiation.cpp @@ -95,7 +95,7 @@ namespace PR7622 { struct basic_streambuf; template<typename,typename> - struct basic_streambuf{friend bob<>()}; // expected-error{{unknown type name 'bob'}} \ + struct basic_streambuf{friend bob<>()}; // expected-error{{no template named 'bob'}} \ // expected-error{{expected member name or ';' after declaration specifiers}} template struct basic_streambuf<int>; } diff --git a/test/SemaTemplate/explicit-specialization-member.cpp b/test/SemaTemplate/explicit-specialization-member.cpp index f302836c7e4b3..c0c36808b4920 100644 --- a/test/SemaTemplate/explicit-specialization-member.cpp +++ b/test/SemaTemplate/explicit-specialization-member.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s -fcxx-exceptions template<typename T> struct X0 { typedef T* type; @@ -57,3 +57,12 @@ template<typename T> struct Helper { template<typename T> void Helper<T>::func<2>() {} // expected-error {{cannot specialize a member}} \ // expected-error {{no function template matches}} } + +namespace SpecLoc { + template <typename T> struct A { + static int n; // expected-note {{previous}} + static void f(); // expected-note {{previous}} + }; + template<> float A<int>::n; // expected-error {{different type}} + template<> void A<int>::f() throw(); // expected-error {{does not match}} +} diff --git a/test/SemaTemplate/ms-lookup-template-base-classes.cpp b/test/SemaTemplate/ms-lookup-template-base-classes.cpp index 6afc7091260dc..a41248ee1b8ef 100644 --- a/test/SemaTemplate/ms-lookup-template-base-classes.cpp +++ b/test/SemaTemplate/ms-lookup-template-base-classes.cpp @@ -347,8 +347,7 @@ template <typename T> struct B : A<T> { }; template <typename T> struct C : A<T> { // Incorrect form. - NameFromBase<T> m; // expected-error {{unknown type name 'NameFromBase'}} - //expected-error@-1 {{expected member name or ';' after declaration specifiers}} + NameFromBase<T> m; // expected-error {{no template named 'NameFromBase'}} }; } diff --git a/test/SemaTemplate/typo-template-name.cpp b/test/SemaTemplate/typo-template-name.cpp new file mode 100644 index 0000000000000..fe5201a8e26c3 --- /dev/null +++ b/test/SemaTemplate/typo-template-name.cpp @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 -std=c++1z %s -verify -Wno-unused + +namespace InExpr { + namespace A { + void typo_first_a(); // expected-note {{found}} + template<typename T> void typo_first_b(); // expected-note 2{{declared here}} + } + void testA() { A::typo_first_a<int>(); } // expected-error {{'typo_first_a' does not name a template but is followed by template arguments; did you mean 'typo_first_b'?}} + + namespace B { + void typo_first_b(); // expected-note {{found}} + } + void testB() { B::typo_first_b<int>(); } // expected-error {{'typo_first_b' does not name a template but is followed by template arguments; did you mean 'A::typo_first_b'?}} + + struct Base { + template<typename T> static void foo(); // expected-note 4{{declared here}} + int n; + }; + struct Derived : Base { + void foo(); // expected-note {{found}} + }; + // We probably don't want to suggest correcting to .Base::foo<int> + void testMember() { Derived().foo<int>(); } // expected-error-re {{does not name a template but is followed by template arguments{{$}}}} + + struct Derived2 : Base { + void goo(); // expected-note {{found}} + }; + void testMember2() { Derived2().goo<int>(); } // expected-error {{member 'goo' of 'InExpr::Derived2' is not a template; did you mean 'foo'?}} + + void no_correction() { + int foo; // expected-note 3{{found}} + + foo<int>(); // expected-error {{'foo' does not name a template but is followed by template arguments; did you mean 'Base::foo'?}} + foo<>(); // expected-error {{'foo' does not name a template but is followed by template arguments; did you mean 'Base::foo'?}} + foo<Base *>(); // expected-error {{'foo' does not name a template but is followed by template arguments; did you mean 'Base::foo'?}} + + // These are valid expressions. + foo<foo; // expected-warning {{self-comparison}} + foo<int()>(0); + foo<int(), true>(false); + foo<Base{}.n; + } +} |
