r200671 - Tests for DR301-320.

Richard Smith richard-llvm at metafoo.co.uk
Sun Feb 2 17:23:28 PST 2014


Author: rsmith
Date: Sun Feb  2 19:23:27 2014
New Revision: 200671

URL: http://llvm.org/viewvc/llvm-project?rev=200671&view=rev
Log:
Tests for DR301-320.

Modified:
    cfe/trunk/test/CXX/drs/dr3xx.cpp
    cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/test/CXX/drs/dr3xx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr3xx.cpp?rev=200671&r1=200670&r2=200671&view=diff
==============================================================================
--- cfe/trunk/test/CXX/drs/dr3xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr3xx.cpp Sun Feb  2 19:23:27 2014
@@ -8,7 +8,7 @@ namespace dr300 { // dr300: yes
   void h() { f(g); }
 }
 
-namespace dr301 { // dr301 WIP
+namespace dr301 { // dr301: yes
   // see also dr38
   struct S;
   template<typename T> void operator+(T, T);
@@ -33,4 +33,223 @@ namespace dr301 { // dr301 WIP
     T::template operator+<int>::foobar(); // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}}
     T::template operator+<int>(0); // ok
   }
+
+  template<typename T> class operator&<T*> {}; // expected-error +{{}}
+  template<typename T> class T::operator& {}; // expected-error +{{}}
+  template<typename T> class S::operator&<T*> {}; // expected-error +{{}}
+}
+
+namespace dr302 { // dr302: yes
+  struct A { A(); ~A(); };
+#if __cplusplus < 201103L
+  struct B { // expected-error {{implicit default constructor for 'dr302::B' must explicitly initialize the const member 'n'}}
+    const int n; // expected-note {{declared here}}
+    A a;
+  } b = B(); // expected-note {{first required here}}
+  // Trivial default constructor C::C() is not called here.
+  struct C {
+    const int n;
+  } c = C();
+#else
+  struct B {
+    const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}}
+    A a;
+  } b = B(); // expected-error {{call to implicitly-deleted default constructor}}
+  // C::C() is called here, because even though it's trivial, it's deleted.
+  struct C {
+    const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}}
+  } c = C(); // expected-error {{call to implicitly-deleted default constructor}}
+  struct D {
+    const int n = 0;
+  } d = D();
+#endif
+}
+
+// dr303: na
+
+namespace dr304 { // dr304: yes
+  typedef int &a;
+  int n = a(); // expected-error {{requires an initializer}}
+
+  struct S { int &b; };
+  int m = S().b;
+#if __cplusplus < 201103L
+  // expected-error at -3 {{requires an initializer}}
+  // expected-note at -3 {{in value-initialization}}
+#else
+  // expected-error at -5 {{deleted}}
+  // expected-note at -7 {{reference}}
+#endif
+}
+
+namespace dr305 { // dr305: yes
+  struct A {
+    typedef A C;
+  };
+  void f(A *a) {
+    struct A {};
+    a->~A();
+    a->~C();
+  }
+  typedef A B;
+  void g(B *b) {
+    b->~B();
+    b->~C();
+  }
+  void h(B *b) {
+    struct B {}; // expected-note {{declared here}}
+    b->~B(); // expected-error {{does not match}}
+  }
+
+  template<typename T> struct X {};
+  void i(X<int>* x) {
+    struct X {};
+    x->~X<int>();
+    x->~X();
+    x->~X<char>(); // expected-error {{no member named}}
+  }
+
+#if __cplusplus >= 201103L
+  struct Y {
+    template<typename T> using T1 = Y;
+  };
+  template<typename T> using T2 = Y;
+  void j(Y *y) {
+    y->~T1<int>();
+    y->~T2<int>();
+  }
+  struct Z {
+    template<typename T> using T2 = T;
+  };
+  void k(Z *z) {
+    // FIXME: This diagnostic is terrible.
+    z->~T1<int>(); // expected-error {{'T1' following the 'template' keyword does not refer to a template}} expected-error +{{}}
+    z->~T2<int>(); // expected-error {{no member named '~int'}}
+    z->~T2<Z>();
+  }
+#endif
+}
+
+namespace dr306 { // dr306: no
+  // FIXME: dup 39
+  // FIXME: This should be accepted.
+  struct A { struct B {}; }; // expected-note 2{{member}}
+  struct C { typedef A::B B; }; // expected-note {{member}}
+  struct D : A, A::B, C {};
+  D::B b; // expected-error {{found in multiple base classes of different types}}
+}
+
+// dr307: na
+
+namespace dr308 { // dr308: yes
+  // This is mostly an ABI library issue.
+  struct A {};
+  struct B : A {};
+  struct C : A {};
+  struct D : B, C {};
+  void f() {
+    try {
+      throw D();
+    } catch (const A&) {
+      // unreachable
+    } catch (const B&) {
+      // get here instead
+    }
+  }
+}
+
+// dr309: dup 485
+
+namespace dr311 { // dr311: yes
+  namespace X { namespace Y {} }
+  namespace X::Y {} // expected-error {{must define each namespace separately}}
+  namespace X {
+    namespace X::Y {} // expected-error {{must define each namespace separately}}
+  }
+  // FIXME: The diagnostics here are not very good.
+  namespace ::dr311::X {} // expected-error 2+{{}} // expected-warning {{extra qual}}
+}
+
+// dr312: dup 616
+
+namespace dr313 { // dr313: dup 299 c++11
+  struct A { operator int() const; };
+  int *p = new int[A()];
+#if __cplusplus < 201103L
+  // FIXME: should this be available in c++98 mode? expected-error at -2 {{extension}}
+#endif
+}
+
+// dr315: na
+// dr316: sup 1004
+
+namespace dr317 { // dr317: no
+  void f() {}
+  inline void f(); // FIXME: ill-formed
+
+  int g();
+  int n = g();
+  inline int g() { return 0; }
+
+  int h();
+  int m = h();
+  int h() { return 0; }
+  inline int h(); // FIXME: ill-formed
+}
+
+namespace dr318 { // dr318: sup 1310
+  struct A {};
+  struct A::A a;
+}
+
+namespace dr319 { // dr319: no
+  // FIXME: dup dr389
+  // FIXME: We don't have a diagnostic for a name with linkage
+  //        having a type without linkage.
+  typedef struct {
+    int i;
+  } *ps;
+  extern "C" void f(ps);
+  void g(ps); // FIXME: ill-formed, type 'ps' has no linkage
+
+  static enum { e } a1;
+  enum { e2 } a2; // FIXME: ill-formed, enum type has no linkage
+
+  enum { n1 = 1u };
+  typedef int (*pa)[n1];
+  pa parr; // ok, type has linkage despite using 'n1'
+
+  template<typename> struct X {};
+
+  void f() {
+    struct A { int n; };
+    extern A a; // FIXME: ill-formed
+    X<A> xa;
+
+    typedef A B;
+    extern B b; // FIXME: ill-formed
+    X<B> xb;
+
+    const int n = 1;
+    typedef int (*C)[n];
+    extern C c; // ok
+    X<C> xc;
+  }
+#if __cplusplus < 201103L
+  // expected-error at -12 {{uses local type 'A'}}
+  // expected-error at -9 {{uses local type 'A'}}
+#endif
+}
+
+namespace dr320 { // dr320: yes
+#if __cplusplus >= 201103L
+  struct X {
+    constexpr X() {}
+    constexpr X(const X &x) : copies(x.copies + 1) {}
+    unsigned copies = 0;
+  };
+  constexpr X f(X x) { return x; }
+  constexpr unsigned g(X x) { return x.copies; }
+  static_assert(f(X()).copies == g(X()) + 1, "expected one extra copy for return value");
+#endif
 }

Modified: cfe/trunk/www/cxx_dr_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=200671&r1=200670&r2=200671&view=diff
==============================================================================
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Sun Feb  2 19:23:27 2014
@@ -1847,55 +1847,55 @@ of class templates</td>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#301">301</a></td>
     <td>CD1</td>
     <td>Syntax for <I>template-name</I></td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#302">302</a></td>
     <td>CD1</td>
     <td>Value-initialization and generation of default constructor</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#303">303</a></td>
     <td>NAD</td>
     <td>Integral promotions on bit-fields</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="na" align="center">N/A</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#304">304</a></td>
     <td>TC1</td>
     <td>Value-initialization of a reference</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#305">305</a></td>
     <td>CD1</td>
     <td>Name lookup in destructor call</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#306">306</a></td>
     <td>CD1</td>
     <td>Ambiguity by class name injection</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="none" align="center">No</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#307">307</a></td>
     <td>NAD</td>
     <td>Initialization of a virtual base class subobject</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="na" align="center">N/A</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#308">308</a></td>
     <td>NAD</td>
     <td>Catching exceptions with ambiguous base classes</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#309">309</a></td>
     <td>CD1</td>
     <td>Linkage of entities whose names are not simply identifiers, in introduction</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="none" align="center">Duplicate of 485</td>
   </tr>
   <tr class="open">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#310">310</a></td>
@@ -1907,19 +1907,19 @@ of class templates</td>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#311">311</a></td>
     <td>NAD</td>
     <td>Using qualified name to reopen nested namespace</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#312">312</a></td>
     <td>DRWP</td>
     <td>“use” of invalid pointer value not defined</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="none" align="center">Duplicate of 616</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#313">313</a></td>
     <td>dup</td>
     <td>Class with single conversion function to integral as array size in <TT>new</TT></td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Duplicate of 299 (C++11 onwards)</td>
   </tr>
   <tr class="open">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#314">314</a></td>
@@ -1931,37 +1931,37 @@ of class templates</td>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#315">315</a></td>
     <td>NAD</td>
     <td>Is call of static member function through null pointer undefined?</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="na" align="center">N/A</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#316">316</a></td>
     <td>NAD</td>
     <td>Injected-class-name of template used as template template parameter</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="none" align="center">Superseded by 1004</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#317">317</a></td>
     <td>CD1</td>
     <td>Can a function be declared inline after it has been called?</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="none" align="center">No</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#318">318</a></td>
     <td>CD1</td>
     <td><TT>struct A::A</TT> should not name the constructor of <TT>A</TT></td>
-    <td class="none" align="center">Unknown</td>
+    <td class="none" align="center">Superseded by 1310</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#319">319</a></td>
     <td>CD1</td>
     <td>Use of names without linkage in declaring entities with linkage</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="none" align="center">No</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#320">320</a></td>
     <td>CD1</td>
     <td>Question on copy constructor elision example</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#321">321</a></td>





More information about the cfe-commits mailing list