-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang] Reject constexpr-unknown values as constant expressions more consistently #129952
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 1 commit
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // RUN: %clang_cc1 -std=c++23 -verify %s | ||
| // RUN: %clang_cc1 -std=c++23 -verify=expected,nointerpreter %s | ||
| // RUN: %clang_cc1 -std=c++23 -verify %s -fexperimental-new-constant-interpreter | ||
|
|
||
| using size_t = decltype(sizeof(0)); | ||
|
|
@@ -154,3 +154,26 @@ int g() { | |
| static_assert(f(arr) == 5); | ||
| } | ||
| } | ||
|
|
||
| namespace GH128409 { | ||
| int &ff(); | ||
| int &x = ff(); // nointerpreter-note {{declared here}} | ||
| constinit int &z = x; // expected-error {{variable does not have a constant initializer}} | ||
| // expected-note@-1 {{required by 'constinit' specifier here}} | ||
| // nointerpreter-note@-2 {{initializer of 'x' is not a constant expression}} | ||
|
||
| } | ||
|
|
||
| namespace GH129845 { | ||
| int &ff(); | ||
| int &x = ff(); // nointerpreter-note {{declared here}} | ||
| struct A { int& x; }; | ||
| constexpr A g = {x}; // expected-error {{constexpr variable 'g' must be initialized by a constant expression}} | ||
| // nointerpreter-note@-1 {{initializer of 'x' is not a constant expression}} | ||
| const A* gg = &g; | ||
| } | ||
|
|
||
| namespace extern_reference_used_as_unknown { | ||
| extern int &x; | ||
| int y; | ||
| constinit int& g = (x,y); // expected-warning {{left operand of comma operator has no effect}} | ||
| } | ||
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.
If you end the comments in
\, you don't need to add the@-2stuff.