[clang] 9c561e8 - [clang] Add test for CWG1397

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Tue May 30 02:09:09 PDT 2023


Author: Vlad Serebrennikov
Date: 2023-05-30T12:09:02+03:00
New Revision: 9c561e8f3c2e8292bce9d7b36657144ba26a1c91

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

LOG: [clang] Add test for CWG1397

Resolution of this CWG breaks potential dependency loop between complete-class context of non-static data member initializer (NSDMI), and defaulted default constructor, which is `noexcept` depending on NSDMIs among other things.

For whatever reason in C++11 mode we issue an additional note and a different line number for the primary error. But I find the message itself even worse than aforementioned issues. It describes what's going on, but doesn't say what's bad about it. I find the previous version of this message more clear: https://github.com/llvm/llvm-project/commit/8dbc6b26171167b8ddf66a5f4b6d6fb9baf28336 . Created an issue for that: #62823

Reviewed By: #clang-language-wg, shafik

Differential Revision: https://reviews.llvm.org/D151034

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp
index 65eb8a293276f..feaf523c44fc2 100644
--- a/clang/test/CXX/drs/dr13xx.cpp
+++ b/clang/test/CXX/drs/dr13xx.cpp
@@ -480,6 +480,23 @@ namespace dr1395 { // dr1395: 16
 #endif
 }
 
+namespace dr1397 { // dr1397: 3.2
+#if __cplusplus >= 201103L
+struct A {       // #dr1397-struct-A
+  void *p = A{}; // #dr1397-void-p
+#if __cplusplus == 201103L
+  // expected-error@#dr1397-struct-A {{default member initializer for 'p' needed within definition of enclosing class 'A' outside of member functions}}
+  // expected-note@#dr1397-void-p {{in evaluation of exception specification for 'dr1397::A::A' needed here}}
+  // expected-note@#dr1397-void-p {{default member initializer declared here}}
+#elif __cplusplus >= 201402L
+  // expected-error@#dr1397-void-p {{default member initializer for 'p' needed within definition of enclosing class 'A' outside of member functions}}
+  // expected-note@#dr1397-void-p {{default member initializer declared here}}
+#endif
+  operator void*() const { return nullptr; }
+};
+#endif
+} // namespace dr1397
+
 namespace dr1399 { // dr1399: dup 1388
   template<typename ...T> void f(T..., int, T...) {} // expected-note {{candidate}} expected-error 0-1{{C++11}}
   void g() {

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 59a0b0c05295c..ec2ac24450832 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -8189,7 +8189,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://cplusplus.github.io/CWG/issues/1397.html">1397</a></td>
     <td>CD4</td>
     <td>Class completeness in non-static data member initializers</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Clang 3.2</td>
   </tr>
   <tr id="1398">
     <td><a href="https://cplusplus.github.io/CWG/issues/1398.html">1398</a></td>


        


More information about the cfe-commits mailing list