[clang] d0918a2 - [clang] Add tests for CWG1800-1804 (#77509)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 10 00:51:08 PST 2024


Author: Vlad Serebrennikov
Date: 2024-01-10T12:51:04+04:00
New Revision: d0918a20d2a85bad3cd0ec48be4b91e873bfe737

URL: https://github.com/llvm/llvm-project/commit/d0918a20d2a85bad3cd0ec48be4b91e873bfe737
DIFF: https://github.com/llvm/llvm-project/commit/d0918a20d2a85bad3cd0ec48be4b91e873bfe737.diff

LOG: [clang] Add tests for CWG1800-1804 (#77509)

Covers C++ core issues 1800, 1801, 1802, 1803, 1804.

Added: 
    

Modified: 
    clang/test/CXX/drs/dr18xx.cpp
    clang/www/cxx_dr_status.html

Removed: 
    


################################################################################
diff  --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index fbe67bd0c2f6db..1d76804907a5c1 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -1,16 +1,169 @@
-// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus == 199711L
 #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
 // cxx98-error at -1 {{variadic macros are a C99 feature}}
 #endif
 
+namespace dr1800 { // dr1800: 2.9
+struct A { union { int n; }; };
+static_assert(__is_same(__decltype(&A::n), int A::*), "");
+} // namespace dr1800
+
+namespace dr1801 { // dr1801: 2.8
+static union {
+  int i;
+};
+
+template <int &> struct S {}; // #dr1801-S
+S<i> V; // #dr1801-S-i
+// cxx98-14-error at -1 {{non-type template argument does not refer to any declaration}}
+//   cxx98-14-note@#dr1801-S {{template parameter is declared here}}
+// since-cxx17-error@#dr1801-S-i {{non-type template argument refers to subobject '.i'}}
+}
+
+namespace dr1802 { // dr1802: 3.1
+#if __cplusplus >= 201103L
+// Using a Wikipedia example of surrogate pair:
+// https://en.wikipedia.org/wiki/UTF-16#Examples
+constexpr char16_t a[3] = u"\U00010437";
+static_assert(a[0] == 0xD801, "");
+static_assert(a[1] == 0xDC37, "");
+static_assert(a[2] == 0x0, "");
+#endif
+} // namespace dr1802
+
+namespace dr1803 { // dr1803: 2.9
+#if __cplusplus >= 201103L
+struct A {
+  enum E : int;
+  enum E : int {};
+  enum class EC;
+  enum class EC {};
+  enum struct ES;
+  enum struct ES {};
+};
+#endif
+} // namespace dr1803
+
+namespace dr1804 { // dr1804: 2.7
+template <typename, typename>
+struct A {
+  void f1();
+  
+  template <typename V>
+  void f2(V);
+
+  class B {
+    void f3();
+  };
+
+  template <typename>
+  class C {
+    void f4();
+  };
+};
+
+template <typename U>
+struct A<int, U> {
+  void f1();
+  
+  template <typename V>
+  void f2(V);
+
+  class B {
+    void f3();
+  };
+
+  template <typename>
+  class C {
+    void f4();
+  };
+};
+
+class D {
+  int i;
+
+  template <typename, typename>
+  friend struct A;
+};
+
+template <typename U>
+struct A<double, U> {
+  void f1();
+  
+  template <typename V>
+  void f2(V);
+
+  class B {
+    void f3();
+  };
+
+  template <typename>
+  class C {
+    void f4();
+  };
+};
+
+template <typename U>
+void A<int, U>::f1() {
+  D d;
+  d.i = 0;
+}
+
+template <typename U>
+void A<double, U>::f1() {
+  D d;
+  d.i = 0;
+}
+
+template <typename U>
+template <typename V>
+void A<int, U>::f2(V) {
+  D d;
+  d.i = 0;
+}
+
+template <typename U>
+template <typename V>
+void A<double, U>::f2(V) {
+  D d;
+  d.i = 0;
+}
+
+template <typename U>
+void A<int, U>::B::f3() {
+  D d;
+  d.i = 0;
+}
+
+template <typename U>
+void A<double, U>::B::f3() {
+  D d;
+  d.i = 0;
+}
+
+template <typename U>
+template <typename V>
+void A<int, U>::C<V>::f4() {
+  D d;
+  d.i = 0;
+}
+
+template <typename U>
+template <typename V>
+void A<double, U>::C<V>::f4() {
+  D d;
+  d.i = 0;
+}
+} // namespace dr1804
+
 namespace dr1812 { // dr1812: no
                    // NB: dup 1710
 #if __cplusplus >= 201103L

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 22eb7ac63c7edf..2bded63d5cd41c 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -2661,7 +2661,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://cplusplus.github.io/CWG/issues/437.html">437</a></td>
     <td>CD1</td>
     <td>Is type of class allowed in member function exception specification?</td>
-    <td class="full" align="center">Superseded by <a href="#1308">1308</a></td>
+    <td class="none" align="center">Superseded by <a href="#1308">1308</a></td>
   </tr>
   <tr id="438">
     <td><a href="https://cplusplus.github.io/CWG/issues/438.html">438</a></td>
@@ -10607,31 +10607,31 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://cplusplus.github.io/CWG/issues/1800.html">1800</a></td>
     <td>CD4</td>
     <td>Pointer to member of nested anonymous union</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Clang 2.9</td>
   </tr>
   <tr id="1801">
     <td><a href="https://cplusplus.github.io/CWG/issues/1801.html">1801</a></td>
     <td>CD4</td>
     <td>Kind of expression referring to member of anonymous union</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Clang 2.8</td>
   </tr>
   <tr id="1802">
     <td><a href="https://cplusplus.github.io/CWG/issues/1802.html">1802</a></td>
     <td>CD4</td>
     <td><TT>char16_t</TT> string literals and surrogate pairs</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Clang 3.1</td>
   </tr>
   <tr id="1803">
     <td><a href="https://cplusplus.github.io/CWG/issues/1803.html">1803</a></td>
     <td>CD5</td>
     <td><I>opaque-enum-declaration</I> as <I>member-declaration</I></td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Clang 2.9</td>
   </tr>
   <tr id="1804">
     <td><a href="https://cplusplus.github.io/CWG/issues/1804.html">1804</a></td>
     <td>CD4</td>
     <td>Partial specialization and friendship</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Clang 2.7</td>
   </tr>
   <tr id="1805">
     <td><a href="https://cplusplus.github.io/CWG/issues/1805.html">1805</a></td>


        


More information about the cfe-commits mailing list