IdentifierInfo &Comp, SourceLocation CmpLoc);
/// type checking declaration initializers (C99 6.7.8)
+
+ /// FIXME: The VarDecl parameter should not have a default value,
+ /// and all call sites should be audited.
bool CheckInitializerTypes(Expr *&simpleInit_or_initList, QualType &declType,
SourceLocation InitLoc,DeclarationName InitEntity,
- bool DirectInit);
+ bool DirectInit, VarDecl *VD = 0);
bool CheckInitList(InitListExpr *&InitList, QualType &DeclType);
bool CheckForConstantInitializer(Expr *e, QualType t);
VDecl->setInvalidDecl();
} else if (!VDecl->isInvalidDecl()) {
if (CheckInitializerTypes(Init, DclT, VDecl->getLocation(),
- VDecl->getDeclName(), DirectInit))
+ VDecl->getDeclName(), DirectInit, VDecl))
VDecl->setInvalidDecl();
// C++ 3.6.2p2, allow dynamic initialization of static initializers.
#include "Sema.h"
#include "clang/Parse/Designator.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include <map>
using namespace clang;
bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
SourceLocation InitLoc,
DeclarationName InitEntity,
- bool DirectInit) {
+ bool DirectInit, VarDecl *VD) {
if (DeclType->isDependentType() ||
Init->isTypeDependent() || Init->isValueDependent())
return false;
InitLoc, Init->getSourceRange(),
InitEntity,
DirectInit? IK_Direct : IK_Copy);
- return Constructor == 0;
+ if (!Constructor)
+ return true;
+
+ // FIXME: What do do if VD is null here?
+ assert(VD && "Must have a var decl to construct into!");
+ Init = CXXConstructExpr::Create(Context, VD, DeclType, Constructor,
+ false, &Init, 1);
+ return false;
}
// -- Otherwise (i.e., for the remaining copy-initialization