[cfe-commits] r64086 - /cfe/trunk/lib/AST/ExprConstant.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Sun Feb 8 07:51:19 PST 2009
Author: cornedbee
Date: Sun Feb 8 09:51:17 2009
New Revision: 64086
URL: http://llvm.org/viewvc/llvm-project?rev=64086&view=rev
Log:
Teach the constant evaluator about C++ const integral variables.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=64086&r1=64085&r2=64086&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Feb 8 09:51:17 2009
@@ -574,7 +574,16 @@
Result.setIsUnsigned(!E->getType()->isSignedIntegerType());
return true;
}
-
+
+ // In C++, const, non-volatile integers initialized with ICEs are ICEs.
+ if (Info.Ctx.getLangOptions().CPlusPlus &&
+ E->getType().getCVRQualifiers() == QualType::Const) {
+ if (const VarDecl *D = dyn_cast<VarDecl>(E->getDecl())) {
+ if (const Expr *Init = D->getInit())
+ return Visit(const_cast<Expr*>(Init));
+ }
+ }
+
// Otherwise, random variable references are not constants.
return Error(E->getLocStart(), diag::note_invalid_subexpr_in_ice, E);
}
More information about the cfe-commits
mailing list