return cast<ParenExpr>(this)->getSubExpr()->hasStaticStorage();
case ImplicitCastExprClass:
return cast<ImplicitCastExpr>(this)->getSubExpr()->hasStaticStorage();
+ case CompoundLiteralExprClass:
+ return cast<CompoundLiteralExpr>(this)->isFileScope();
case DeclRefExprClass: {
const Decl *D = cast<DeclRefExpr>(this)->getDecl();
if (const VarDecl *VD = dyn_cast<VarDecl>(D))
S.Emit(getType());
S.Emit(getLParenLoc());
S.EmitOwnedPtr(Init);
+ S.EmitBool(isFileScope());
}
CompoundLiteralExpr* CompoundLiteralExpr::CreateImpl(Deserializer& D) {
QualType Q = QualType::ReadVal(D);
SourceLocation L = SourceLocation::ReadVal(D);
Expr* Init = D.ReadOwnedPtr<Expr>();
- return new CompoundLiteralExpr(L, Q, Init);
+ bool fileScope = D.ReadBool();
+ return new CompoundLiteralExpr(L, Q, Init, fileScope);
}
void CompoundStmt::EmitImpl(Serializer& S) const {
InitListExpr *ILE = new InitListExpr(SourceLocation(),
&InitExprs[0], InitExprs.size(),
SourceLocation());
- CompoundLiteralExpr *StrRep = new CompoundLiteralExpr(CFConstantStrType, ILE);
+ CompoundLiteralExpr *StrRep = new CompoundLiteralExpr(CFConstantStrType, ILE, false);
// struct NSConstantString *
expType = Context->getPointerType(StrRep->getType());
Unop = new UnaryOperator(StrRep, UnaryOperator::AddrOf, expType,
&InitExprs[0], InitExprs.size(),
SourceLocation());
CompoundLiteralExpr *SuperRep = new CompoundLiteralExpr(SourceLocation(),
- superType, ILE);
+ superType, ILE, false);
// struct objc_super *
Expr *Unop = new UnaryOperator(SuperRep, UnaryOperator::AddrOf,
Context->getPointerType(SuperRep->getType()),
&InitExprs[0], InitExprs.size(),
SourceLocation());
CompoundLiteralExpr *SuperRep = new CompoundLiteralExpr(SourceLocation(),
- superType, ILE);
+ superType, ILE, false);
// struct objc_super *
Expr *Unop = new UnaryOperator(SuperRep, UnaryOperator::AddrOf,
Context->getPointerType(SuperRep->getType()),
// FIXME: add more semantic analysis (C99 6.5.2.5).
if (CheckInitializerTypes(literalExpr, literalType))
return true;
-
- if (!CurFunctionDecl && !CurMethodDecl) { // 6.5.2.5p3
+
+ bool isFileScope = !CurFunctionDecl && !CurMethodDecl;
+ if (isFileScope) { // 6.5.2.5p3
if (CheckForConstantInitializer(literalExpr, literalType))
return true;
}
- return new CompoundLiteralExpr(LParenLoc, literalType, literalExpr);
+ return new CompoundLiteralExpr(LParenLoc, literalType, literalExpr, isFileScope);
}
Action::ExprResult Sema::
// Otherwise, create a compound literal expression as the base, and
// iteratively process the offsetof designators.
- Expr *Res = new CompoundLiteralExpr(SourceLocation(), ArgTy, 0);
+ Expr *Res = new CompoundLiteralExpr(SourceLocation(), ArgTy, 0, false);
// offsetof with non-identifier designators (e.g. "offsetof(x, a.b[c])") are a
// GCC extension, diagnose them.
/// synthesized compound expression.
SourceLocation LParenLoc;
Expr *Init;
+ bool FileScope;
public:
- CompoundLiteralExpr(SourceLocation lparenloc, QualType ty, Expr *init) :
- Expr(CompoundLiteralExprClass, ty), LParenLoc(lparenloc), Init(init) {}
+ CompoundLiteralExpr(SourceLocation lparenloc, QualType ty, Expr *init, bool fileScope) :
+ Expr(CompoundLiteralExprClass, ty), LParenLoc(lparenloc), Init(init), FileScope(fileScope) {}
const Expr *getInitializer() const { return Init; }
Expr *getInitializer() { return Init; }
+
+ bool isFileScope() const { return FileScope; }
SourceLocation getLParenLoc() const { return LParenLoc; }
static int *p2 = (int []){2,x}; // -expected-error {{initializer element is not constant}}
static int *p3 = (int []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'char *', expected 'int'}}
+typedef struct Test {int a;int b;} Test;
+static Test* ll = &(Test) {0,0};
+
extern void fooFunc(struct foo *pfoo);
int main(int argc, char **argv) {