summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-11 00:02:17 +0000
committerChris Lattner <sabre@nondot.org>2008-02-11 00:02:17 +0000
commit36fc8790b7ae08f00b4e8958f2b8371c37031e14 (patch)
tree07e23087add768079da175674cf75137c99f8b7b /clang/test
parentde4496bb9ef95ef12d7a72582df95cf64772800a (diff)
downloadbcm5719-llvm-36fc8790b7ae08f00b4e8958f2b8371c37031e14.tar.gz
bcm5719-llvm-36fc8790b7ae08f00b4e8958f2b8371c37031e14.zip
Fix PR1992 by computing the right type for string literals, which
is an array type not a pointer type. This requires updating some diags that change and updating the code generator to handle the proper form of strings. llvm-svn: 46941
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Sema/argument-checking.m2
-rw-r--r--clang/test/Sema/array-init.c10
-rw-r--r--clang/test/Sema/compound-literal.c2
-rw-r--r--clang/test/Sema/i-c-e2.c12
4 files changed, 18 insertions, 8 deletions
diff --git a/clang/test/Sema/argument-checking.m b/clang/test/Sema/argument-checking.m
index 45eba87804a..820a2f09c79 100644
--- a/clang/test/Sema/argument-checking.m
+++ b/clang/test/Sema/argument-checking.m
@@ -17,7 +17,7 @@ void test() {
struct S sInst;
charStarFunc(1); // expected-warning {{incompatible integer to pointer conversion passing 'int', expected 'char *'}}
- charFunc("abc"); // expected-warning {{incompatible pointer to integer conversion passing 'char *', expected 'char'}}
+ charFunc("abc"); // expected-warning {{incompatible pointer to integer conversion passing 'char [4]', expected 'char'}}
[obj charStarMeth:1]; // expected-warning {{incompatible integer to pointer conversion sending 'int'}}
[obj structMeth:1]; // expected-error {{incompatible type sending 'int'}}
diff --git a/clang/test/Sema/array-init.c b/clang/test/Sema/array-init.c
index cfbc2b926ae..849737e49e6 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 constant
extern int fileScopeExtern[3] = { 1, 3, 5 }; // expected-warning{{'extern' variable has an initializer}}
-static int ary3[] = { 1, "abc", 3, 4 }; // expected-warning{{incompatible pointer to integer conversion initializing 'char *', expected 'int'}}
+static int ary3[] = { 1, "abc", 3, 4 }; // expected-warning{{incompatible pointer to integer conversion initializing 'char [4]', expected 'int'}}
void func() {
int x = 1;
@@ -48,7 +48,7 @@ void func() {
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 pointer to integer conversion initializing 'char *', expected 'int'}}
+ static int x2[3] = { 1.0, "abc" , 5.8 }; // expected-warning{{incompatible pointer to integer conversion initializing 'char [4]', expected 'int'}}
}
void test() {
@@ -152,10 +152,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 *', expected 'int'}}
+ int i[] = { "Hello "}; // expected-warning{{incompatible pointer to integer conversion initializing 'char [7]', expected 'int'}}
char c2[] = { "Hello", "Good bye" }; //expected-error{{excess elements in char array initializer}}
- int i2[1] = { "Hello" }; //expected-warning{{incompatible pointer to integer conversion initializing 'char *', expected 'int'}}
+ int i2[1] = { "Hello" }; //expected-warning{{incompatible pointer to integer conversion initializing 'char [6]', expected 'int'}}
char c3[5] = { "Hello" };
char c4[4] = { "Hello" }; //expected-warning{{initializer-string for char array is too long}}
@@ -187,7 +187,7 @@ 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 *', expected 'char'}}
+struct s1 t3[] = {t1, t1, "abc", 0}; //expected-warning{{incompatible pointer to integer conversion initializing 'char [4]', expected 'char'}}
int t4[sizeof t3 == 6 ? 1 : -1];
}
struct foo { int z; } w;
diff --git a/clang/test/Sema/compound-literal.c b/clang/test/Sema/compound-literal.c
index 1a0394578a9..83657245f50 100644
--- a/clang/test/Sema/compound-literal.c
+++ b/clang/test/Sema/compound-literal.c
@@ -9,7 +9,7 @@ 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'}}
+static int *p3 = (int []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'char [2]', expected 'int'}}
typedef struct Test {int a;int b;} Test;
static Test* ll = &(Test) {0,0};
diff --git a/clang/test/Sema/i-c-e2.c b/clang/test/Sema/i-c-e2.c
index 1fd4c21a0c5..1afb7c90c28 100644
--- a/clang/test/Sema/i-c-e2.c
+++ b/clang/test/Sema/i-c-e2.c
@@ -1,6 +1,16 @@
-// RUN: clang %s -fsyntax-only
+// RUN: clang %s -fsyntax-only -fpascal-strings
char array[1024/(sizeof (long))];
int x['\xBb' == (char) 187 ? 1: -1];
+// PR1992
+void func(int x)
+{
+ switch (x) {
+ case sizeof("abc"): break;
+ case sizeof("loooong"): func(4);
+ case sizeof("\ploooong"): func(4);
+ }
+}
+
OpenPOWER on IntegriCloud