r216834 - Tests for DR525-550.
Richard Smith
richard-llvm at metafoo.co.uk
Sat Aug 30 20:06:20 PDT 2014
Author: rsmith
Date: Sat Aug 30 22:06:20 2014
New Revision: 216834
URL: http://llvm.org/viewvc/llvm-project?rev=216834&view=rev
Log:
Tests for DR525-550.
Modified:
cfe/trunk/test/CXX/drs/dr5xx.cpp
cfe/trunk/www/cxx_dr_status.html
Modified: cfe/trunk/test/CXX/drs/dr5xx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr5xx.cpp?rev=216834&r1=216833&r2=216834&view=diff
==============================================================================
--- cfe/trunk/test/CXX/drs/dr5xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr5xx.cpp Sat Aug 30 22:06:20 2014
@@ -195,6 +195,153 @@ namespace dr525 { // dr525: yes
}
}
+namespace dr526 { // dr526: yes
+ template<int> struct S {};
+ template<int N> void f1(S<N> s);
+ template<int N> void f2(S<(N)> s); // expected-note {{couldn't infer}}
+ template<int N> void f3(S<+N> s); // expected-note {{couldn't infer}}
+ template<int N> void g1(int (&)[N]);
+ template<int N> void g2(int (&)[(N)]); // expected-note {{couldn't infer}}
+ template<int N> void g3(int (&)[+N]); // expected-note {{couldn't infer}}
+
+ void test(int (&a)[3], S<3> s) {
+ f1(s);
+ f2(s); // expected-error {{no matching}}
+ f3(s); // expected-error {{no matching}}
+ g1(a);
+ g2(a); // expected-error {{no matching}}
+ g3(a); // expected-error {{no matching}}
+ }
+
+ template<int N> struct X {
+ typedef int type;
+ X<N>::type v1;
+ X<(N)>::type v2; // expected-error {{missing 'typename'}}
+ X<+N>::type v3; // expected-error {{missing 'typename'}}
+ };
+}
+
+namespace dr527 { // dr527: na
+ // This DR is meaningless. It removes a required diagnostic from the case
+ // where a not-externally-visible object is odr-used but not defined, which
+ // requires a diagnostic for a different reason.
+ extern struct { int x; } a; // FIXME: We should reject this, per dr389.
+ static struct { int x; } b;
+ extern "C" struct { int x; } c;
+ namespace { extern struct { int x; } d; }
+ typedef struct { int x; } *P;
+ struct E { static P e; }; // FIXME: We should reject this, per dr389.
+ namespace { struct F { static P f; }; }
+
+ int ax = a.x, bx = b.x, cx = c.x, dx = d.x, ex = E::e->x, fx = F::f->x;
+}
+
+namespace dr530 { // dr530: yes
+ template<int*> struct S { enum { N = 1 }; };
+ template<void(*)()> struct T { enum { N = 1 }; };
+ int n;
+ void f();
+ int a[S<&n>::N];
+ int b[T<&f>::N];
+}
+
+namespace dr531 { // dr531: partial
+ namespace good {
+ template<typename T> struct A {
+ void f(T) { T::error; }
+ template<typename U> void g(T, U) { T::error; }
+ struct B { typename T::error error; };
+ template<typename U> struct C { typename T::error error; };
+ static T n;
+ };
+ template<typename T> T A<T>::n = T::error;
+
+ template<> void A<int>::f(int) {}
+ template<> template<typename U> void A<int>::g(int, U) {}
+ template<> struct A<int>::B {};
+ template<> template<typename U> struct A<int>::C {};
+ template<> int A<int>::n = 0;
+
+ void use(A<int> a) {
+ a.f(a.n);
+ a.g(0, 0);
+ A<int>::B b;
+ A<int>::C<int> c;
+ }
+
+ template<> struct A<char> {
+ void f(char);
+ template<typename U> void g(char, U);
+ struct B;
+ template<typename U> struct C;
+ static char n;
+ };
+
+ void A<char>::f(char) {}
+ template<typename U> void A<char>::g(char, U) {}
+ struct A<char>::B {};
+ template<typename U> struct A<char>::C {};
+ char A<char>::n = 0;
+ }
+
+ namespace bad {
+ template<typename T> struct A {
+ void f(T) { T::error; }
+ template<typename U> void g(T, U) { T::error; }
+ struct B { typename T::error error; };
+ template<typename U> struct C { typename T::error error; }; // expected-note {{here}}
+ static T n;
+ };
+ template<typename T> T A<T>::n = T::error;
+
+ void A<int>::f(int) {} // expected-error {{requires 'template<>'}}
+ template<typename U> void A<int>::g(int, U) {} // expected-error {{should be empty}}
+ struct A<int>::B {}; // expected-error {{requires 'template<>'}}
+ template<typename U> struct A<int>::C {}; // expected-error {{should be empty}} expected-error {{different kind of symbol}}
+ int A<int>::n = 0; // expected-error {{requires 'template<>'}}
+
+ template<> struct A<char> { // expected-note 2{{here}}
+ void f(char);
+ template<typename U> void g(char, U);
+ struct B; // expected-note {{here}}
+ template<typename U> struct C;
+ static char n;
+ };
+
+ template<> void A<char>::f(char) {} // expected-error {{no function template matches}}
+ // FIXME: This is ill-formed; -pedantic-errors should reject.
+ template<> template<typename U> void A<char>::g(char, U) {} // expected-warning {{extraneous template parameter list}}
+ template<> struct A<char>::B {}; // expected-error {{extraneous 'template<>'}} expected-error {{does not specialize}}
+ // FIXME: This is ill-formed; -pedantic-errors should reject.
+ template<> template<typename U> struct A<char>::C {}; // expected-warning {{extraneous template parameter list}}
+ template<> char A<char>::n = 0; // expected-error {{extraneous 'template<>'}}
+ }
+
+ namespace nested {
+ template<typename T> struct A {
+ template<typename U> struct B;
+ };
+ template<> template<typename U> struct A<int>::B {
+ void f();
+ void g();
+ template<typename V> void h();
+ template<typename V> void i();
+ };
+ template<> template<typename U> void A<int>::B<U>::f() {}
+ template<typename U> void A<int>::B<U>::g() {} // expected-error {{should be empty}}
+
+ template<> template<typename U> template<typename V> void A<int>::B<U>::h() {}
+ template<typename U> template<typename V> void A<int>::B<U>::i() {} // expected-error {{should be empty}}
+
+ template<> template<> void A<int>::B<int>::f() {}
+ template<> template<> template<typename V> void A<int>::B<int>::h() {}
+ template<> template<> template<> void A<int>::B<int>::h<int>() {}
+
+ template<> void A<int>::B<char>::f() {} // expected-error {{requires 'template<>'}}
+ template<> template<typename V> void A<int>::B<char>::h() {} // expected-error {{should be empty}}
+ }
+}
+
// PR8130
namespace dr532 { // dr532: 3.5
struct A { };
@@ -210,3 +357,172 @@ namespace dr532 { // dr532: 3.5
int &ir = b * a;
}
}
+
+// dr533: na
+
+namespace dr534 { // dr534: yes
+ struct S {};
+ template<typename T> void operator+(S, T);
+ template<typename T> void operator+<T*>(S, T*) {} // expected-error {{function template partial spec}}
+}
+
+namespace dr535 { // dr535: yes
+ class X { private: X(const X&); };
+ struct A {
+ X x;
+ template<typename T> A(T&);
+ };
+ struct B : A {
+ X y;
+ B(volatile A&);
+ };
+
+ extern A a1;
+ A a2(a1); // ok, uses constructor template
+
+ extern volatile B b1;
+ B b2(b1); // ok, uses converting constructor
+
+ void f() { throw a1; }
+
+#if __cplusplus >= 201103L
+ struct C {
+ constexpr C() : n(0) {}
+ template<typename T> constexpr C(T&t) : n(t.n == 0 ? throw 0 : 0) {}
+ int n;
+ };
+ constexpr C c() { return C(); }
+ // ok, copy is elided
+ constexpr C x = c();
+#endif
+}
+
+// dr537: na
+// dr538: na
+
+// dr539: yes
+const dr539( // expected-error {{requires a type specifier}}
+ const a) { // expected-error {{unknown type name 'a'}}
+ const b; // expected-error {{requires a type specifier}}
+ new const; // expected-error {{expected a type}}
+ try {} catch (const n) {} // expected-error {{unknown type name 'n'}}
+ try {} catch (const) {} // expected-error {{expected a type}}
+ if (const n = 0) {} // expected-error {{requires a type specifier}}
+ switch (const n = 0) {} // expected-error {{requires a type specifier}}
+ while (const n = 0) {} // expected-error {{requires a type specifier}}
+ for (const n = 0; // expected-error {{requires a type specifier}}
+ const m = 0; ) {} // expected-error {{requires a type specifier}}
+ sizeof(const); // expected-error {{requires a type specifier}}
+ struct S {
+ const n; // expected-error {{requires a type specifier}}
+ operator const(); // expected-error {{expected a type}}
+ };
+#if __cplusplus >= 201103L
+ int arr[3];
+ // FIXME: The extra braces here are to avoid the parser getting too
+ // badly confused when recovering here. We should fix this recovery.
+ { for (const n // expected-error {{unknown type name 'n'}} expected-note {{}}
+ : arr) ; {} } // expected-error +{{}}
+ (void) [](const) {}; // expected-error {{requires a type specifier}}
+ (void) [](const n) {}; // expected-error {{unknown type name 'n'}}
+ enum E : const {}; // expected-error {{expected a type}}
+ using T = const; // expected-error {{expected a type}}
+ auto f() -> const; // expected-error {{expected a type}}
+#endif
+}
+
+namespace dr540 { // dr540: yes
+ typedef int &a;
+ typedef const a &a; // expected-warning {{has no effect}}
+ typedef const int &b;
+ typedef b &b;
+ typedef const a &c; // expected-note {{previous}} expected-warning {{has no effect}}
+ typedef const b &c; // expected-error {{different}} expected-warning {{has no effect}}
+}
+
+namespace dr541 { // dr541: yes
+ template<int> struct X { typedef int type; };
+ template<typename T> struct S {
+ int f(T);
+
+ int g(int);
+ T g(bool);
+
+ int h();
+ int h(T);
+
+ void x() {
+ // These are type-dependent expressions, even though we could
+ // determine that all calls have type 'int'.
+ X<sizeof(f(0))>::type a; // expected-error +{{}}
+ X<sizeof(g(0))>::type b; // expected-error +{{}}
+ X<sizeof(h(0))>::type b; // expected-error +{{}}
+
+ typename X<sizeof(f(0))>::type a;
+ typename X<sizeof(h(0))>::type b;
+ }
+ };
+}
+
+namespace dr542 { // dr542: yes
+#if __cplusplus >= 201103L
+ struct A { A() = delete; int n; };
+ A a[32] = {}; // ok, constructor not called
+
+ struct B {
+ int n;
+ private:
+ B() = default;
+ };
+ B b[32] = {}; // ok, constructor not called
+#endif
+}
+
+namespace dr543 { // dr543: yes
+ // In C++98+DR543, this is valid because value-initialization doesn't call a
+ // trivial default constructor, so we never notice that defining the
+ // constructor would be ill-formed.
+ //
+ // In C++11+DR543, this is ill-formed, because the default constructor is
+ // deleted, and value-initialization *does* call a deleted default
+ // constructor, even if it is trivial.
+ struct A {
+ const int n;
+ };
+ A a = A();
+#if __cplusplus >= 201103L
+ // expected-error at -2 {{deleted}}
+ // expected-note at -5 {{would not be initialized}}
+#endif
+}
+
+namespace dr544 { // dr544: yes
+ int *n;
+
+ template<class T> struct A { int n; };
+ template<class T> struct B : A<T> { int get(); };
+ template<> int B<int>::get() { return n; }
+ int k = B<int>().get();
+}
+
+namespace dr546 { // dr546: yes
+ template<typename T> struct A { void f(); };
+ template struct A<int>;
+ template<typename T> void A<T>::f() { T::error; }
+}
+
+namespace dr547 { // d547: yes
+ template<typename T> struct X;
+ template<typename T> struct X<T() const> {};
+ template<typename T, typename C> X<T> f(T C::*) { return X<T>(); }
+
+ struct S { void f() const; };
+ X<void() const> x = f(&S::f);
+}
+
+namespace dr548 { // dr548: dup 482
+ template<typename T> struct S {};
+ template<typename T> void f() {}
+ template struct dr548::S<int>;
+ template void dr548::f<int>();
+}
Modified: cfe/trunk/www/cxx_dr_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=216834&r1=216833&r2=216834&view=diff
==============================================================================
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Sat Aug 30 22:06:20 2014
@@ -675,7 +675,7 @@
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#106">106</a></td>
<td>CD1</td>
<td>Creating references to references during template deduction/instantiation</td>
- <td class="none" align="center">Superseded by <a href="#540">540</a></td>
+ <td class="full" align="center">Superseded by <a href="#540">540</a></td>
</tr>
<tr id="107">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#107">107</a></td>
@@ -705,7 +705,7 @@
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#111">111</a></td>
<td>NAD</td>
<td>Copy constructors and cv-qualifiers</td>
- <td class="none" align="center">Duplicate of <a href="#535">535</a></td>
+ <td class="full" align="center">Duplicate of <a href="#535">535</a></td>
</tr>
<tr id="112">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#112">112</a></td>
@@ -2003,7 +2003,7 @@ of class templates</td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#327">327</a></td>
<td>CD1</td>
<td>Use of "structure" without definition</td>
- <td class="none" align="center">Duplicate of <a href="#538">538</a></td>
+ <td class="na" align="center">Duplicate of <a href="#538">538</a></td>
</tr>
<tr id="328">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#328">328</a></td>
@@ -3197,13 +3197,13 @@ of class templates</td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#526">526</a></td>
<td>CD1</td>
<td>Confusing aspects in the specification of non-deduced contexts</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="527">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#527">527</a></td>
<td>CD2</td>
<td>Problems with linkage of types</td>
- <td class="none" align="center">Unknown</td>
+ <td class="na" align="center">N/A</td>
</tr>
<tr class="open" id="528">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#528">528</a></td>
@@ -3221,13 +3221,13 @@ of class templates</td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#530">530</a></td>
<td>CD1</td>
<td>Nontype template arguments in constant expressions</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="531">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#531">531</a></td>
<td>C++11</td>
<td>Defining members of explicit specializations</td>
- <td class="none" align="center">Unknown</td>
+ <td class="partial" align="center">Partial</td>
</tr>
<tr id="532">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#532">532</a></td>
@@ -3239,19 +3239,19 @@ of class templates</td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#533">533</a></td>
<td>NAD</td>
<td>Special treatment for C-style header names</td>
- <td class="none" align="center">Unknown</td>
+ <td class="na" align="center">N/A</td>
</tr>
<tr id="534">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#534">534</a></td>
<td>CD1</td>
<td><I>template-name</I>s and <I>operator-function-id</I>s</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="535">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#535">535</a></td>
<td>CD3</td>
<td>Copy construction without a copy constructor</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr class="open" id="536">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#536">536</a></td>
@@ -3263,7 +3263,7 @@ of class templates</td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#537">537</a></td>
<td>CD1</td>
<td>Definition of “signature”</td>
- <td class="none" align="center">Unknown</td>
+ <td class="na" align="center">N/A</td>
</tr>
<tr id="538">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#538">538</a></td>
@@ -3271,43 +3271,43 @@ of class templates</td>
<td>Definition and usage
of <I>structure</I>, <I>POD-struct</I>, <I>POD-union</I>,
and <I>POD class</I></td>
- <td class="none" align="center">Unknown</td>
+ <td class="na" align="center">N/A</td>
</tr>
<tr id="539">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#539">539</a></td>
<td>CD3</td>
<td>Constraints on <I>type-specifier-seq</I></td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="540">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#540">540</a></td>
<td>CD1</td>
<td>Propagation of cv-qualifiers in reference-to-reference collapse</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="541">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#541">541</a></td>
<td>CD2</td>
<td>Dependent function types</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="542">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#542">542</a></td>
<td>CD2</td>
<td>Value initialization of arrays of POD-structs</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="543">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#543">543</a></td>
<td>CD1</td>
<td>Value initialization and default constructors</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="544">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#544">544</a></td>
<td>NAD</td>
<td>Base class lookup in explicit specialization</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr class="open" id="545">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#545">545</a></td>
@@ -3319,7 +3319,7 @@ and <I>POD class</I></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#546">546</a></td>
<td>C++11</td>
<td>Explicit instantiation of class template members</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr id="547">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#547">547</a></td>
@@ -3331,7 +3331,7 @@ and <I>POD class</I></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#548">548</a></td>
<td>dup</td>
<td><I>qualified-id</I>s in declarations</td>
- <td class="none" align="center">Unknown</td>
+ <td class="svn" align="center">Duplicate of <a href="#482">482</a></td>
</tr>
<tr class="open" id="549">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#549">549</a></td>
More information about the cfe-commits
mailing list