summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX')
-rw-r--r--clang/test/CXX/temp/concept/p4.cpp6
-rw-r--r--clang/test/CXX/temp/temp.constr/temp.constr.decl/class-template-decl.cpp24
-rw-r--r--clang/test/CXX/temp/temp.constr/temp.constr.decl/func-template-decl.cpp59
-rw-r--r--clang/test/CXX/temp/temp.constr/temp.constr.decl/var-template-decl.cpp25
4 files changed, 106 insertions, 8 deletions
diff --git a/clang/test/CXX/temp/concept/p4.cpp b/clang/test/CXX/temp/concept/p4.cpp
new file mode 100644
index 00000000000..2e0226779f5
--- /dev/null
+++ b/clang/test/CXX/temp/concept/p4.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+
+template<typename T> requires true
+concept C = true; // expected-error{{concept cannot have associated constraints}}
+
+// TODO: Add test for other kinds of associated constraints once we have them.
diff --git a/clang/test/CXX/temp/temp.constr/temp.constr.decl/class-template-decl.cpp b/clang/test/CXX/temp/temp.constr/temp.constr.decl/class-template-decl.cpp
index d1ad0404ef4..5d5361f9c20 100644
--- a/clang/test/CXX/temp/temp.constr/temp.constr.decl/class-template-decl.cpp
+++ b/clang/test/CXX/temp/temp.constr/temp.constr.decl/class-template-decl.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
namespace nodiag {
@@ -13,15 +13,15 @@ namespace diag {
template <typename T> requires true // expected-note{{previous template declaration is here}}
struct A;
-template <typename T> struct A; // expected-error{{associated constraints differ in template redeclaration}}
+template <typename T> struct A; // expected-error{{requires clause differs in template redeclaration}}
template <typename T> struct B; // expected-note{{previous template declaration is here}}
-template <typename T> requires true // expected-error{{associated constraints differ in template redeclaration}}
+template <typename T> requires true // expected-error{{requires clause differs in template redeclaration}}
struct B;
template <typename T> requires true // expected-note{{previous template declaration is here}}
struct C;
-template <typename T> requires !0 // expected-error{{associated constraints differ in template redeclaration}}
+template <typename T> requires !0 // expected-error{{requires clause differs in template redeclaration}}
struct C;
} // end namespace diag
@@ -33,7 +33,7 @@ struct AA {
struct A;
};
-template <typename T> requires someFunc(T())
+template <typename U> requires someFunc(U())
struct AA::A { };
struct AAF {
@@ -47,18 +47,26 @@ namespace diag {
template <unsigned N>
struct TA {
- template <template <unsigned> class TT> requires TT<N>::happy // expected-note 2{{previous template declaration is here}}
+ template <template <unsigned> class TT> requires TT<N>::happy // expected-note {{previous template declaration is here}}
struct A;
+ template <template <unsigned> class TT> requires TT<N>::happy // expected-note {{previous template declaration is here}}
+ struct B;
+
struct AF;
};
template <unsigned N>
-template <template <unsigned> class TT> struct TA<N>::A { }; // expected-error{{associated constraints differ in template redeclaration}}
+template <template <unsigned> class TT> struct TA<N>::A { }; // expected-error{{requires clause differs in template redeclaration}}
+
+
+template <unsigned N>
+template <template <unsigned> class TT> requires TT<N + 1>::happy struct TA<N>::B { }; // expected-error{{requires clause differs in template redeclaration}}
template <unsigned N>
struct TA<N>::AF {
- template <template <unsigned> class TT> requires TT<N + 0>::happy // expected-error{{associated constraints differ in template redeclaration}}
+ // we do not expect a diagnostic here because the template parameter list is dependent.
+ template <template <unsigned> class TT> requires TT<N + 0>::happy
friend struct TA::A;
};
diff --git a/clang/test/CXX/temp/temp.constr/temp.constr.decl/func-template-decl.cpp b/clang/test/CXX/temp/temp.constr/temp.constr.decl/func-template-decl.cpp
new file mode 100644
index 00000000000..c83ab26059d
--- /dev/null
+++ b/clang/test/CXX/temp/temp.constr/temp.constr.decl/func-template-decl.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
+
+namespace nodiag {
+
+template <typename T> requires bool(T())
+int A();
+template <typename U> requires bool(U())
+int A();
+
+} // end namespace nodiag
+
+namespace diag {
+
+namespace orig {
+ template <typename T> requires true
+ int A();
+ template <typename T>
+ int B();
+ template <typename T> requires true
+ int C();
+}
+
+template <typename T>
+int orig::A();
+// expected-error@-1{{out-of-line declaration of 'A' does not match any declaration in namespace 'diag::orig'}}
+template <typename T> requires true
+int orig::B();
+// expected-error@-1{{out-of-line declaration of 'B' does not match any declaration in namespace 'diag::orig'}}
+template <typename T> requires !0
+int orig::C();
+// expected-error@-1{{out-of-line declaration of 'C' does not match any declaration in namespace 'diag::orig'}}
+
+} // end namespace diag
+
+namespace nodiag {
+
+struct AA {
+ template <typename T> requires someFunc(T())
+ int A();
+};
+
+template <typename T> requires someFunc(T())
+int AA::A() { return sizeof(T); }
+
+} // end namespace nodiag
+
+namespace diag {
+
+template <unsigned N>
+struct TA {
+ template <template <unsigned> class TT> requires TT<N>::happy
+ int A();
+};
+
+template <unsigned N>
+template <template <unsigned> class TT> int TA<N>::A() { return sizeof(TT<N>); }
+// expected-error@-1{{out-of-line definition of 'A' does not match any declaration in 'TA<N>'}}
+
+} // end namespace diag
diff --git a/clang/test/CXX/temp/temp.constr/temp.constr.decl/var-template-decl.cpp b/clang/test/CXX/temp/temp.constr/temp.constr.decl/var-template-decl.cpp
new file mode 100644
index 00000000000..cf6874f12d3
--- /dev/null
+++ b/clang/test/CXX/temp/temp.constr/temp.constr.decl/var-template-decl.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
+
+namespace nodiag {
+
+struct B {
+ template <typename T> requires bool(T())
+ static int A;
+};
+
+template <typename U> requires bool(U())
+int B::A = int(U());
+
+} // end namespace nodiag
+
+namespace diag {
+
+struct B {
+ template <typename T> requires bool(T()) // expected-note{{previous template declaration is here}}
+ static int A;
+};
+
+template <typename U> requires !bool(U()) // expected-error{{requires clause differs in template redeclaration}}
+int B::A = int(U());
+
+} // end namespace diag \ No newline at end of file
OpenPOWER on IntegriCloud