summaryrefslogtreecommitdiff
path: root/test/Parser
diff options
context:
space:
mode:
Diffstat (limited to 'test/Parser')
-rw-r--r--test/Parser/cxx-class.cpp10
-rw-r--r--test/Parser/cxx-concept-declaration.cpp30
-rw-r--r--test/Parser/cxx-concepts-ambig-constraint-expr.cpp29
-rw-r--r--test/Parser/cxx-concepts-requires-clause.cpp82
-rw-r--r--test/Parser/nullability.c8
5 files changed, 155 insertions, 4 deletions
diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp
index 38eef1756d0f2..9e907f1b1c12f 100644
--- a/test/Parser/cxx-class.cpp
+++ b/test/Parser/cxx-class.cpp
@@ -24,6 +24,16 @@ public:
; // expected-warning{{extra ';' inside a class}}
virtual int vf() const volatile = 0;
+
+ virtual int vf0() = 0l; // expected-error {{does not look like a pure-specifier}}
+ virtual int vf1() = 1; // expected-error {{does not look like a pure-specifier}}
+ virtual int vf2() = 00; // expected-error {{does not look like a pure-specifier}}
+ virtual int vf3() = 0x0; // expected-error {{does not look like a pure-specifier}}
+ virtual int vf4() = 0.0; // expected-error {{does not look like a pure-specifier}}
+ virtual int vf5(){0}; // expected-error +{{}} expected-warning {{unused}}
+ virtual int vf5a(){0;}; // function definition, expected-warning {{unused}}
+ virtual int vf6()(0); // expected-error +{{}} expected-note +{{}}
+ virtual int vf7() = { 0 }; // expected-error {{does not look like a pure-specifier}}
private:
int x,f(),y,g();
diff --git a/test/Parser/cxx-concept-declaration.cpp b/test/Parser/cxx-concept-declaration.cpp
new file mode 100644
index 0000000000000..591629ca28565
--- /dev/null
+++ b/test/Parser/cxx-concept-declaration.cpp
@@ -0,0 +1,30 @@
+
+// Support parsing of function concepts and variable concepts
+
+// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template<typename T> concept bool C1 = true;
+
+template<typename T> concept bool C2() { return true; }
+
+template<typename T>
+struct A { typedef bool Boolean; };
+
+template<int N>
+A<void>::Boolean concept C3(!0);
+
+template<typename T, int = 0>
+concept auto C4(void) -> bool { return true; }
+
+constexpr int One = 1;
+
+template <typename>
+static concept decltype(!0) C5 { bool(One) };
+
+template<typename T> concept concept bool C6 = true; // expected-warning {{duplicate 'concept' declaration specifier}}
+
+template<typename T> concept concept bool C7() { return true; } // expected-warning {{duplicate 'concept' declaration specifier}}
+
+concept D1 = true; // expected-error {{C++ requires a type specifier for all declarations}}
+
+template<concept T> concept bool D2 = true; // expected-error {{unknown type name 'T'}}
diff --git a/test/Parser/cxx-concepts-ambig-constraint-expr.cpp b/test/Parser/cxx-concepts-ambig-constraint-expr.cpp
new file mode 100644
index 0000000000000..12ab338a6b00a
--- /dev/null
+++ b/test/Parser/cxx-concepts-ambig-constraint-expr.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ %s -verify
+
+// Test parsing of constraint-expressions in cases where the grammar is
+// ambiguous with the expectation that the longest token sequence which matches
+// the syntax is consumed without backtracking.
+
+// type-specifier-seq in conversion-type-id
+template <typename T> requires (bool)&T::operator short
+unsigned int foo(); // expected-error {{C++ requires a type specifier for all declarations}}
+
+// type-specifier-seq in new-type-id
+template <typename T> requires (bool)sizeof new (T::f()) short
+unsigned int bar(); // expected-error {{C++ requires a type specifier for all declarations}}
+
+template<typename T> requires (bool)sizeof new (T::f()) unsigned // expected-error {{'struct' cannot be signed or unsigned}}
+struct X { }; // expected-error {{'X' cannot be defined in a type specifier}}
+
+// C-style cast
+// of function call on function-style cast
+template <typename T> requires (bool(T()))
+T (*fp)(); // expected-error {{use of undeclared identifier 'fp'}}
+
+// function-style cast
+// as the callee in a function call
+struct A {
+ static int t;
+ template <typename T> requires bool(T())
+ (A(T (&t))) { } // expected-error {{called object type 'bool' is not a function or function pointer}}
+};
diff --git a/test/Parser/cxx-concepts-requires-clause.cpp b/test/Parser/cxx-concepts-requires-clause.cpp
new file mode 100644
index 0000000000000..01893a94cbc94
--- /dev/null
+++ b/test/Parser/cxx-concepts-requires-clause.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ %s -verify
+// expected-no-diagnostics
+
+// Test parsing of the optional requires-clause in a template-declaration.
+
+template <typename T> requires true
+void foo() { }
+
+
+template <typename T> requires !0
+struct A {
+ void foo();
+ struct AA;
+ enum E : int;
+ static int x;
+
+ template <typename> requires true
+ void Mfoo();
+
+ template <typename> requires true
+ struct M;
+
+ template <typename> requires true
+ static int Mx;
+
+ template <typename TT> requires true
+ using MQ = M<TT>;
+};
+
+template <typename T> requires !0
+void A<T>::foo() { }
+
+template <typename T> requires !0
+struct A<T>::AA { };
+
+template <typename T> requires !0
+enum A<T>::E : int { E0 };
+
+template <typename T> requires !0
+int A<T>::x = 0;
+
+template <typename T> requires !0
+template <typename> requires true
+void A<T>::Mfoo() { }
+
+template <typename T> requires !0
+template <typename> requires true
+struct A<T>::M { };
+
+template <typename T> requires !0
+template <typename> requires true
+int A<T>::Mx = 0;
+
+
+template <typename T> requires true
+int x = 0;
+
+template <typename T> requires true
+using Q = A<T>;
+
+struct C {
+ template <typename> requires true
+ void Mfoo();
+
+ template <typename> requires true
+ struct M;
+
+ template <typename> requires true
+ static int Mx;
+
+ template <typename T> requires true
+ using MQ = M<T>;
+};
+
+template <typename> requires true
+void C::Mfoo() { }
+
+template <typename> requires true
+struct C::M { };
+
+template <typename> requires true
+int C::Mx = 0;
diff --git a/test/Parser/nullability.c b/test/Parser/nullability.c
index f2b6abf73dcf6..7117bce4bb747 100644
--- a/test/Parser/nullability.c
+++ b/test/Parser/nullability.c
@@ -1,14 +1,14 @@
// RUN: %clang_cc1 -fsyntax-only -std=c99 -Wno-nullability-declspec -pedantic %s -verify
-__nonnull int *ptr; // expected-warning{{type nullability specifier '__nonnull' is a Clang extension}}
+_Nonnull int *ptr; // expected-warning{{type nullability specifier '_Nonnull' is a Clang extension}}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability-extension"
-__nonnull int *ptr2; // no-warning
+_Nonnull int *ptr2; // no-warning
#pragma clang diagnostic pop
-#if __has_feature(nullability)
-# error Nullability should not be supported in C under -pedantic -std=c99
+#if !__has_feature(nullability)
+# error Nullability should always be supported
#endif
#if !__has_extension(nullability)