aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/array-init.c
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-09-02 02:04:30 +0000
committerSteve Naroff <snaroff@apple.com>2007-09-02 02:04:30 +0000
commitf009063ab7e05be7781751ff9e4b42630f07a747 (patch)
tree2b44c125aa6743d63b2a1d90ae7a9fedca8ac190 /test/Sema/array-init.c
parent9dcbfa450d751bd68fc4af8b75da381d4f6984b9 (diff)
Start implementing semantic analysis for C initializers.
Step 1: Start instantiating InitListExpr's. Step 2: Call newly added function Sema::CheckInitializer() from Sema::ParseDeclarator(). Step 3: Give InitListExpr's a preliminary type. Step 4: Start emitting diagnostics for simple assignments. Note: As a result of step 1, the CodeGen/mandel.c test asserts "Unimplemented agg expr!", which is expected. As a result of step 4, the test below now fails. This isn't expected and needs to be investigated (it appears type checking for C++ references is flawed in some way). ******************** TEST 'Sema/cxx-references.cpp' FAILED! ******************** Command: clang -fsyntax-only Sema/cxx-references.cpp Output: Sema/cxx-references.cpp:8:12: warning: incompatible pointer types assigning 'int &*' to 'int *' int *p = &r; ^~ Sema/cxx-references.cpp:10:20: error: incompatible types assigning 'int (int)' to 'int (&)(int)' int (&rg)(int) = g; ^ Sema/cxx-references.cpp:13:18: error: incompatible types assigning 'int [3]' to 'int (&)[3]' int (&ra)[3] = a; ^ Sema/cxx-references.cpp:16:14: error: incompatible types assigning 'int *' to 'int *&' int *& P = Q; ^ 4 diagnostics generated. ******************** TEST 'Sema/cxx-references.cpp' FAILED! ******************** git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41671 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/array-init.c')
-rw-r--r--test/Sema/array-init.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c
new file mode 100644
index 0000000000..2a26103a31
--- /dev/null
+++ b/test/Sema/array-init.c
@@ -0,0 +1,27 @@
+// RUN: clang -parse-ast-check -pedantic %s
+
+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 x4 = { 1, 2 }; // gcc-warning {{excess elements in array initializer}}
+
+ int y[4][3] = {
+ { 1, 3, 5 },
+ { 2, 4, 6 },
+ { 3, 5, 7 },
+ };
+
+ int y2[4][3] = {
+ 1, 3, 5, 2, 4, 6, 3, 5, 7
+ };
+
+ struct threeElements {
+ int a,b,c;
+ } z = { 1 };
+
+ struct threeElements *p = 7; // expected-warning{{incompatible types assigning 'int' to 'struct threeElements *'}}
+}