-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[Clang] Handle ?: operator in fold expression #164019
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -12,3 +12,8 @@ template <typename... U> struct A { | |
| foo<T>((... + static_cast<U>(1))); // expected-error {{expression contains unexpanded parameter pack 'T'}} | ||
| } | ||
| }; | ||
|
|
||
| template <typename ... T> | ||
| void foo(T... Params) { | ||
| (Params ?: 1, ...); // expected-error {{expression not permitted as operand of fold expression}} | ||
|
Collaborator
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. This feels like it is in desperate need of notes or better source locations.
Contributor
Author
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. Sorry for the late response, I've been busy with college and such. Do you mean the test itself? Or the diagnostic? g++ diagnostic shows the caret on the conditional operator, should we do something similar here? |
||
| } | ||
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.
You can't really do this I think?
RecoveryExprisn't always generated/always valid.It seems to me that we shouldn't have created the
RecoveryExprhere (or done the return ExprError) unless we had diagnosedThere 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.
IIUC the frontend produces a RecoveryExpr on semantic errors that prevent forming well formed statements. In that case should it be always generated in case of semantic errors? Can you point an example where it is not always generated.
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.
RecoveryExprs are only created if they’re enabled by some flag (-frecovery-astiirc), otherwise, you just getExprError():llvm-project/clang/lib/Sema/SemaExpr.cpp
Lines 21591 to 21594 in f42e58f