mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 15:11:07 +01: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:
@@ -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