diff options
author | Anders Carlsson <andersca@mac.com> | 2010-02-03 21:58:41 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-02-03 21:58:41 +0000 |
commit | b0695ef01191237910425c7b880075f3ed02fcea (patch) | |
tree | bb40ba4544ff27d2a52f71c943039d4c34552fe0 /clang/lib/AST/ExprConstant.cpp | |
parent | 223084d3ac553a856fea488211048124b45e7df2 (diff) | |
download | bcm5719-llvm-b0695ef01191237910425c7b880075f3ed02fcea.tar.gz bcm5719-llvm-b0695ef01191237910425c7b880075f3ed02fcea.zip |
Don't try to fold DeclRefExprs that point to ParmVarDecls. This had the side-effect of always folding the expression to the default argument of the parameter. For example:
void f(int a = 10) {
return a;
}
would always return 10, regardless of the passed in argument.
This fixes another 600 test failures. We're now down to only 137 failures!
llvm-svn: 95262
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index a0b2aa993fa..382bfe59b5b 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -878,6 +878,10 @@ bool IntExprEvaluator::CheckReferencedDecl(const Expr* E, const Decl* D) { // In C, they can also be folded, although they are not ICEs. if (Info.Ctx.getCanonicalType(E->getType()).getCVRQualifiers() == Qualifiers::Const) { + + if (isa<ParmVarDecl>(D)) + return Error(E->getLocStart(), diag::note_invalid_subexpr_in_ice, E); + if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { if (const Expr *Init = VD->getAnyInitializer()) { if (APValue *V = VD->getEvaluatedValue()) { |