Skip to content

Commit

Permalink
[clang] Add test for CWG1397
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Endilll committed May 30, 2023
1 parent 898b880 commit 9c561e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions clang/test/CXX/drs/dr13xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion clang/www/cxx_dr_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 9c561e8

Please sign in to comment.