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

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 9 12:32:24 PST 2024


https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/77509

>From d3cb62eba8e2109e44083bd8b9e89a453acad754 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Tue, 9 Jan 2024 21:51:00 +0300
Subject: [PATCH 1/2] [clang] Add tests for CWG1800-1804

Covers C++ core issues 1800, 1801, 1802, 1803, 1804.
---
 clang/test/CXX/drs/dr18xx.cpp | 167 ++++++++++++++++++++++++++++++++--
 clang/www/cxx_dr_status.html  |  12 +--
 2 files changed, 166 insertions(+), 13 deletions(-)

diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index fbe67bd0c2f6db..90539e0a47e708 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"𐐷";
+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>

>From 3ef6a36ea56bfe85adfe5e36d4f6a2f75305fc68 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Tue, 9 Jan 2024 23:32:09 +0300
Subject: [PATCH 2/2] Update CWG1802 test

Replace a character that has to be encoded as a surrogate pair with a universal character name.
---
 clang/test/CXX/drs/dr18xx.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index 90539e0a47e708..1d76804907a5c1 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -32,7 +32,7 @@ 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"𐐷";
+constexpr char16_t a[3] = u"\U00010437";
 static_assert(a[0] == 0xD801, "");
 static_assert(a[1] == 0xDC37, "");
 static_assert(a[2] == 0x0, "");



More information about the cfe-commits mailing list