Skip to content

[clang] Add tests for CWG1800-1804 #77509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 10, 2024
Merged

[clang] Add tests for CWG1800-1804 #77509

merged 2 commits into from
Jan 10, 2024

Conversation

Endilll
Copy link
Contributor

@Endilll Endilll commented Jan 9, 2024

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

Covers C++ core issues 1800, 1801, 1802, 1803, 1804.
@Endilll Endilll requested a review from cor3ntin January 9, 2024 18:51
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jan 9, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 9, 2024

@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/77509.diff

2 Files Affected:

  • (modified) clang/test/CXX/drs/dr18xx.cpp (+160-7)
  • (modified) clang/www/cxx_dr_status.html (+6-6)
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@-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@-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 Uncyclopedia 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>

@Endilll
Copy link
Contributor Author

Endilll commented Jan 9, 2024

This PR also reverts "full" status for CWG437 back to "unknown", which is a follow-up to #77372.
Nothing wrong with the tooling, just my mistake separating output of make_cxx_dr_status from changes I already had for complete-class context DRs.

#if __cplusplus >= 201103L
// Using a Uncyclopedia example of surrogate pair:
// https://en.wikipedia.org/wiki/UTF-16#Examples
constexpr char16_t a[3] = u"𐐷";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really just an array of char16_t - so 𐐷 would be parsed as 2 char16_t
What the wording is referring to is that any of the following should yield 2 elements

u"\N{DESERET SMALL LETTER YEE}"
u"\u{10437}"
u"\U00010437"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Updated the test to use \U00010437 as the first two forms you provided are too new for older language modes.

} // namespace dr1802

namespace dr1803 { // dr1803: 2.9
#if __cplusplus >= 201103L
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erichkeane I think it looks reasonable but I would like a second pair of eyes
https://cplusplus.github.io/CWG/issues/1804.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Test for 1804 is at line 56)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think the test for 1804 tests everything I can thing of.

Replace a character that has to be encoded as a surrogate pair with a universal character name.
Copy link
Contributor

@cor3ntin cor3ntin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Endilll Endilll merged commit d0918a2 into llvm:main Jan 10, 2024
@Endilll Endilll deleted the cwg1800-1804 branch January 10, 2024 08:51
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
Covers C++ core issues 1800, 1801, 1802, 1803, 1804.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ clang Clang issues not falling into any other category test-suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants