-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] Fix a crash issue that caused by handling of fields with initializers in nested anonymous unions #113049
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 3 commits
804b103
de4a9d5
882fd4e
cf5a038
ac30f8a
c0be803
5be9331
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 |
---|---|---|
|
@@ -115,3 +115,14 @@ namespace nested_union { | |
// of Test3, or we should exclude f(Test3) as a candidate. | ||
static_assert(f({1}) == 2, ""); // expected-error {{call to 'f' is ambiguous}} | ||
} | ||
|
||
// Fix crash issue https://github.com/llvm/llvm-project/issues/112560. | ||
// Make sure clang compiles the following code without crashing: | ||
namespace GH112560 { | ||
union U { | ||
int f = ; // expected-error {{expected expression}} | ||
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. As far as I can tell, the reason the code in SemaInit is getting confused is that the union is marked "hasInClassInitializer" because of the initializer... but then there isn't actually an initializer anywhere because we failed to parse it. I think hasInClassInitializer() on RecordDecl needs to be consistent with hasInClassInitializer() on FieldDecl. If hasInClassInitializer is true, there should be an initializer somewhere. Either we should pretend the user didn't write the "=", or we should construct a RecoveryExpr to represent the missing initializer. Adding extra handling to every bit of code that checks hasInClassInitializer spreads out error handling to places it shouldn't exist. 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. Thanks for the review! Make sense, there should have a RecoveryExpr as the initializer. I'd like to give a try.
yronglin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
void foo() { | ||
U g{}; | ||
} | ||
} // namespace GH112560 |
Uh oh!
There was an error while loading. Please reload this page.