IdentifierInfo &Comp, SourceLocation CmpLoc);
/// type checking declaration initializers (C99 6.7.8)
- bool CheckInitializer(Expr *simpleInit_or_initList, QualType &declType,
+ bool CheckInitializer(Expr *&simpleInit_or_initList, QualType &declType,
bool isStatic);
- bool CheckSingleInitializer(Expr *simpleInit, QualType declType);
- bool CheckInitExpr(Expr *expr, bool isStatic, QualType ElementType);
+ bool CheckSingleInitializer(Expr *&simpleInit, QualType declType);
+ bool CheckInitExpr(Expr *expr, InitListExpr *IList, unsigned slot,
+ bool isStatic, QualType ElementType);
void CheckVariableInitList(QualType DeclType, InitListExpr *IList,
QualType ElementType, bool isStatic,
int &nInitializers, bool &hadError);
return 0;
}
-bool Sema::CheckSingleInitializer(Expr *Init, QualType DeclType) {
+bool Sema::CheckSingleInitializer(Expr *&Init, QualType DeclType) {
AssignmentCheckResult result;
SourceLocation loc = Init->getLocStart();
// Get the type before calling CheckSingleAssignmentConstraints(), since
return false;
}
-bool Sema::CheckInitExpr(Expr *expr, bool isStatic, QualType ElementType) {
+bool Sema::CheckInitExpr(Expr *expr, InitListExpr *IList, unsigned slot,
+ bool isStatic, QualType ElementType) {
SourceLocation loc;
+ Expr *savExpr = expr; // Might be promoted by CheckSingleInitializer.
if (isStatic && !expr->isConstantExpr(Context, &loc)) { // C99 6.7.8p4.
Diag(loc, diag::err_init_element_not_constant, expr->getSourceRange());
} else if (CheckSingleInitializer(expr, ElementType)) {
return true; // types weren't compatible.
}
+ if (savExpr != expr) // The type was promoted, update initializer list.
+ IList->setInit(slot, expr);
return false;
}
maxElements, hadError);
}
} else {
- hadError = CheckInitExpr(expr, isStatic, ElementType);
+ hadError = CheckInitExpr(expr, IList, i, isStatic, ElementType);
}
nInitializers++;
}
CheckConstantInitList(DeclType, InitList, ElementType, isStatic,
totalInits, hadError);
} else {
- hadError = CheckInitExpr(expr, isStatic, ElementType);
+ hadError = CheckInitExpr(expr, IList, i, isStatic, ElementType);
nInitsAtLevel++; // increment the number of initializers at this level.
totalInits--; // decrement the total number of initializers.
return;
}
-bool Sema::CheckInitializer(Expr *Init, QualType &DeclType, bool isStatic) {
+bool Sema::CheckInitializer(Expr *&Init, QualType &DeclType, bool isStatic) {
InitListExpr *InitList = dyn_cast<InitListExpr>(Init);
if (!InitList)
return CheckSingleInitializer(Init, DeclType);