Skip to content
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

[clang] Add test for CWG1350 #78040

Merged
merged 2 commits into from
Jan 13, 2024
Merged

Conversation

Endilll
Copy link
Contributor

@Endilll Endilll commented Jan 13, 2024

Test is based on P0136R1 wording instead of proposed resolution in the issue itself.

This patch also expands related CWG1573 test with an additional test case. Existing 3.9 status of 1573 is still relevant even with this new test case.

Test is based on [P0136R1](https://wg21.link/p0136r1) wording instead of proposed resolution in the issue itself.

This patch also expands related CWG1573 test with an additional test case. Existing `3.9` status of 1573 is still relevant even with this new test case.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jan 13, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 13, 2024

@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)

Changes

Test is based on P0136R1 wording instead of proposed resolution in the issue itself.

This patch also expands related CWG1573 test with an additional test case. Existing 3.9 status of 1573 is still relevant even with this new test case.


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

3 Files Affected:

  • (modified) clang/test/CXX/drs/dr13xx.cpp (+42)
  • (modified) clang/test/CXX/drs/dr15xx.cpp (+7)
  • (modified) clang/www/cxx_dr_status.html (+1-1)
diff --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp
index 359c04b3e0f3d4..6a4a1f52383c04 100644
--- a/clang/test/CXX/drs/dr13xx.cpp
+++ b/clang/test/CXX/drs/dr13xx.cpp
@@ -379,6 +379,48 @@ namespace dr1347 { // dr1347: 3.1
 #endif
 }
 
+namespace dr1350 { // dr1350: 3.5
+#if __cplusplus >= 201103L
+struct NoexceptCtor {
+  NoexceptCtor(int) noexcept {}
+};
+
+struct ThrowingNSDMI : NoexceptCtor {
+  int a = []() noexcept(false) { return 0; }();
+  using NoexceptCtor::NoexceptCtor;
+};
+
+static_assert(!__is_nothrow_constructible(ThrowingNSDMI, int), "");
+
+struct ThrowingCtor {
+  ThrowingCtor() noexcept(false) {}
+};
+
+struct ThrowingNSDM : NoexceptCtor {
+  ThrowingCtor c;
+  using NoexceptCtor::NoexceptCtor;
+};
+
+static_assert(!__is_nothrow_constructible(ThrowingNSDM, int), "");
+
+struct D : NoexceptCtor, ThrowingCtor {
+  using NoexceptCtor::NoexceptCtor;
+};
+
+static_assert(!__is_nothrow_constructible(D, int), "");
+
+struct ThrowingDefaultArg {
+  ThrowingDefaultArg(ThrowingCtor = {}) {}
+};
+
+struct D2 : NoexceptCtor, ThrowingDefaultArg {
+  using NoexceptCtor::NoexceptCtor;
+};
+
+static_assert(!__is_nothrow_constructible(D2, int), "");
+#endif
+} // namespace dr1350
+
 namespace dr1358 { // dr1358: 3.1
 #if __cplusplus >= 201103L
   struct Lit { constexpr operator int() const { return 0; } };
diff --git a/clang/test/CXX/drs/dr15xx.cpp b/clang/test/CXX/drs/dr15xx.cpp
index 007b42c74affb1..3d4050a5713f92 100644
--- a/clang/test/CXX/drs/dr15xx.cpp
+++ b/clang/test/CXX/drs/dr15xx.cpp
@@ -390,6 +390,13 @@ namespace dr1573 { // dr1573: 3.9
   H h(0);
   // since-cxx11-error@-1 {{constructor inherited by 'H' from base class 'G' is implicitly deleted}}
   //   since-cxx11-note@#dr1573-H {{constructor inherited by 'H' is implicitly deleted because field 'g' has no default constructor}}
+
+  // deleted definition of constructor is inherited
+  struct I { I(int) = delete; }; // #dr1573-I
+  struct J : I { using I::I; };
+  J j(0);
+  // since-cxx11-error@-1 {{call to deleted constructor of 'J'}}
+  //   since-cxx11-note@#dr1573-I {{'I' has been explicitly marked deleted here}}
 #endif
 }
 
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 4a3ed19161f9a5..5acc72dcf54b2d 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -7908,7 +7908,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://cplusplus.github.io/CWG/issues/1350.html">1350</a></td>
     <td>CD3</td>
     <td>Incorrect exception specification for inherited constructors</td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="full" align="center">Clang 3.5</td>
   </tr>
   <tr id="1351">
     <td><a href="https://cplusplus.github.io/CWG/issues/1351.html">1351</a></td>

@Endilll
Copy link
Contributor Author

Endilll commented Jan 13, 2024

I was way too deep into P0136R1 Rewording inheriting constructors (core issue 1941 et al) when I realized Richard has written tests for all issues covered there long ago. So I decided to carry on and check whether those tests would benefit from additional test cases. That's how I came up with a new test case for CWG1573, and came about its related issue 1350, which was lacking a test.

@cor3ntin
Copy link
Contributor

For completeness, can you add a couple of tests covering the note (ie, template case?)
Otherwise, LGTM

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 d8cd554 into llvm:main Jan 13, 2024
4 checks passed
@Endilll Endilll deleted the inherited-ctor-cwg-issues branch January 13, 2024 22:19
Copy link
Collaborator

@shafik shafik left a comment

Choose a reason for hiding this comment

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

LGTM

justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
Test is based on [P0136R1](https://wg21.link/p0136r1) wording instead of proposed resolution in the issue itself.

This patch also expands related CWG1573 test with an additional test case. Existing `3.9` status of 1573 is still relevant even with this new test case.
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.

None yet

4 participants