summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/array-init.c
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-09-02 20:30:18 +0000
committerSteve Naroff <snaroff@apple.com>2007-09-02 20:30:18 +0000
commitb03f5940d1f657cbd5faf28ab9e5c7ad743dba98 (patch)
tree126a2fbab51b85f66e2410a7e21543a668ae9d70 /clang/test/Sema/array-init.c
parentf33527a1aaca63f72bfb644a65c43fe2f27c48cf (diff)
downloadbcm5719-llvm-b03f5940d1f657cbd5faf28ab9e5c7ad743dba98.tar.gz
bcm5719-llvm-b03f5940d1f657cbd5faf28ab9e5c7ad743dba98.zip
More progress on array initializers.
- Added Expr::isConstantExpr(). - Added type checking for InitListExpr elements. - Added diagnostic for trying to initialize a variable sized object. llvm-svn: 41674
Diffstat (limited to 'clang/test/Sema/array-init.c')
-rw-r--r--clang/test/Sema/array-init.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/test/Sema/array-init.c b/clang/test/Sema/array-init.c
index 3ab2f4e5781..209b73463ad 100644
--- a/clang/test/Sema/array-init.c
+++ b/clang/test/Sema/array-init.c
@@ -7,12 +7,14 @@ int ary2[] = { x, y, z }; // expected-error{{initializer element is not constant
extern int fileScopeExtern[3] = { 1, 3, 5 }; // expected-warning{{'extern' variable has an initializer}}
+static int ary3[] = { 1, "abc", 3 }; // expected-warning{{incompatible types assigning 'char *' to 'int'}}
+
void func() {
int x = 1;
//int x2[] = { 1, 3, 5 };
- int x3[x] = { 1, 2 }; // gcc-error {{variable-sized object may not be initialized}}
+ int x3[x] = { 1, 2 }; // expected-error{{variable-sized object may not be initialized}}
int x4 = { 1, 2 }; // gcc-warning {{excess elements in array initializer}}
@@ -33,4 +35,6 @@ void func() {
struct threeElements *p = 7; // expected-warning{{incompatible types assigning 'int' to 'struct threeElements *'}}
extern int blockScopeExtern[3] = { 1, 3, 5 }; // expected-error{{'extern' variable cannot have an initializer}}
+
+ static int x2[3] = { 1.0, "abc" , 5.8 }; // expected-warning{{incompatible types assigning 'char *' to 'int'}}
}
OpenPOWER on IntegriCloud