summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-02-09 22:14:25 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-02-09 22:14:25 +0000
commit3af700977bdc3047044f22409f0e8aa24daae0f7 (patch)
tree25c7ce87b0791470cdd2d220a8d02256a3c8f162 /clang/test
parent546bc1103b682c4ea66116ddaf0fc6fdf0a8bdd5 (diff)
downloadbcm5719-llvm-3af700977bdc3047044f22409f0e8aa24daae0f7.tar.gz
bcm5719-llvm-3af700977bdc3047044f22409f0e8aa24daae0f7.zip
Diagnose attempts to explicitly instantiate a template at class scope. Previously Clang would simply ignore the 'template' keyword in this case.
llvm-svn: 294639
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Parser/cxx-template-decl.cpp10
-rw-r--r--clang/test/Parser/eof.cpp2
-rw-r--r--clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp6
-rw-r--r--clang/test/SemaTemplate/explicit-instantiation.cpp4
-rw-r--r--clang/test/SemaTemplate/template-id-expr.cpp8
5 files changed, 21 insertions, 9 deletions
diff --git a/clang/test/Parser/cxx-template-decl.cpp b/clang/test/Parser/cxx-template-decl.cpp
index efa42ad30d0..9ad422e7ab7 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -238,3 +238,13 @@ struct t2 : base<int,
// expected-error@-1 {{expected '{' after base class list}}
}
+
+namespace class_scope_instantiation {
+ struct A {
+ template<typename T> void f(T);
+ template void f<int>(int); // expected-error {{expected '<' after 'template'}}
+ template void f(float); // expected-error {{expected '<' after 'template'}}
+ extern template // expected-error {{expected member name or ';'}}
+ void f(double);
+ };
+}
diff --git a/clang/test/Parser/eof.cpp b/clang/test/Parser/eof.cpp
index 3c966c50e1d..4a06587edea 100644
--- a/clang/test/Parser/eof.cpp
+++ b/clang/test/Parser/eof.cpp
@@ -1,6 +1,6 @@
// RUN: not %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s
-// CHECK: error: expected member name or ';' after declaration specifiers
+// CHECK: error: expected '<' after 'template'
// CHECK: error: expected '}'
// CHECK: note: to match this '{'
// CHECK: error: expected ';' after class
diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
index 76f1bb9905b..66f0f10f0f3 100644
--- a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -17,8 +17,7 @@ class A {
template<typename T> CONST float right<float,T> = 5; // expected-error {{member 'right' declared as a template}}
template<> static CONST int right<int,int> = 7; // expected-error {{explicit specialization of 'right' in class scope}}
template<> static CONST float right<float,int>; // expected-error {{explicit specialization of 'right' in class scope}}
- template static CONST int right<int,int>; // expected-error {{template specialization requires 'template<>'}} \
- // expected-error {{explicit specialization of 'right' in class scope}}
+ template static CONST int right<int,int>; // expected-error {{expected '<' after 'template'}}
};
namespace out_of_line {
@@ -166,8 +165,7 @@ namespace constexpred {
template<typename T> constexpr float right<float,T> = 5; // expected-error {{non-static data member cannot be constexpr; did you intend to make it static?}}
template<> static constexpr int right<int,int> = 7; // expected-error {{explicit specialization of 'right' in class scope}}
template<> static constexpr float right<float,int>; // expected-error {{explicit specialization of 'right' in class scope}}
- template static constexpr int right<int,int>; // expected-error {{template specialization requires 'template<>'}} \
- // expected-error {{explicit specialization of 'right' in class scope}}
+ template static constexpr int right<int,int>; // expected-error {{expected '<' after 'template'}}
};
}
#endif
diff --git a/clang/test/SemaTemplate/explicit-instantiation.cpp b/clang/test/SemaTemplate/explicit-instantiation.cpp
index 040a932e972..010716dd142 100644
--- a/clang/test/SemaTemplate/explicit-instantiation.cpp
+++ b/clang/test/SemaTemplate/explicit-instantiation.cpp
@@ -103,8 +103,8 @@ namespace PR7622 {
// Test that we do not crash.
class TC1 {
class TC2 {
- template // FIXME: error here.
- void foo() { }
+ template
+ void foo() { } // expected-error{{expected '<' after 'template'}}
};
};
diff --git a/clang/test/SemaTemplate/template-id-expr.cpp b/clang/test/SemaTemplate/template-id-expr.cpp
index e311b5832d0..65c4e998acc 100644
--- a/clang/test/SemaTemplate/template-id-expr.cpp
+++ b/clang/test/SemaTemplate/template-id-expr.cpp
@@ -98,7 +98,11 @@ void f5() {
template void f5<0>(); // expected-note {{in instantiation of function template specialization 'f5<0>' requested here}}
class C {};
-template <template <typename> class D> // expected-note{{previous use is here}}
+template <template <typename> class D>
class E {
- template class D<C>; // expected-error {{template template argument 'D' cannot be referenced with a class specifier}}
+ template class D<C>; // expected-error {{expected '<' after 'template'}}
+ template<> class D<C>; // expected-error {{cannot specialize a template template parameter}}
+ friend class D<C>; // expected-error {{type alias template 'D' cannot be referenced with a class specifier}}
};
+template<typename T> using D = int; // expected-note {{declared here}} expected-warning {{extension}}
+E<D> ed; // expected-note {{instantiation of}}
OpenPOWER on IntegriCloud