-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] Add tests for CWG issues regarding completeness of types #92113
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
Changes from all commits
1ae4b4e
96e5f31
f356676
f99395f
1cc043f
0fda391
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,23 @@ struct A { | |
}; | ||
} | ||
|
||
namespace cwg1458 { // cwg1458: 3.1 | ||
#if __cplusplus >= 201103L | ||
struct A; | ||
|
||
void f() { | ||
constexpr A* a = nullptr; | ||
constexpr int p = &*a; | ||
// expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}} | ||
constexpr A *p2 = &*a; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the DR says it is "unspecified" so are we documenting here that this will always be the behavior? Maybe worth a comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are documenting that our constant evaluator doesn't consider this UB. |
||
} | ||
|
||
struct A { | ||
int operator&(); | ||
}; | ||
#endif | ||
} // namespace cwg1458 | ||
|
||
namespace cwg1460 { // cwg1460: 3.5 | ||
#if __cplusplus >= 201103L | ||
namespace DRExample { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// RUN: split-file --leading-lines %s %t | ||
// RUN: %clang_cc1 -std=c++20 -verify -emit-module-interface %t/module.cppm -o %t/module.pcm | ||
// RUN: %clang_cc1 -std=c++20 -verify -fmodule-file=A=%t/module.pcm %t/main.cpp | ||
// RUN: %clang_cc1 -std=c++23 -verify -emit-module-interface %t/module.cppm -o %t/module.pcm | ||
// RUN: %clang_cc1 -std=c++23 -verify -fmodule-file=A=%t/module.pcm %t/main.cpp | ||
// RUN: %clang_cc1 -std=c++2c -verify -emit-module-interface %t/module.cppm -o %t/module.pcm | ||
// RUN: %clang_cc1 -std=c++2c -verify -fmodule-file=A=%t/module.pcm %t/main.cpp | ||
|
||
//--- module.cppm | ||
// expected-no-diagnostics | ||
export module A; | ||
|
||
namespace cwg2630 { | ||
export class X {}; | ||
} // namespace cwg2630 | ||
|
||
//--- main.cpp | ||
// expected-no-diagnostics | ||
import A; | ||
|
||
namespace cwg2630 { // cwg2630: 9 | ||
X x; | ||
} // namespace cwg2630 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be worth it to see that this fails for a
static member
since the DR specifically saysnon-static
so we should cover both.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also mentions in the body of member function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not going to fail for static member initializers because of (I suspect) subsequent changes that were made to the wording: http://eel.is/c++draft/class.mem.general#8.5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that is worth adding. I'll prepare a PR.