Skip to content

Commit 9c561e8

Browse files
committed
[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: 8dbc6b2 . Created an issue for that: #62823 Reviewed By: #clang-language-wg, shafik Differential Revision: https://reviews.llvm.org/D151034
1 parent 898b880 commit 9c561e8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

clang/test/CXX/drs/dr13xx.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,23 @@ namespace dr1395 { // dr1395: 16
480480
#endif
481481
}
482482

483+
namespace dr1397 { // dr1397: 3.2
484+
#if __cplusplus >= 201103L
485+
struct A { // #dr1397-struct-A
486+
void *p = A{}; // #dr1397-void-p
487+
#if __cplusplus == 201103L
488+
// expected-error@#dr1397-struct-A {{default member initializer for 'p' needed within definition of enclosing class 'A' outside of member functions}}
489+
// expected-note@#dr1397-void-p {{in evaluation of exception specification for 'dr1397::A::A' needed here}}
490+
// expected-note@#dr1397-void-p {{default member initializer declared here}}
491+
#elif __cplusplus >= 201402L
492+
// expected-error@#dr1397-void-p {{default member initializer for 'p' needed within definition of enclosing class 'A' outside of member functions}}
493+
// expected-note@#dr1397-void-p {{default member initializer declared here}}
494+
#endif
495+
operator void*() const { return nullptr; }
496+
};
497+
#endif
498+
} // namespace dr1397
499+
483500
namespace dr1399 { // dr1399: dup 1388
484501
template<typename ...T> void f(T..., int, T...) {} // expected-note {{candidate}} expected-error 0-1{{C++11}}
485502
void g() {

clang/www/cxx_dr_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8189,7 +8189,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
81898189
<td><a href="https://cplusplus.github.io/CWG/issues/1397.html">1397</a></td>
81908190
<td>CD4</td>
81918191
<td>Class completeness in non-static data member initializers</td>
8192-
<td class="none" align="center">Unknown</td>
8192+
<td class="full" align="center">Clang 3.2</td>
81938193
</tr>
81948194
<tr id="1398">
81958195
<td><a href="https://cplusplus.github.io/CWG/issues/1398.html">1398</a></td>

0 commit comments

Comments
 (0)