Expr *literalExpr = static_cast<Expr*>(InitExpr);
// FIXME: add more semantic analysis (C99 6.5.2.5).
- if (CheckInitializer(literalExpr, literalType, false))
- return 0;
+ bool requireConstantExprs = !CurFunctionDecl && !CurMethodDecl;
+ if (CheckInitializer(literalExpr, literalType, requireConstantExprs))
+ return true;
return new CompoundLiteralExpr(LParenLoc, literalType, literalExpr);
}
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify -pedantic %s
struct foo { int a, b; };
static int *p = (int []){2,4};
static int x = (int){1}; // -expected-error {{initializer element is not constant}} -expected-warning{{braces around scalar initializer}}
+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'}}
+
extern void fooFunc(struct foo *pfoo);
int main(int argc, char **argv) {
+ int *l = (int []){x, *p, *p2};
fooFunc(&(struct foo){ 1, 2 });
}