summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX')
-rw-r--r--clang/test/CXX/drs/dr0xx.cpp4
-rw-r--r--clang/test/CXX/drs/dr3xx.cpp7
-rw-r--r--clang/test/CXX/drs/dr7xx.cpp49
-rw-r--r--clang/test/CXX/temp/temp.deduct.guide/p1.cpp2
-rw-r--r--clang/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp8
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp31
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp48
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp8
8 files changed, 71 insertions, 86 deletions
diff --git a/clang/test/CXX/drs/dr0xx.cpp b/clang/test/CXX/drs/dr0xx.cpp
index fbca6635ec1..a311d8f3393 100644
--- a/clang/test/CXX/drs/dr0xx.cpp
+++ b/clang/test/CXX/drs/dr0xx.cpp
@@ -499,10 +499,10 @@ namespace dr42 { // dr42: yes
// dr43: na
-namespace dr44 { // dr44: yes
+namespace dr44 { // dr44: sup 727
struct A {
template<int> void f();
- template<> void f<0>(); // expected-error {{explicit specialization of 'f' in class scope}}
+ template<> void f<0>();
};
}
diff --git a/clang/test/CXX/drs/dr3xx.cpp b/clang/test/CXX/drs/dr3xx.cpp
index 3342148461a..0de2d495a34 100644
--- a/clang/test/CXX/drs/dr3xx.cpp
+++ b/clang/test/CXX/drs/dr3xx.cpp
@@ -925,7 +925,7 @@ namespace dr373 { // dr373: 5
using namespace A::B; // expected-error {{expected namespace name}}
}
-namespace dr374 { // dr374: yes c++11
+namespace dr374 { // dr374: yes
namespace N {
template<typename T> void f();
template<typename T> struct A { void f(); };
@@ -933,11 +933,6 @@ namespace dr374 { // dr374: yes c++11
template<> void N::f<char>() {}
template<> void N::A<char>::f() {}
template<> struct N::A<int> {};
-#if __cplusplus < 201103L
- // expected-error@-4 {{extension}} expected-note@-7 {{here}}
- // expected-error@-4 {{extension}} expected-note@-7 {{here}}
- // expected-error@-4 {{extension}} expected-note@-8 {{here}}
-#endif
}
// dr375: dup 345
diff --git a/clang/test/CXX/drs/dr7xx.cpp b/clang/test/CXX/drs/dr7xx.cpp
index fe4a2dc5ee4..982ffdddab3 100644
--- a/clang/test/CXX/drs/dr7xx.cpp
+++ b/clang/test/CXX/drs/dr7xx.cpp
@@ -3,6 +3,53 @@
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+namespace dr727 { // dr727: 7
+ struct A {
+ template<typename T> struct C; // expected-note 6{{here}}
+ template<typename T> void f(); // expected-note {{here}}
+ template<typename T> static int N; // expected-error 0-1{{C++14}} expected-note 6{{here}}
+
+ template<> struct C<int>;
+ template<> void f<int>();
+ template<> static int N<int>;
+
+ template<typename T> struct C<T*>;
+ template<typename T> static int N<T*>;
+
+ struct B {
+ template<> struct C<float>; // expected-error {{not in class 'A' or an enclosing namespace}}
+ template<> void f<float>(); // expected-error {{no function template matches}}
+ template<> static int N<float>; // expected-error {{not in class 'A' or an enclosing namespace}}
+
+ template<typename T> struct C<T**>; // expected-error {{not in class 'A' or an enclosing namespace}}
+ template<typename T> static int N<T**>; // expected-error {{not in class 'A' or an enclosing namespace}}
+
+ template<> struct A::C<double>; // expected-error {{not in class 'A' or an enclosing namespace}}
+ template<> void A::f<double>(); // expected-error {{no function template matches}} expected-error {{cannot have a qualified name}}
+ template<> static int A::N<double>; // expected-error {{not in class 'A' or an enclosing namespace}} expected-error {{cannot have a qualified name}}
+
+ template<typename T> struct A::C<T***>; // expected-error {{not in class 'A' or an enclosing namespace}}
+ template<typename T> static int A::N<T***>; // expected-error {{not in class 'A' or an enclosing namespace}} expected-error {{cannot have a qualified name}}
+ };
+ };
+
+ template<> struct A::C<char>;
+ template<> void A::f<char>();
+ template<> int A::N<char>;
+
+ template<typename T> struct A::C<T****>;
+ template<typename T> int A::N<T****>;
+
+ namespace C {
+ template<> struct A::C<long>; // expected-error {{not in class 'A' or an enclosing namespace}}
+ template<> void A::f<long>(); // expected-error {{not in class 'A' or an enclosing namespace}}
+ template<> int A::N<long>; // expected-error {{not in class 'A' or an enclosing namespace}}
+
+ template<typename T> struct A::C<T*****>; // expected-error {{not in class 'A' or an enclosing namespace}}
+ template<typename T> int A::N<T*****>; // expected-error {{not in class 'A' or an enclosing namespace}}
+ }
+}
+
namespace dr777 { // dr777: 3.7
#if __cplusplus >= 201103L
template <typename... T>
@@ -16,5 +63,3 @@ template <typename... T>
void h(int i = 0, T ...args, int j = 1) {}
#endif
}
-
-// expected-no-diagnostics
diff --git a/clang/test/CXX/temp/temp.deduct.guide/p1.cpp b/clang/test/CXX/temp/temp.deduct.guide/p1.cpp
index c0a2ba1129e..8bb9da8a972 100644
--- a/clang/test/CXX/temp/temp.deduct.guide/p1.cpp
+++ b/clang/test/CXX/temp/temp.deduct.guide/p1.cpp
@@ -101,7 +101,7 @@ namespace ExplicitInst {
struct X {
template<typename T> struct C {};
template<typename T> C(T) -> C<T>;
- template<> C(int) -> C<int>; // expected-error {{explicit specialization of '<deduction guide for C>' in class scope}}
+ template<> C(int) -> C<int>; // expected-error {{deduction guide cannot be explicitly specialized}}
extern template C(float) -> C<float>; // expected-error {{expected member name or ';'}}
template C(char) -> C<char>; // expected-error {{expected '<' after 'template'}}
};
diff --git a/clang/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp b/clang/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp
index 425d527e521..741ebc5de41 100644
--- a/clang/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp
+++ b/clang/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp
@@ -28,10 +28,8 @@ T pi1 = T(3.1415926535897932385); // expected-note 0-2 {{here}}
// Should recover as if specialization
template float pi1<float> = 1.0; // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}}
-#ifndef FIXING
namespace expected_global {
- template<> double pi1<double> = 1.5; // expected-error {{variable template specialization of 'pi1' must originally be declared in the global scope}}
- template int pi1<int> = 10; // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} \
- expected-error {{variable template specialization of 'pi1' must originally be declared in the global scope}}
-}
+#ifndef FIXING
+ template int pi1<int> = 10; // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} expected-error {{must occur at global scope}}
#endif
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp
index d0e24f54772..c29646dd945 100644
--- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp
@@ -10,9 +10,6 @@ struct NonDefaultConstructible {
NonDefaultConstructible(int);
};
-// FIXME: The "must originally be declared in namespace" diagnostics throughout
-// this file are wrong.
-
// C++ [temp.expl.spec]p1:
// An explicit specialization of any of the following:
@@ -43,7 +40,7 @@ template<> void N0::f0(double) { }
struct X1 {
template<typename T> void f(T);
- template<> void f(int); // expected-error{{in class scope}}
+ template<> void f(int); // OK (DR727)
};
// -- class template
@@ -94,7 +91,7 @@ template<> struct N0::X0<volatile void> {
// -- variable template [C++1y]
namespace N0 {
-template<typename T> int v0; // expected-note +{{here}}
+template<typename T> int v0; // expected-note 4{{explicitly specialized declaration is here}}
template<> extern int v0<char[1]>;
template<> extern int v0<char[2]>;
template<> extern int v0<char[5]>;
@@ -102,32 +99,32 @@ template<> extern int v0<char[6]>;
}
using N0::v0;
-template<typename T> int v1; // expected-note +{{here}}
+template<typename T> int v1; // expected-note 4{{explicitly specialized declaration is here}}
template<> extern int v1<char[3]>;
template<> extern int v1<char[4]>;
template<> extern int v1<char[7]>;
template<> extern int v1<char[8]>;
template<> int N0::v0<int[1]>;
-template<> int v0<int[2]>; // FIXME: ill-formed
+template<> int v0<int[2]>;
template<> int ::v1<int[3]>; // expected-warning {{extra qualification}}
template<> int v1<int[4]>;
template<> int N0::v0<char[1]>;
-template<> int v0<char[2]>; // FIXME: ill-formed
+template<> int v0<char[2]>;
template<> int ::v1<char[3]>; // expected-warning {{extra qualification}}
template<> int v1<char[4]>;
namespace N1 {
-template<> int N0::v0<int[5]>; // expected-error {{must originally be declared in namespace 'N0'}} expected-error {{does not enclose namespace}}
-template<> int v0<int[6]>; // expected-error {{must originally be declared in namespace 'N0'}}
-template<> int ::v1<int[7]>; // expected-error {{must originally be declared in the global scope}} expected-error {{cannot name the global scope}}
-template<> int v1<int[8]>; // expected-error {{must originally be declared in the global scope}}
-
-template<> int N0::v0<char[5]>; // expected-error {{does not enclose namespace 'N0'}}
-template<> int v0<char[6]>; // FIXME: ill-formed
-template<> int ::v1<char[7]>; // expected-error {{cannot name the global scope}}
-template<> int v1<char[8]>; // FIXME: ill-formed
+template<> int N0::v0<int[5]>; // expected-error {{not in a namespace enclosing 'N0'}}
+template<> int v0<int[6]>; // expected-error {{not in a namespace enclosing 'N0'}}
+template<> int ::v1<int[7]>; // expected-error {{must occur at global scope}}
+template<> int v1<int[8]>; // expected-error {{must occur at global scope}}
+
+template<> int N0::v0<char[5]>; // expected-error {{not in a namespace enclosing 'N0'}}
+template<> int v0<char[6]>; // expected-error {{not in a namespace enclosing 'N0'}}
+template<> int ::v1<char[7]>; // expected-error {{must occur at global scope}}
+template<> int v1<char[8]>; // expected-error {{must occur at global scope}}
}
// -- member function of a class template
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
index 21399b62046..904f950df44 100644
--- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
@@ -20,9 +20,6 @@ struct NonDefaultConstructible {
// -- function template
namespace N0 {
template<typename T> void f0(T) {
-#if __cplusplus <= 199711L
- // expected-note@-2 {{explicitly specialized declaration is here}}
-#endif
T t;
}
@@ -43,16 +40,13 @@ namespace N1 {
}
template<> void N0::f0(double);
-#if __cplusplus <= 199711L
-// expected-warning@-2 {{first declaration of function template specialization of 'f0' outside namespace 'N0' is a C++11 extension}}
-#endif
template<> void N0::f0(double) { }
struct X1 {
template<typename T> void f(T);
- template<> void f(int); // expected-error{{in class scope}}
+ template<> void f(int);
};
// -- class template
@@ -60,38 +54,20 @@ namespace N0 {
template<typename T>
struct X0 { // expected-note {{explicitly specialized declaration is here}}
-#if __cplusplus <= 199711L
-// expected-note@-2 {{explicitly specialized declaration is here}}
-#endif
static T member;
-#if __cplusplus <= 199711L
- // expected-note@-2 {{explicitly specialized declaration is here}}
-#endif
void f1(T t) {
-#if __cplusplus <= 199711L
- // expected-note@-2 {{explicitly specialized declaration is here}}
-#endif
t = 17;
}
struct Inner : public T { }; // expected-note 2{{explicitly specialized declaration is here}}
-#if __cplusplus <= 199711L
- // expected-note@-2 {{explicitly specialized declaration is here}}
-#endif
template<typename U>
struct InnerTemplate : public T { }; // expected-note {{explicitly specialized declaration is here}}
-#if __cplusplus <= 199711L
- // expected-note@-2 {{explicitly specialized declaration is here}}
-#endif
- // expected-error@-4 {{base specifier must name a class}}
+ // expected-error@-1 {{base specifier must name a class}}
template<typename U>
void ft1(T t, U u);
-#if __cplusplus <= 199711L
- // expected-note@-2 {{explicitly specialized declaration is here}}
-#endif
};
}
@@ -105,9 +81,6 @@ void N0::X0<T>::ft1(T t, U u) {
template<typename T> T N0::X0<T>::member;
template<> struct N0::X0<void> { };
-#if __cplusplus <= 199711L
-// expected-warning@-2 {{first declaration of class template specialization of 'X0' outside namespace 'N0' is a C++11 extension}}
-#endif
N0::X0<void> test_X0;
namespace N1 {
@@ -124,9 +97,6 @@ template<> struct N0::X0<volatile void> {
// -- member function of a class template
template<> void N0::X0<void*>::f1(void *) { }
-#if __cplusplus <= 199711L
-// expected-warning@-2 {{first declaration of member function specialization of 'f1' outside namespace 'N0' is a C++11 extension}}
-#endif
void test_spec(N0::X0<void*> xvp, void *vp) {
xvp.f1(vp);
@@ -160,9 +130,6 @@ NonDefaultConstructible &get_static_member() {
}
template<> int N0::X0<int>::member;
-#if __cplusplus <= 199711L
-// expected-warning@-2 {{first declaration of static data member specialization of 'member' outside namespace 'N0' is a C++11 extension}}
-#endif
template<> float N0::X0<float>::member = 3.14f;
@@ -191,9 +158,6 @@ namespace N0 {
template<>
struct N0::X0<long>::Inner { };
-#if __cplusplus <= 199711L
-// expected-warning@-2 {{first declaration of member class specialization of 'Inner' outside namespace 'N0' is a C++11 extension}}
-#endif
template<>
struct N0::X0<float>::Inner { };
@@ -233,9 +197,6 @@ struct N0::X0<int>::InnerTemplate<long> { }; // okay
template<> template<>
struct N0::X0<int>::InnerTemplate<float> { };
-#if __cplusplus <= 199711L
-// expected-warning@-2 {{first declaration of class template specialization of 'InnerTemplate' outside namespace 'N0' is a C++11 extension}}
-#endif
namespace N1 {
template<> template<>
@@ -268,9 +229,6 @@ void N0::X0<void*>::ft1(void *, unsigned) { } // okay
template<> template<>
void N0::X0<void*>::ft1(void *, float) { }
-#if __cplusplus <= 199711L
-// expected-warning@-2 {{first declaration of function template specialization of 'ft1' outside namespace 'N0' is a C++11 extension}}
-#endif
namespace N1 {
template<> template<>
@@ -293,6 +251,6 @@ namespace PR8979 {
template<typename T, typename U> void f(Inner<T, U>&);
typedef Inner<OtherInner, OtherInner> MyInner;
- template<> void f(MyInner&); // expected-error{{cannot specialize a function 'f' within class scope}}
+ template<> void f(MyInner&);
};
}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
index d82691c7c86..ca55c54a5e9 100644
--- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
@@ -4,17 +4,9 @@
namespace N {
template<class T> class X; // expected-note {{'N::X' declared here}}
-#if __cplusplus <= 199711L
- // expected-note@-2 {{explicitly specialized declaration is here}}
-#endif
}
-// TODO: Don't add a namespace qualifier to the template if it would trigger
-// the warning about the specialization being outside of the namespace.
template<> class X<int> { /* ... */ }; // expected-error {{no template named 'X'; did you mean 'N::X'?}}
-#if __cplusplus <= 199711L
-// expected-warning@-2 {{first declaration of class template specialization of 'X' outside namespace 'N' is a C++11 extension}}
-#endif
namespace N {
OpenPOWER on IntegriCloud