summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-04-13 00:40:32 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-04-13 00:40:32 +0000
commitc7f9bb17574381ccc401bf1ae63e07fb811a3eb0 (patch)
treefb2248a96ebada9159977dc35156c345361a4a9c /clang/test
parent0f64d663041c2215aa58ea84d5bb5ea798025fcc (diff)
downloadbcm5719-llvm-c7f9bb17574381ccc401bf1ae63e07fb811a3eb0.tar.gz
bcm5719-llvm-c7f9bb17574381ccc401bf1ae63e07fb811a3eb0.zip
Tests for DR501-525.
llvm-svn: 206123
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/drs/dr2xx.cpp2
-rw-r--r--clang/test/CXX/drs/dr5xx.cpp181
2 files changed, 182 insertions, 1 deletions
diff --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp
index 19cb122aa6f..692ed1d1afd 100644
--- a/clang/test/CXX/drs/dr2xx.cpp
+++ b/clang/test/CXX/drs/dr2xx.cpp
@@ -686,6 +686,8 @@ namespace dr259 { // dr259: yes c++11
#endif
}
+// FIXME: When dr260 is resolved, also add tests for DR507.
+
namespace dr261 { // dr261: no
#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wused-but-marked-unused"
diff --git a/clang/test/CXX/drs/dr5xx.cpp b/clang/test/CXX/drs/dr5xx.cpp
index fa8d5682372..09b28690fd4 100644
--- a/clang/test/CXX/drs/dr5xx.cpp
+++ b/clang/test/CXX/drs/dr5xx.cpp
@@ -14,4 +14,183 @@ namespace dr500 { // dr500: dup 372
class D : public A::B {};
}
-// expected-no-diagnostics
+namespace dr501 { // dr501: yes
+ struct A {
+ friend void f() {}
+ void g() {
+ void (*p)() = &f; // expected-error {{undeclared identifier}}
+ }
+ };
+}
+
+namespace dr502 { // dr502: yes
+ struct Q {};
+ template<typename T> struct A {
+ enum E { e = 1 };
+ void q1() { f(e); }
+ void q2() { Q arr[sizeof(E)]; f(arr); }
+ void q3() { Q arr[e]; f(arr); }
+ void sanity() { Q arr[1]; f(arr); } // expected-error {{undeclared identifier 'f'}}
+ };
+ int f(A<int>::E);
+ template<int N> int f(Q (&)[N]);
+ template struct A<int>;
+}
+
+namespace dr505 { // dr505: yes
+ const char *exts = "\e\(\{\[\%"; // expected-error 5{{use of non-standard escape}}
+ const char *unknown = "\Q"; // expected-error {{unknown escape sequence}}
+}
+
+namespace dr506 { // dr506: yes
+ struct NonPod { ~NonPod(); };
+ void f(...);
+ void g(NonPod np) { f(np); } // expected-error {{cannot pass}}
+}
+
+// FIXME: Add tests here once DR260 is resolved.
+// dr507: dup 260
+
+// dr508: na
+// dr509: na
+// dr510: na
+
+namespace dr512 { // dr512: yes
+ struct A {
+ A(int);
+ };
+ union U { A a; };
+#if __cplusplus < 201103L
+ // expected-error@-2 {{has a non-trivial constructor}}
+ // expected-note@-6 {{no default constructor}}
+ // expected-note@-6 {{suppressed by user-declared constructor}}
+#endif
+}
+
+// dr513: na
+
+namespace dr514 { // dr514: yes
+ namespace A { extern int x, y; }
+ int A::x = y;
+}
+
+namespace dr515 { // dr515: sup 1017
+ // FIXME: dr1017 reverses the wording of dr515, but the current draft has
+ // dr515's wording, with a different fix for dr1017.
+
+ struct X { int n; };
+ template<typename T> struct Y : T {
+ int f() { return X::n; }
+ };
+ int k = Y<X>().f();
+
+ struct A { int a; };
+ struct B { void f() { int k = sizeof(A::a); } };
+#if __cplusplus < 201103L
+ // expected-error@-2 {{invalid use of non-static data member}}
+#endif
+}
+
+// dr516: na
+
+namespace dr517 { // dr517: no
+ // This is NDR, but we should diagnose it anyway.
+ template<typename T> struct S {};
+ template<typename T> int v = 0; // expected-error 0-1{{extension}}
+
+ template struct S<int*>;
+ template int v<int*>;
+
+ S<char&> s;
+ int k = v<char&>;
+
+ // FIXME: These are both ill-formed.
+ template<typename T> struct S<T*> {};
+ template<typename T> int v<T*> = 0; // expected-error 0-1{{extension}}
+
+ // FIXME: These are both ill-formed.
+ template<typename T> struct S<T&> {};
+ template<typename T> int v<T&> = 0; // expected-error 0-1{{extension}}
+}
+
+namespace dr518 { // dr518: yes c++11
+ enum E { e, };
+#if __cplusplus < 201103L
+ // expected-error@-2 {{C++11 extension}}
+#endif
+}
+
+namespace dr519 { // dr519: yes
+// FIXME: Add a codegen test.
+#if __cplusplus >= 201103L
+#define fold(x) (__builtin_constant_p(x) ? (x) : (x))
+ int test[fold((int*)(void*)0) ? -1 : 1];
+#undef fold
+#endif
+}
+
+// dr520: na
+
+// dr521: no
+// FIXME: The wording here is broken. It's not reasonable to expect a
+// diagnostic here. Once the relevant DR gets a number, mark this as a dup.
+
+namespace dr522 { // dr522: yes
+ struct S {};
+ template<typename T> void b1(volatile T &);
+ template<typename T> void b2(volatile T * const *);
+ template<typename T> void b2(volatile T * const S::*);
+ template<typename T> void b2(volatile T * const S::* const *);
+ // FIXME: This diagnostic isn't very good. The problem is not substitution failure.
+ template<typename T> void b2a(volatile T *S::* const *); // expected-note {{substitution failure}}
+
+ template<typename T> struct Base {};
+ struct Derived : Base<int> {};
+ template<typename T> void b3(Base<T>);
+ template<typename T> void b3(Base<T> *);
+
+ void test(int n, const int cn, int **p, int *S::*pm) {
+ int *a[3], *S::*am[3];
+ const Derived cd = Derived();
+ Derived d[3];
+
+ b1(n);
+ b1(cn);
+ b2(p);
+ b2(pm);
+ b2(a);
+ b2(am);
+ b2a(am); // expected-error {{no matching function}}
+ b3(d);
+ b3(cd);
+ }
+}
+
+namespace dr524 { // dr524: yes
+ template<typename T> void f(T a, T b) { operator+(a, b); } // expected-error {{call}}
+
+ struct S {};
+ void operator+(S, S);
+ template void f(S, S);
+
+ namespace N { struct S {}; }
+ void operator+(N::S, N::S); // expected-note {{should be declared}}
+ template void f(N::S, N::S); // expected-note {{instantiation}}
+}
+
+namespace dr525 { // dr525: yes
+ namespace before {
+ // Note, the example was correct prior to the change; instantiation is
+ // required for cases like this:
+ template <class T> struct D { operator T*(); };
+ void g(D<double> ppp) {
+ delete ppp;
+ }
+ }
+ namespace after {
+ template <class T> struct D { typename T::error e; }; // expected-error {{prior to '::'}}
+ void g(D<double> *ppp) {
+ delete ppp; // expected-note {{instantiation of}}
+ }
+ }
+}
OpenPOWER on IntegriCloud