Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -679,12 +679,18 @@ } template bool ByteCodeExprGen::discard(const Expr *E) { + if (E->containsErrors()) + return false; + OptionScope Scope(this, /*NewDiscardResult=*/true); return this->Visit(E); } template bool ByteCodeExprGen::visit(const Expr *E) { + if (E->containsErrors()) + return false; + OptionScope Scope(this, /*NewDiscardResult=*/false); return this->Visit(E); } @@ -1255,8 +1261,10 @@ /// We need to evaluate the initializer and return its value. template bool ByteCodeExprGen::visitDecl(const VarDecl *VD) { - Optional VarT = classify(VD->getType()); + if (VD->isInvalidDecl()) + return false; + Optional VarT = classify(VD->getType()); // Create and initialize the variable. if (!this->visitVarDecl(VD)) return false;