summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/array-init.c
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-09 00:35:39 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-09 00:35:39 +0000
commitc68e140657e40cda2f027beff923276b36e33684 (patch)
tree1a32c9fcccd9102ab6ca64a098c771ec4ebea5a6 /clang/test/Sema/array-init.c
parent48b1804e7957ce379441e477602ac860a606e469 (diff)
downloadbcm5719-llvm-c68e140657e40cda2f027beff923276b36e33684.tar.gz
bcm5719-llvm-c68e140657e40cda2f027beff923276b36e33684.zip
Improve diagnostics when we fail to convert from a source type to a
destination type for initialization, assignment, parameter-passing, etc. The main issue fixed here is that we used rather confusing wording for diagnostics such as t.c:2:9: warning: initializing 'char const [2]' discards qualifiers, expected 'char *' [-pedantic] char *name = __func__; ^ ~~~~~~~~ We're not initializing a 'char const [2]', we're initializing a 'char *' with an expression of type 'char const [2]'. Similar problems existed for other diagnostics in this area, so I've normalized them all with more precise descriptive text to say what we're initializing/converting/assigning/etc. from and to. The warning for the code above is now: t.c:2:9: warning: initializing 'char *' from an expression of type 'char const [2]' discards qualifiers [-pedantic] char *name = __func__; ^ ~~~~~~~~ Fixes <rdar://problem/7447179>. llvm-svn: 100832
Diffstat (limited to 'clang/test/Sema/array-init.c')
-rw-r--r--clang/test/Sema/array-init.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/clang/test/Sema/array-init.c b/clang/test/Sema/array-init.c
index 45d31838529..ac45ff77c8e 100644
--- a/clang/test/Sema/array-init.c
+++ b/clang/test/Sema/array-init.c
@@ -9,7 +9,7 @@ int ary2[] = { x, y, z }; // expected-error{{initializer element is not a compil
extern int fileScopeExtern[3] = { 1, 3, 5 }; // expected-warning{{'extern' variable has an initializer}}
-static long ary3[] = { 1, "abc", 3, 4 }; // expected-warning{{incompatible pointer to integer conversion initializing 'char [4]', expected 'long'}}
+static long ary3[] = { 1, "abc", 3, 4 }; // expected-warning{{incompatible pointer to integer conversion initializing 'long' from an expression of type 'char [4]'}}
void func() {
int x = 1;
@@ -44,11 +44,11 @@ void func() {
int a,b,c;
} z = { 1 };
- struct threeElements *p = 7; // expected-warning{{incompatible integer to pointer conversion initializing 'int', expected 'struct threeElements *'}}
+ struct threeElements *p = 7; // expected-warning{{incompatible integer to pointer conversion initializing 'struct threeElements *' from an expression of type 'int'}}
extern int blockScopeExtern[3] = { 1, 3, 5 }; // expected-error{{'extern' variable cannot have an initializer}}
- static long x2[3] = { 1.0, "abc" , 5.8 }; // expected-warning{{incompatible pointer to integer conversion initializing 'char [4]', expected 'long'}}
+ static long x2[3] = { 1.0, "abc" , 5.8 }; // expected-warning{{incompatible pointer to integer conversion initializing 'long' from an expression of type 'char [4]'}}
}
void test() {
@@ -155,10 +155,10 @@ void charArrays() {
char c[] = { "Hello" };
int l[sizeof(c) == 6 ? 1 : -1];
- int i[] = { "Hello "}; // expected-warning{{incompatible pointer to integer conversion initializing 'char [7]', expected 'int'}}
+ int i[] = { "Hello "}; // expected-warning{{incompatible pointer to integer conversion initializing 'int' from an expression of type 'char [7]'}}
char c2[] = { "Hello", "Good bye" }; //expected-warning{{excess elements in char array initializer}}
- int i2[1] = { "Hello" }; //expected-warning{{incompatible pointer to integer conversion initializing 'char [6]', expected 'int'}}
+ int i2[1] = { "Hello" }; //expected-warning{{incompatible pointer to integer conversion initializing 'int' from an expression of type 'char [6]'}}
char c3[5] = { "Hello" };
char c4[4] = { "Hello" }; //expected-warning{{initializer-string for char array is too long}}
@@ -191,12 +191,12 @@ void autoStructTest() {
struct s1 {char a; char b;} t1;
struct s2 {struct s1 c;} t2 = { t1 };
// The following is a less than great diagnostic (though it's on par with EDG).
-struct s1 t3[] = {t1, t1, "abc", 0}; //expected-warning{{incompatible pointer to integer conversion initializing 'char [4]', expected 'char'}}
+struct s1 t3[] = {t1, t1, "abc", 0}; //expected-warning{{incompatible pointer to integer conversion initializing 'char' from an expression of type 'char [4]'}}
int t4[sizeof t3 == 6 ? 1 : -1];
}
struct foo { int z; } w;
int bar (void) {
- struct foo z = { w }; //expected-error{{incompatible type initializing 'struct foo', expected 'int'}}
+ struct foo z = { w }; //expected-error{{initializing 'int' from an expression of incompatible type 'struct foo'}}
return z.z;
}
struct s3 {void (*a)(void);} t5 = {autoStructTest};
OpenPOWER on IntegriCloud