mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-18 21:10:29 +00:00
Don't crash if a macro expands to an erroneous expression. (#7652)
For certain kinds of error, clang's parser will succeed but produce an expression marked as "contains error". Clang's constant evaluator asserts if given one of those, so return early if we encounter one.
This commit is contained in:
1 parent
d21cc3197f
commit
047555bb1c
2 files changed
+59
-1
No files matched your search
@@ -84,7 +84,7 @@ auto TryEvaluateMacro(Context& context, SemIR::LocId loc_id,
|
||||
parser.ConsumeAnyToken(true);
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
if (!success || result_expr->containsErrors()) {
|
||||
CARBON_DIAGNOSTIC(
|
||||
InCppMacroEvaluation, Error,
|
||||
"failed to parse macro Cpp.{0} to a valid constant expression",
|
||||
|
||||
Reference in new issue
Block a user