[cfe-commits] r65107 - /cfe/trunk/lib/AST/Expr.cpp
Eli Friedman
eli.friedman at gmail.com
Thu Feb 19 18:36:22 PST 2009
Author: efriedma
Date: Thu Feb 19 20:36:22 2009
New Revision: 65107
URL: http://llvm.org/viewvc/llvm-project?rev=65107&view=rev
Log:
A few small tweaks to isConstantInitializer. (No test because this
isn't getting used by Sema or CodeGen at the moment...)
Modified:
cfe/trunk/lib/AST/Expr.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=65107&r1=65106&r2=65107&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Feb 19 20:36:22 2009
@@ -794,15 +794,24 @@
// expressions, and it can't deal with aggregates; we deal with those here,
// and fall back to isEvaluatable for the other cases.
+ // FIXME: This function assumes the variable being assigned to
+ // isn't a reference type!
+
switch (getStmtClass()) {
default: break;
case StringLiteralClass:
return true;
case CompoundLiteralExprClass: {
+ // This handles gcc's extension that allows global initializers like
+ // "struct x {int x;} x = (struct x) {};".
+ // FIXME: This accepts other cases it shouldn't!
const Expr *Exp = cast<CompoundLiteralExpr>(this)->getInitializer();
return Exp->isConstantInitializer(Ctx);
}
case InitListExprClass: {
+ // FIXME: This doesn't deal with fields with reference types correctly.
+ // FIXME: This incorrectly allows pointers cast to integers to be assigned
+ // to bitfields.
const InitListExpr *Exp = cast<InitListExpr>(this);
unsigned numInits = Exp->getNumInits();
for (unsigned i = 0; i < numInits; i++) {
@@ -829,9 +838,6 @@
if (getType()->isRecordType())
return cast<CastExpr>(this)->getSubExpr()->isConstantInitializer(Ctx);
break;
- case DesignatedInitExprClass:
- return cast<DesignatedInitExpr>(this)->
- getInit()->isConstantInitializer(Ctx);
}
return isEvaluatable(Ctx);
More information about the cfe-commits
mailing list