summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaTemplate/class-template-spec.cpp2
-rw-r--r--clang/test/SemaTemplate/default-arguments.cpp3
-rw-r--r--clang/test/SemaTemplate/nested-name-spec-template.cpp50
-rw-r--r--clang/test/SemaTemplate/temp_arg.cpp6
-rw-r--r--clang/test/SemaTemplate/temp_arg_nontype.cpp52
-rw-r--r--clang/test/SemaTemplate/temp_arg_template.cpp15
-rw-r--r--clang/test/SemaTemplate/temp_arg_type.cpp13
7 files changed, 83 insertions, 58 deletions
diff --git a/clang/test/SemaTemplate/class-template-spec.cpp b/clang/test/SemaTemplate/class-template-spec.cpp
index 9347bf5997f..86cd52c3e36 100644
--- a/clang/test/SemaTemplate/class-template-spec.cpp
+++ b/clang/test/SemaTemplate/class-template-spec.cpp
@@ -40,3 +40,5 @@ void testme(X<int_type> *x1, X<float, int> *x2) {
x1->foo(); // okay: refers to #1
x2->bar(); // okay: refers to #2
}
+
+// FIXME: diagnose specializations in a different namespace
diff --git a/clang/test/SemaTemplate/default-arguments.cpp b/clang/test/SemaTemplate/default-arguments.cpp
index 94976e9735c..cc0da1942d4 100644
--- a/clang/test/SemaTemplate/default-arguments.cpp
+++ b/clang/test/SemaTemplate/default-arguments.cpp
@@ -5,8 +5,7 @@ template<typename T, int N = 2> struct X; // expected-note{{template is declared
X<int, 1> *x1;
X<int> *x2;
-X<> *x3; // expected-error{{too few template arguments for class template 'X'}} \
- // FIXME: expected-error{{expected unqualified-id}}
+X<> *x3; // expected-error{{too few template arguments for class template 'X'}}
template<typename U = float, int M> struct X;
diff --git a/clang/test/SemaTemplate/nested-name-spec-template.cpp b/clang/test/SemaTemplate/nested-name-spec-template.cpp
new file mode 100644
index 00000000000..4007f232c45
--- /dev/null
+++ b/clang/test/SemaTemplate/nested-name-spec-template.cpp
@@ -0,0 +1,50 @@
+// RUN: clang -fsyntax-only -verify %s
+
+namespace N {
+ namespace M {
+ template<typename T> struct Promote; // expected-note{{previous definition is here}}
+
+ template<> struct Promote<short> {
+ typedef int type;
+ };
+
+ template<> struct Promote<int> {
+ typedef int type;
+ };
+
+ template<> struct Promote<float> {
+ typedef double type;
+ };
+
+ Promote<short>::type *ret_intptr(int* ip) { return ip; }
+ Promote<int>::type *ret_intptr2(int* ip) { return ip; }
+ }
+
+ M::Promote<int>::type *ret_intptr3(int* ip) { return ip; }
+ M::template Promote<int>::type *ret_intptr4(int* ip) { return ip; }
+}
+
+N::M::Promote<int>::type *ret_intptr5(int* ip) { return ip; }
+::N::M::Promote<int>::type *ret_intptr6(int* ip) { return ip; }
+
+
+N::M::template; // expected-error{{expected template name after 'template' keyword in nested name specifier}} \
+ // expected-error{{expected unqualified-id}}
+
+N::M::template Promote; // expected-error{{expected '<' after 'template Promote' in nested name specifier}} \
+// expected-error{{C++ requires a type specifier for all declarations}} \
+// expected-error{{redefinition of 'Promote' as different kind of symbol}} \
+// expected-error{{no member named 'Promote'}}
+
+namespace N {
+ template<typename T> struct A;
+
+ template<>
+ struct A<int> {
+ struct X;
+ };
+}
+
+struct ::N::A<int>::X {
+ int foo;
+};
diff --git a/clang/test/SemaTemplate/temp_arg.cpp b/clang/test/SemaTemplate/temp_arg.cpp
index b8bb279caf2..b974c622a4f 100644
--- a/clang/test/SemaTemplate/temp_arg.cpp
+++ b/clang/test/SemaTemplate/temp_arg.cpp
@@ -8,7 +8,5 @@ template<typename> class X;
A<int, 0, X> * a1;
-A<float, 1, X, double> *a2; // expected-error{{too many template arguments for class template 'A'}} \
- // expected-error{{unqualified-id}}
-A<float, 1> *a3; // expected-error{{too few template arguments for class template 'A'}} \
- // expected-error{{unqualified-id}}
+A<float, 1, X, double> *a2; // expected-error{{too many template arguments for class template 'A'}}
+A<float, 1> *a3; // expected-error{{too few template arguments for class template 'A'}}
diff --git a/clang/test/SemaTemplate/temp_arg_nontype.cpp b/clang/test/SemaTemplate/temp_arg_nontype.cpp
index 89dbf237b3e..d67cc4e4097 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -3,26 +3,21 @@ template<int N> struct A; // expected-note 5{{template parameter is declared her
A<0> *a0;
-A<int()> *a1; // expected-error{{template argument for non-type template parameter is treated as type 'int (void)'}} \
- // FIXME: expected-error{{unqualified-id}}
+A<int()> *a1; // expected-error{{template argument for non-type template parameter is treated as type 'int (void)'}}
-A<int> *a2; // expected-error{{template argument for non-type template parameter must be an expression}} \
- // FIXME: expected-error{{unqualified-id}}
+A<int> *a2; // expected-error{{template argument for non-type template parameter must be an expression}}
A<1 >> 2> *a3;
// C++ [temp.arg.nontype]p5:
A<A> *a4; // expected-error{{must have an integral or enumeration type}} \
- // FIXME: the error message above is a bit lame \
- // FIXME: expected-error{{expected unqualified-id}}
+ // FIXME: the error message above is a bit lame
enum E { Enumerator = 17 };
-A<E> *a5; // expected-error{{template argument for non-type template parameter must be an expression}} \
- // FIXME: expected-error{{unqualified-id}}
+A<E> *a5; // expected-error{{template argument for non-type template parameter must be an expression}}
template<E Value> struct A1; // expected-note{{template parameter is declared here}}
A1<Enumerator> *a6; // okay
-A1<17> *a7; // expected-error{{non-type template argument of type 'int' cannot be converted to a value of type 'enum E'}} \
- // FIXME: expected-error{{expected unqualified-id}}
+A1<17> *a7; // expected-error{{non-type template argument of type 'int' cannot be converted to a value of type 'enum E'}}
const long LongValue = 12345678;
A<LongValue> *a8;
@@ -30,8 +25,7 @@ const short ShortValue = 17;
A<ShortValue> *a9;
int f(int);
-A<f(17)> *a10; // expected-error{{non-type template argument of type 'int' is not an integral constant expression}} \
- // FIXME: expected-error{{expected unqualified-id}}
+A<f(17)> *a10; // expected-error{{non-type template argument of type 'int' is not an integral constant expression}}
class X {
public:
@@ -39,8 +33,7 @@ public:
X(int, int);
operator int() const;
};
-A<X(17, 42)> *a11; // expected-error{{non-type template argument of type 'class X' must have an integral or enumeration type}} \
- // FIXME:expected-error{{expected unqualified-id}}
+A<X(17, 42)> *a11; // expected-error{{non-type template argument of type 'class X' must have an integral or enumeration type}}
template<X const *Ptr> struct A2;
@@ -50,8 +43,7 @@ X array_of_Xs[10];
A2<X_ptr> *a12;
A2<array_of_Xs> *a13;
A2<&an_X> *a13_2;
-A2<(&an_X)> *a13_2; // expected-error{{non-type template argument cannot be surrounded by parentheses}} \
- // FIXME: expected-error{{unqualified-id}}
+A2<(&an_X)> *a13_3; // expected-error{{non-type template argument cannot be surrounded by parentheses}}
float f(float);
@@ -66,10 +58,8 @@ A3<h> *a14_1;
A3<&h> *a14_2;
A3<f> *a14_3;
A3<&f> *a14_4;
-A3<h2> *a14_6; // expected-error{{non-type template argument of type 'float (*)(float)' cannot be converted to a value of type 'int (*)(int)'}} \
-// FIXME: expected-error{{expected unqualified-id}}
-A3<g> *a14_7; // expected-error{{non-type template argument of type '<overloaded function type>' cannot be converted to a value of type 'int (*)(int)'}}\
-// FIXME: expected-error{{expected unqualified-id}}
+A3<h2> *a14_6; // expected-error{{non-type template argument of type 'float (*)(float)' cannot be converted to a value of type 'int (*)(int)'}}
+A3<g> *a14_7; // expected-error{{non-type template argument of type '<overloaded function type>' cannot be converted to a value of type 'int (*)(int)'}}
// FIXME: the first error includes the string <overloaded function
// type>, which makes Doug slightly unhappy.
@@ -79,18 +69,15 @@ struct Y { } y;
volatile X * X_volatile_ptr;
template<X const &AnX> struct A4; // expected-note 2{{template parameter is declared here}}
A4<an_X> *a15_1; // okay
-A4<*X_volatile_ptr> *a15_2; // expected-error{{reference binding of non-type template parameter of type 'class X const &' to template argument of type 'class X volatile' ignores qualifiers}} \
- // FIXME: expected-error{{expected unqualified-id}}
-A4<y> *15_3; // expected-error{{non-type template parameter of reference type 'class X const &' cannot bind to template argument of type 'struct Y'}}\
- // FIXME: expected-error{{expected unqualified-id}}
+A4<*X_volatile_ptr> *a15_2; // expected-error{{reference binding of non-type template parameter of type 'class X const &' to template argument of type 'class X volatile' ignores qualifiers}}
+A4<y> *15_3; // expected-error{{non-type template parameter of reference type 'class X const &' cannot bind to template argument of type 'struct Y'}} \
+ // FIXME: expected-error{{expected unqualified-id}}
template<int (&fr)(int)> struct A5; // expected-note 2{{template parameter is declared here}}
A5<h> *a16_1;
A5<f> *a16_3;
-A5<h2> *a16_6; // expected-error{{non-type template argument of type 'float (float)' cannot be converted to a value of type 'int (&)(int)'}} \
-// FIXME: expected-error{{expected unqualified-id}}
-A5<g> *a14_7; // expected-error{{non-type template argument of type '<overloaded function type>' cannot be converted to a value of type 'int (&)(int)'}}\
-// FIXME: expected-error{{expected unqualified-id}}
+A5<h2> *a16_6; // expected-error{{non-type template argument of type 'float (float)' cannot be converted to a value of type 'int (&)(int)'}}
+A5<g> *a14_7; // expected-error{{non-type template argument of type '<overloaded function type>' cannot be converted to a value of type 'int (&)(int)'}}
// FIXME: the first error includes the string <overloaded function
// type>, which makes Doug slightly unhappy.
@@ -106,15 +93,12 @@ struct Z {
template<int (Z::*pmf)(int)> struct A6; // expected-note{{template parameter is declared here}}
A6<&Z::foo> *a17_1;
A6<&Z::bar> *a17_2;
-A6<&Z::baz> *a17_3; // expected-error{{non-type template argument of type 'double (struct Z::*)(double)' cannot be converted to a value of type 'int (struct Z::*)(int)'}} \
-// FIXME: expected-error{{expected unqualified-id}}
+A6<&Z::baz> *a17_3; // expected-error{{non-type template argument of type 'double (struct Z::*)(double)' cannot be converted to a value of type 'int (struct Z::*)(int)'}}
template<int Z::*pm> struct A7; // expected-note{{template parameter is declared here}}
template<int Z::*pm> struct A7c;
A7<&Z::int_member> *a18_1;
A7c<&Z::int_member> *a18_2;
-A7<&Z::float_member> *a18_3; // expected-error{{non-type template argument of type 'float struct Z::*' cannot be converted to a value of type 'int struct Z::*'}} \
- // FIXME: expected-error{{unqualified-id}}
-A7c<(&Z::int_member)> *a18_3; // expected-error{{non-type template argument cannot be surrounded by parentheses}} \
- // FIXME: expected-error{{expected unqualified-id}}
+A7<&Z::float_member> *a18_3; // expected-error{{non-type template argument of type 'float struct Z::*' cannot be converted to a value of type 'int struct Z::*'}}
+A7c<(&Z::int_member)> *a18_3; // expected-error{{non-type template argument cannot be surrounded by parentheses}}
diff --git a/clang/test/SemaTemplate/temp_arg_template.cpp b/clang/test/SemaTemplate/temp_arg_template.cpp
index e1b9bb4874f..781ada9cfe7 100644
--- a/clang/test/SemaTemplate/temp_arg_template.cpp
+++ b/clang/test/SemaTemplate/temp_arg_template.cpp
@@ -20,23 +20,18 @@ A<X> *a1;
A<N::Z> *a2;
A< ::N::Z> *a3;
-A<Y> *a4; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} \
- // FIXME::expected-error{{expected unqualified-id}}
-A<TooMany> *a5; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} \
- // FIXME::expected-error{{expected unqualified-id}}
-B<X> *a6; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} \
- // FIXME::expected-error{{expected unqualified-id}}
+A<Y> *a4; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
+A<TooMany> *a5; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
+B<X> *a6; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
C<Y> *a7;
-C<Ylong> *a8; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} \
- // FIXME::expected-error{{expected unqualified-id}}
+C<Ylong> *a8; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
template<typename T> void f(int);
// FIXME: we're right to provide an error message, but it should say
// that we need a class template. We won't get this right until name
// lookup of 'f' returns a TemplateDecl.
-A<f> *a9; // expected-error{{template argument for template template parameter must be a template}} \
- // expected-error{{unqualified-id}}
+A<f> *a9; // expected-error{{template argument for template template parameter must be a template}}
// FIXME: The code below is ill-formed, because of the evil digraph '<:'.
// We should provide a much better error message than we currently do.
diff --git a/clang/test/SemaTemplate/temp_arg_type.cpp b/clang/test/SemaTemplate/temp_arg_type.cpp
index 36764fc8e43..216a283e2e9 100644
--- a/clang/test/SemaTemplate/temp_arg_type.cpp
+++ b/clang/test/SemaTemplate/temp_arg_type.cpp
@@ -2,11 +2,9 @@
template<typename T> class A; // expected-note 2 {{template parameter is declared here}}
// [temp.arg.type]p1
-A<0> *a1; // expected-error{{template argument for template type parameter must be a type}} \
- // expected-error{{unqualified-id}}
+A<0> *a1; // expected-error{{template argument for template type parameter must be a type}}
-A<A> *a2; // expected-error{{template argument for template type parameter must be a type}} \
- // expected-error{{unqualified-id}}
+A<A> *a2; // expected-error{{template argument for template type parameter must be a type}}
A<int> *a3;
A<int()> *a4;
@@ -16,13 +14,12 @@ A<A<int> > *a6;
// [temp.arg.type]p2
void f() {
class X { };
- A<X> * a = 0; // expected-error{{template argument uses local type 'class X'}}\
- // FIXME: expected-error{{expected expression}}
+ A<X> * a = 0; // expected-error{{template argument uses local type 'class X'}} \
+ // FIXME: expected-error{{use of undeclared identifier 'a'}}
}
struct { int x; } Unnamed; // expected-note{{unnamed type used in template argument was declared here}}
-A<__typeof__(Unnamed)> *a7; // expected-error{{template argument uses unnamed type}} \
- // FIXME: expected-error{{expected unqualified-id}}
+A<__typeof__(Unnamed)> *a7; // expected-error{{template argument uses unnamed type}}
// FIXME: [temp.arg.type]p3. The check doesn't really belong here (it
// belongs somewhere in the template instantiation section).
OpenPOWER on IntegriCloud