[PATCH] D151034: [clang] Add test for CWG1397

Vlad Serebrennikov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat May 20 11:13:44 PDT 2023


Endill created this revision.
Endill added reviewers: clang-language-wg, shafik.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151034

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


Index: clang/www/cxx_dr_status.html
===================================================================
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -8189,7 +8189,7 @@
     <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>
Index: clang/test/CXX/drs/dr13xx.cpp
===================================================================
--- clang/test/CXX/drs/dr13xx.cpp
+++ clang/test/CXX/drs/dr13xx.cpp
@@ -480,6 +480,23 @@
 #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() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151034.524046.patch
Type: text/x-patch
Size: 1810 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230520/c0ecbc5d/attachment.bin>


More information about the cfe-commits mailing list