r206123 - Tests for DR501-525.
Richard Smith
richard-llvm at metafoo.co.uk
Sat Apr 12 17:40:32 PDT 2014
Author: rsmith
Date: Sat Apr 12 19:40:32 2014
New Revision: 206123
URL: http://llvm.org/viewvc/llvm-project?rev=206123&view=rev
Log:
Tests for DR501-525.
Modified:
cfe/trunk/test/CXX/drs/dr2xx.cpp
cfe/trunk/test/CXX/drs/dr5xx.cpp
cfe/trunk/www/cxx_dr_status.html
Modified: cfe/trunk/test/CXX/drs/dr2xx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr2xx.cpp?rev=206123&r1=206122&r2=206123&view=diff
==============================================================================
--- cfe/trunk/test/CXX/drs/dr2xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr2xx.cpp Sat Apr 12 19:40:32 2014
@@ -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"
Modified: cfe/trunk/test/CXX/drs/dr5xx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr5xx.cpp?rev=206123&r1=206122&r2=206123&view=diff
==============================================================================
--- cfe/trunk/test/CXX/drs/dr5xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr5xx.cpp Sat Apr 12 19:40:32 2014
@@ -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 at -2 {{has a non-trivial constructor}}
+ // expected-note at -6 {{no default constructor}}
+ // expected-note at -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 at -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 at -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}}
+ }
+ }
+}
Modified: cfe/trunk/www/cxx_dr_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=206123&r1=206122&r2=206123&view=diff
==============================================================================
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Sat Apr 12 19:40:32 2014
@@ -3047,13 +3047,13 @@ of class templates</td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#501">501</a></td>
<td>NAD</td>
<td>Visibility of friend declarations within the befriending class</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="502">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#502">502</a></td>
<td>C++11</td>
<td>Dependency of nested enumerations and enumerators</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr class="open" id="503">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#503">503</a></td>
@@ -3071,37 +3071,37 @@ of class templates</td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#505">505</a></td>
<td>CD1</td>
<td>Conditionally-supported behavior for unknown character escapes</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="506">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#506">506</a></td>
<td>CD1</td>
<td>Conditionally-supported behavior for non-POD objects passed to ellipsis</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="507">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#507">507</a></td>
<td>dup</td>
<td>Ambiguity assigning class object to built-in type</td>
- <td class="none" align="center">Unknown</td>
+ <td class="none" align="center">Duplicate of <a href="#260">260</a></td>
</tr>
<tr id="508">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#508">508</a></td>
<td>C++11</td>
<td>Non-constructed value-initialized objects</td>
- <td class="none" align="center">Unknown</td>
+ <td class="na" align="center">N/A</td>
</tr>
<tr id="509">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#509">509</a></td>
<td>CD1</td>
<td>Dead code in the specification of default initialization</td>
- <td class="none" align="center">Unknown</td>
+ <td class="na" align="center">N/A</td>
</tr>
<tr id="510">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#510">510</a></td>
<td>CD1</td>
<td>Default initialization of POD classes?</td>
- <td class="none" align="center">Unknown</td>
+ <td class="na" align="center">N/A</td>
</tr>
<tr class="open" id="511">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#511">511</a></td>
@@ -3113,67 +3113,67 @@ of class templates</td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#512">512</a></td>
<td>NAD</td>
<td>Union members with user-declared non-default constructors</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="513">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#513">513</a></td>
<td>CD1</td>
<td>Non-class “most-derived” objects</td>
- <td class="none" align="center">Unknown</td>
+ <td class="na" align="center">N/A</td>
</tr>
<tr id="514">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#514">514</a></td>
<td>CD1</td>
<td>Is the initializer for a namespace member in the scope of the namespace?</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="515">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#515">515</a></td>
<td>CD1</td>
<td>Non-dependent references to base class members</td>
- <td class="none" align="center">Unknown</td>
+ <td class="none" align="center">Superseded by <a href="#1017">1017</a></td>
</tr>
<tr id="516">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#516">516</a></td>
<td>CD1</td>
<td>Use of <TT>signed</TT> in bit-field declarations</td>
- <td class="none" align="center">Unknown</td>
+ <td class="na" align="center">N/A</td>
</tr>
<tr id="517">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#517">517</a></td>
<td>CD1</td>
<td>Partial specialization following explicit instantiation</td>
- <td class="none" align="center">Unknown</td>
+ <td class="none" align="center">No</td>
</tr>
<tr id="518">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#518">518</a></td>
<td>CD1</td>
<td>Trailing comma following <I>enumerator-list</I></td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes (C++11 onwards)</td>
</tr>
<tr id="519">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#519">519</a></td>
<td>CD1</td>
<td>Null pointer preservation in <TT>void*</TT> conversions</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="520">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#520">520</a></td>
<td>CD1</td>
<td>Old-style casts between incomplete class types</td>
- <td class="none" align="center">Unknown</td>
+ <td class="na" align="center">N/A</td>
</tr>
<tr id="521">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#521">521</a></td>
<td>CD1</td>
<td>Requirements for exceptions thrown by allocation functions</td>
- <td class="none" align="center">Unknown</td>
+ <td class="none" align="center">No</td>
</tr>
<tr id="522">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#522">522</a></td>
<td>CD1</td>
<td>Array-to-pointer decay in template argument deduction</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr class="open" id="523">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#523">523</a></td>
@@ -3185,13 +3185,13 @@ of class templates</td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#524">524</a></td>
<td>CD1</td>
<td>Can function-notation calls to operator functions be dependent?</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="525">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#525">525</a></td>
<td>CD1</td>
<td>Missing <TT>*</TT> in example</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="526">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#526">526</a></td>
More information about the cfe-commits
mailing list