summaryrefslogtreecommitdiff
path: root/test/Sema
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2010-05-04 16:12:48 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2010-05-04 16:12:48 +0000
commit0883ccd9eac3b974df00e6548ee319a7dd3646f4 (patch)
treed6a70c3518b8dea8be7062438d7e8676820ed17f /test/Sema
parent60bfabcd8ce617297c0d231f77d14ab507e98796 (diff)
Notes
Diffstat (limited to 'test/Sema')
-rw-r--r--test/Sema/address_spaces.c2
-rw-r--r--test/Sema/altivec-init.c4
-rw-r--r--test/Sema/anonymous-struct-union.c12
-rw-r--r--test/Sema/arm-layout.c49
-rw-r--r--test/Sema/array-constraint.c4
-rw-r--r--test/Sema/array-init.c14
-rw-r--r--test/Sema/attr-format.c2
-rw-r--r--test/Sema/attr-noreturn.c2
-rw-r--r--test/Sema/attr-section.c2
-rw-r--r--test/Sema/bitfield.c4
-rw-r--r--test/Sema/block-call.c12
-rw-r--r--test/Sema/block-misc.c12
-rw-r--r--test/Sema/block-return.c14
-rw-r--r--test/Sema/builtin-prefetch.c4
-rw-r--r--test/Sema/builtin-stackaddress.c4
-rw-r--r--test/Sema/builtins.c2
-rw-r--r--test/Sema/cast-to-union.c2
-rw-r--r--test/Sema/compare.c5
-rw-r--r--test/Sema/compound-literal.c2
-rw-r--r--test/Sema/conditional-expr.c8
-rw-r--r--test/Sema/conditional.c4
-rw-r--r--test/Sema/decl-invalid.c12
-rw-r--r--test/Sema/declspec.c2
-rw-r--r--test/Sema/enum.c3
-rw-r--r--test/Sema/exprs.c8
-rw-r--r--test/Sema/ext_vector_casts.c2
-rw-r--r--test/Sema/format-strings.c4
-rw-r--r--test/Sema/function-ptr.c6
-rw-r--r--test/Sema/function-redecl.c2
-rw-r--r--test/Sema/incompatible-sign.c4
-rw-r--r--test/Sema/invalid-init-diag.c2
-rw-r--r--test/Sema/offsetof.c13
-rw-r--r--test/Sema/parentheses.c12
-rw-r--r--test/Sema/pointer-conversion.c6
-rw-r--r--test/Sema/predef.c2
-rw-r--r--test/Sema/predefined-function.c5
-rw-r--r--test/Sema/return.c2
-rw-r--r--test/Sema/statements.c12
-rw-r--r--test/Sema/struct-compat.c2
-rw-r--r--test/Sema/transparent-union.c2
-rw-r--r--test/Sema/typedef-retain.c4
-rw-r--r--test/Sema/unused-expr.c6
-rw-r--r--test/Sema/vector-assign.c44
-rw-r--r--test/Sema/vector-cast.c4
-rw-r--r--test/Sema/warn-missing-braces.c2
-rw-r--r--test/Sema/warn-unused-function.c7
-rw-r--r--test/Sema/warn-unused-parameters.c15
-rw-r--r--test/Sema/warn-unused-value.c15
-rw-r--r--test/Sema/warn-write-strings.c2
-rw-r--r--test/Sema/x86-builtin-palignr.c10
50 files changed, 246 insertions, 128 deletions
diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c
index badd2383abc2c..6258114578db3 100644
--- a/test/Sema/address_spaces.c
+++ b/test/Sema/address_spaces.c
@@ -37,6 +37,6 @@ struct _st {
__attribute__((address_space(256))) void * * const base = 0;
void * get_0(void) {
return base[0]; // expected-error {{illegal implicit cast between two pointers with different address spaces}} \
- expected-warning {{returning 'void __attribute__((address_space(256))) *' discards qualifiers, expected 'void *'}}
+ expected-warning {{returning 'void __attribute__((address_space(256))) *' from a function with result type 'void *' discards qualifiers}}
}
diff --git a/test/Sema/altivec-init.c b/test/Sema/altivec-init.c
index f22c1fc4db8a6..57abc9304d5be 100644
--- a/test/Sema/altivec-init.c
+++ b/test/Sema/altivec-init.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -faltivec -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -triple=powerpc-apple-darwin8 -faltivec -verify -pedantic -fsyntax-only
typedef int v4 __attribute((vector_size(16)));
typedef short v8 __attribute((vector_size(16)));
@@ -6,7 +6,7 @@ typedef short v8 __attribute((vector_size(16)));
v8 foo(void) {
v8 a;
v4 b;
- a = (v8){4, 2}; // expected-error {{too few elements in vector initialization (expected 8 elements, have 2)}}
+ a = (v8){4, 2};
b = (v4)(5, 6, 7, 8, 9); // expected-warning {{excess elements in vector initializer}}
b = (v4)(5, 6, 8, 8.0f);
return (v8){0, 1, 2, 3, 1, 2, 3, 4};
diff --git a/test/Sema/anonymous-struct-union.c b/test/Sema/anonymous-struct-union.c
index 78995a993a4f5..d9e08397f2d38 100644
--- a/test/Sema/anonymous-struct-union.c
+++ b/test/Sema/anonymous-struct-union.c
@@ -50,12 +50,12 @@ struct Redecl {
void zz(); // expected-error{{duplicate member 'zz'}}
};
-union { // expected-error{{declaration does not declare anything}}
+union { // expected-warning{{declaration does not declare anything}}
int int_val;
float float_val;
};
-static union { // expected-error{{declaration does not declare anything}}
+static union { // expected-warning{{declaration does not declare anything}}
int int_val2;
float float_val2;
};
@@ -66,7 +66,7 @@ void f() {
}
void g() {
- union { // expected-error{{declaration does not declare anything}}
+ union { // expected-warning{{declaration does not declare anything}}
int i;
float f2;
};
@@ -78,7 +78,7 @@ void g() {
struct s0 { union { int f0; }; };
// <rdar://problem/6481130>
-typedef struct { }; // expected-error{{declaration does not declare anything}}
+typedef struct { }; // expected-warning{{declaration does not declare anything}}
// PR3675
struct s1 {
@@ -89,7 +89,7 @@ struct s1 {
};
// PR3680
-struct {}; // expected-error{{declaration does not declare anything}}
+struct {}; // expected-warning{{declaration does not declare anything}}
struct s2 {
union {
@@ -101,4 +101,4 @@ struct s2 {
typedef struct {
int x;
} a_struct;
-int tmp = (a_struct) { .x = 0 }; // expected-error {{incompatible type initializing 'a_struct', expected 'int'}}
+int tmp = (a_struct) { .x = 0 }; // expected-error {{initializing 'int' with an expression of incompatible type 'a_struct'}}
diff --git a/test/Sema/arm-layout.c b/test/Sema/arm-layout.c
index 1e239d275a82b..424868510428c 100644
--- a/test/Sema/arm-layout.c
+++ b/test/Sema/arm-layout.c
@@ -1,20 +1,53 @@
// RUN: %clang_cc1 -triple armv7-unknown-unknown -target-abi apcs-gnu %s -verify
// RUN: %clang_cc1 -triple armv7-unknown-unknown -target-abi aapcs %s -verify
-#ifdef __ARM_EABI__
+#define check(name, cond) int _##name##_check[(cond) ? 1 : -1]
struct s0 { char field0; double field1; };
-int g0[sizeof(struct s0) == 16 ? 1 : -1];
+#ifdef __ARM_EABI__
+check(s0_size, sizeof(struct s0) == 16);
+#else
+check(s0_size, sizeof(struct s0) == 12);
+#endif
struct s1 { char field0; long double field1; };
-int g1[sizeof(struct s1) == 16 ? 1 : -1];
-
+#ifdef __ARM_EABI__
+check(s1_size, sizeof(struct s1) == 16);
#else
+check(s1_size, sizeof(struct s1) == 12);
+#endif
-struct s0 { char field0; double field1; };
-int g0[sizeof(struct s0) == 12 ? 1 : -1];
+struct s2 {
+ short field0;
+ int field1 : 24;
+ char field2;
+};
+#ifdef __ARM_EABI__
+check(s2_size, sizeof(struct s2) == 8);
+check(s2_offset_0, __builtin_offsetof(struct s2, field0) == 0);
+check(s2_offset_1, __builtin_offsetof(struct s2, field2) == 7);
+#else
+check(s2_size, sizeof(struct s2) == 6);
+check(s2_offset_0, __builtin_offsetof(struct s2, field0) == 0);
+check(s2_offset_1, __builtin_offsetof(struct s2, field2) == 5);
+#endif
-struct s1 { char field0; long double field1; };
-int g1[sizeof(struct s1) == 12 ? 1 : -1];
+struct s3 {
+ short field0;
+ int field1 : 24 __attribute__((aligned(4)));
+ char field2;
+};
+check(s3_size, sizeof(struct s3) == 8);
+check(s3_offset_0, __builtin_offsetof(struct s3, field0) == 0);
+check(s3_offset_1, __builtin_offsetof(struct s3, field2) == 7);
+struct s4 {
+ int field0 : 4
+};
+#ifdef __ARM_EABI__
+check(s4_size, sizeof(struct s4) == 4);
+check(s4_align, __alignof(struct s4) == 4);
+#else
+check(s4_size, sizeof(struct s4) == 1);
+check(s4_align, __alignof(struct s4) == 1);
#endif
diff --git a/test/Sema/array-constraint.c b/test/Sema/array-constraint.c
index 66f15c3a3cccc..9fcac25abe968 100644
--- a/test/Sema/array-constraint.c
+++ b/test/Sema/array-constraint.c
@@ -43,10 +43,10 @@ void check_size() {
static int I;
typedef int TA[I]; // expected-error {{variable length array declaration not allowed at file scope}}
-void strFunc(char *);
+void strFunc(char *); // expected-note{{passing argument to parameter here}}
const char staticAry[] = "test";
void checkStaticAry() {
- strFunc(staticAry); // expected-warning{{passing 'char const [5]' discards qualifiers, expected 'char *'}}
+ strFunc(staticAry); // expected-warning{{passing 'char const [5]' to parameter of type 'char *' discards qualifiers}}
}
diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c
index 45d3183852990..f93b0878fd3f1 100644
--- a/test/Sema/array-init.c
+++ b/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' with 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 *' with 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' with 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' with 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' with 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' with 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' with an expression of incompatible type 'struct foo'}}
return z.z;
}
struct s3 {void (*a)(void);} t5 = {autoStructTest};
diff --git a/test/Sema/attr-format.c b/test/Sema/attr-format.c
index 0fadf98f978f2..a223e08f5a484 100644
--- a/test/Sema/attr-format.c
+++ b/test/Sema/attr-format.c
@@ -45,7 +45,7 @@ void e2(char *str, int c, ...) __attribute__((format(printf0, 2,3))); // expecte
// FreeBSD usage
#define __printf0like(fmt,va) __attribute__((__format__(__printf0__,fmt,va)))
void null(int i, const char *a, ...) __printf0like(2,0); // no-error
-void null(int i, const char *a, ...) {
+void null(int i, const char *a, ...) { // expected-note{{passing argument to parameter 'a' here}}
if (a)
(void)0/* vprintf(...) would go here */;
}
diff --git a/test/Sema/attr-noreturn.c b/test/Sema/attr-noreturn.c
index b17f9fd12920d..5333a2c13fc28 100644
--- a/test/Sema/attr-noreturn.c
+++ b/test/Sema/attr-noreturn.c
@@ -40,3 +40,5 @@ f5 (unsigned long size)
__attribute__((noreturn)) void f(__attribute__((noreturn)) void (*x)(void)) {
x();
}
+
+typedef void (*Fun)(void) __attribute__ ((noreturn(2))); // expected-error {{attribute requires 0 argument(s)}}
diff --git a/test/Sema/attr-section.c b/test/Sema/attr-section.c
index 614f294d237e5..a9325254080ba 100644
--- a/test/Sema/attr-section.c
+++ b/test/Sema/attr-section.c
@@ -12,4 +12,4 @@ int y __attribute__((section(
void test() {
__attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute is not valid on local variables}}
__attribute__((section("NEAR,x"))) static int n2; // ok.
-} \ No newline at end of file
+}
diff --git a/test/Sema/bitfield.c b/test/Sema/bitfield.c
index 6f129daceba58..5bb194b1f3a9b 100644
--- a/test/Sema/bitfield.c
+++ b/test/Sema/bitfield.c
@@ -5,7 +5,7 @@ struct a {
int a : -1; // expected-error{{bit-field 'a' has negative width}}
// rdar://6081627
- int b : 33; // expected-error{{size of bit-field 'b' exceeds size of its type (32 bits)}}
+ int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}}
int d : (int)(1 + 0.25);
@@ -21,7 +21,7 @@ struct a {
int g : (_Bool)1;
// PR4017
- char : 10; // expected-error {{size of anonymous bit-field exceeds size of its type (8 bits)}}
+ char : 10; // expected-error {{size of anonymous bit-field (10 bits) exceeds size of its type (8 bits)}}
unsigned : -2; // expected-error {{anonymous bit-field has negative width (-2)}}
float : 12; // expected-error {{anonymous bit-field has non-integral type 'float'}}
};
diff --git a/test/Sema/block-call.c b/test/Sema/block-call.c
index 0aba75e14a9a4..318bc6b2a3b11 100644
--- a/test/Sema/block-call.c
+++ b/test/Sema/block-call.c
@@ -13,7 +13,7 @@ int main() {
int (^IFP) () = PFR; // OK
- const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int (^)()', expected 'int const (^)()'}}
+ const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int const (^)()' with an expression of type 'int (^)()'}}
const int (^CICC) () = CIC;
@@ -21,7 +21,7 @@ int main() {
int * const (^IPCC1) () = IPCC;
- int * (^IPCC2) () = IPCC; // expected-error {{incompatible block pointer types initializing 'int *const (^)()', expected 'int *(^)()'}}
+ int * (^IPCC2) () = IPCC; // expected-error {{incompatible block pointer types initializing 'int *(^)()' with an expression of type 'int *const (^)()'}}
int (^IPCC3) (const int) = PFR;
@@ -29,14 +29,14 @@ int main() {
int (^IPCC5) (int, char (^CArg) (double)) = IPCC4;
- int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{incompatible block pointer types initializing 'int (^)(int, char (^)(double))', expected 'int (^)(int, char (^)(float))'}}
+ int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{incompatible block pointer types initializing 'int (^)(int, char (^)(float))' with an expression of type 'int (^)(int, char (^)(double))'}}
IPCC2 = 0;
- IPCC2 = 1; // expected-error {{invalid conversion assigning integer 'int', expected block pointer 'int *(^)()'}}
+ IPCC2 = 1; // expected-error {{invalid block pointer conversion assigning to 'int *(^)()' from 'int'}}
int (^x)() = 0;
- int (^y)() = 3; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}}
+ int (^y)() = 3; // expected-error {{invalid block pointer conversion initializing 'int (^)()' with an expression of type 'int'}}
int a = 1;
- int (^z)() = a+4; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}}
+ int (^z)() = a+4; // expected-error {{invalid block pointer conversion initializing 'int (^)()' with an expression of type 'int'}}
}
int blah() {
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index ca71ab12b2681..92be5b1898489 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -139,12 +139,12 @@ void test14() {
enum { LESS };
-void foo(long (^comp)()) {
+void foo(long (^comp)()) { // expected-note{{passing argument to parameter 'comp' here}}
}
void (^test15f)(void);
void test15() {
- foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)', expected 'long (^)()'}}
+ foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)' to parameter of type 'long (^)()'}}
}
__block int test16i; // expected-error {{__block attribute not allowed, only allowed on local variables}}
@@ -202,8 +202,8 @@ L0:
// radr://7438948
void test20() {
int n = 7;
- int vla[n]; // expected-note {{declared at}}
- int (*vm)[n] = 0; // expected-note {{declared at}}
+ int vla[n]; // expected-note {{declared here}}
+ int (*vm)[n] = 0; // expected-note {{declared here}}
vla[1] = 4341;
^{
(void)vla[1]; // expected-error {{cannot refer to declaration with a variably modified type inside block}}
@@ -213,8 +213,8 @@ void test20() {
// radr://7438948
void test21() {
- int a[7]; // expected-note {{declared at}}
- __block int b[10]; // expected-note {{declared at}}
+ int a[7]; // expected-note {{declared here}}
+ __block int b[10]; // expected-note {{declared here}}
a[1] = 1;
^{
(void)a[1]; // expected-error {{cannot refer to declaration with an array type inside block}}
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index 2385106630d78..10b3b8480cc96 100644
--- a/test/Sema/block-return.c
+++ b/test/Sema/block-return.c
@@ -4,7 +4,7 @@ typedef void (^CL)(void);
CL foo() {
short y;
- short (^add1)(void) = ^{ return y+1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(void)', expected 'short (^)(void)'}}
+ short (^add1)(void) = ^{ return y+1; }; // expected-error {{incompatible block pointer types initializing 'short (^)(void)' with an expression of type 'int (^)(void)'}}
CL X = ^{
if (2)
@@ -26,7 +26,7 @@ CL foo() {
return (char*)0;
};
- double (^A)(void) = ^ { // expected-error {{incompatible block pointer types initializing 'float (^)(void)', expected 'double (^)(void)'}}
+ double (^A)(void) = ^ { // expected-error {{incompatible block pointer types initializing 'double (^)(void)' with an expression of type 'float (^)(void)'}}
if (1)
return (float)1.0;
else
@@ -38,10 +38,10 @@ CL foo() {
if (3)
return "";
else
- return 2; // expected-warning {{incompatible integer to pointer conversion returning 'int', expected 'char *'}}
+ return 2; // expected-warning {{incompatible integer to pointer conversion returning 'int' from a function with result type 'char *'}}
};
- return ^{ return 1; }; // expected-error {{incompatible block pointer types returning 'int (^)(void)', expected 'CL'}}
+ return ^{ return 1; }; // expected-error {{incompatible block pointer types returning 'int (^)(void)' from a function with result type 'CL' (aka 'void (^)(void)')}}
}
typedef int (^CL2)(void);
@@ -78,8 +78,8 @@ static int funk(char *s) {
}
void next();
void foo4() {
- int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(char *)', expected 'int (^)(char const *)'}}
- int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (char *)', expected 'int (*)(char const *)'}}
+ int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(char const *)' with an expression of type 'int (^)(char *)'}}
+ int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (*)(char const *)' with an expression of type 'int (char *)'}}
int (^nested)(char *s) = ^(char *str) { void (^nest)(void) = ^(void) { printf("%s\n", str); }; next(); return 1; }; // expected-warning{{implicitly declaring C library function 'printf' with type 'int (char const *, ...)'}} \
// expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
@@ -109,7 +109,7 @@ void foo6() {
void foo7()
{
- const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int (^)(void)', expected 'int const (^)(void)'}}
+ const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int const (^)(void)' with an expression of type 'int (^)(void)'}}
const int (^CC) (void) = ^const int{ const int i = 1; return i; }; // OK
int i;
diff --git a/test/Sema/builtin-prefetch.c b/test/Sema/builtin-prefetch.c
index 4f09da6c28cfc..c5fa792a56636 100644
--- a/test/Sema/builtin-prefetch.c
+++ b/test/Sema/builtin-prefetch.c
@@ -6,8 +6,8 @@ void foo() {
__builtin_prefetch(&a, 1);
__builtin_prefetch(&a, 1, 2);
__builtin_prefetch(&a, 1, 9, 3); // expected-error{{too many arguments to function}}
- __builtin_prefetch(&a, "hello", 2); // expected-error{{argument to __builtin_prefetch must be of integer type}}
- __builtin_prefetch(&a, a, 2); // expected-error{{argument to __builtin_prefetch must be a constant integer}}
+ __builtin_prefetch(&a, "hello", 2); // expected-error{{argument to '__builtin_prefetch' must be a constant integer}}
+ __builtin_prefetch(&a, a, 2); // expected-error{{argument to '__builtin_prefetch' must be a constant integer}}
__builtin_prefetch(&a, 2); // expected-error{{argument should be a value from 0 to 1}}
__builtin_prefetch(&a, 0, 4); // expected-error{{argument should be a value from 0 to 3}}
__builtin_prefetch(&a, -1, 4); // expected-error{{argument should be a value from 0 to 1}}
diff --git a/test/Sema/builtin-stackaddress.c b/test/Sema/builtin-stackaddress.c
index 1feb57ea52670..5f63bb114624f 100644
--- a/test/Sema/builtin-stackaddress.c
+++ b/test/Sema/builtin-stackaddress.c
@@ -4,7 +4,7 @@ return __builtin_return_address(0);
}
void b(unsigned x) {
-return __builtin_return_address(x); // expected-error{{the level argument for a stack address builtin must be constant}}
+return __builtin_return_address(x); // expected-error{{argument to '__builtin_return_address' must be a constant integer}}
}
void* c(unsigned x) {
@@ -12,5 +12,5 @@ return __builtin_frame_address(0);
}
void d(unsigned x) {
-return __builtin_frame_address(x); // expected-error{{the level argument for a stack address builtin must be constant}}
+return __builtin_frame_address(x); // expected-error{{argument to '__builtin_frame_address' must be a constant integer}}
}
diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c
index 7b2f2afbd9cad..6fa563b31137b 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -60,7 +60,7 @@ void test11(int X) {
break;
}
- __builtin_eh_return_data_regno(X); // expected-error {{not an integer constant expression}}
+ __builtin_eh_return_data_regno(X); // expected-error {{argument to '__builtin_eh_return_data_regno' must be a constant integer}}
}
// PR5062
diff --git a/test/Sema/cast-to-union.c b/test/Sema/cast-to-union.c
index 6856c17c721a9..6f275e8b505fb 100644
--- a/test/Sema/cast-to-union.c
+++ b/test/Sema/cast-to-union.c
@@ -10,7 +10,7 @@ void test(int x) {
union u w = (union u)2; // expected-warning {{C99 forbids casts to union type}}
union u ww = (union u)1.0; // expected-error{{cast to union type from type 'double' not present in union}}
-union u x = 7; // expected-error{{incompatible type initializing 'int', expected 'union u'}}
+union u x = 7; // expected-error{{initializing 'union u' with an expression of incompatible type 'int'}}
int i;
union u zz = (union u)i; // expected-error{{initializer element is not a compile-time constant}} expected-warning {{C99 forbids casts to union type}}
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index 7c8c36f0c145b..631b694202933 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -282,3 +282,8 @@ int test5(unsigned int x) {
&& (x >= 0) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
&& (0 <= x); // expected-warning {{comparison of 0 <= unsigned expression is always true}}
}
+
+int test6(unsigned i, unsigned power) {
+ unsigned x = (i < (1 << power) ? i : 0);
+ return x != 3 ? 1 << power : i;
+}
diff --git a/test/Sema/compound-literal.c b/test/Sema/compound-literal.c
index 0c8ddd42d0c88..08c30b3c876de 100644
--- a/test/Sema/compound-literal.c
+++ b/test/Sema/compound-literal.c
@@ -9,7 +9,7 @@ static int *p = (int []){2,4};
static int x = (int){1};
static int *p2 = (int []){2,x}; // -expected-error {{initializer element is not a compile-time constant}}
-static long *p3 = (long []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'char [2]', expected 'long'}}
+static long *p3 = (long []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [2]'}}
typedef struct { } cache_t; // -expected-warning{{use of empty struct extension}}
static cache_t clo_I1_cache = ((cache_t) { } ); // -expected-warning{{use of GNU empty initializer extension}}
diff --git a/test/Sema/conditional-expr.c b/test/Sema/conditional-expr.c
index 5f01374be3669..5e2c1a46248a3 100644
--- a/test/Sema/conditional-expr.c
+++ b/test/Sema/conditional-expr.c
@@ -13,11 +13,11 @@ void foo() {
dp = vp;
vp = dp;
- ip = dp; // expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}}
- dp = ip; // expected-warning {{incompatible pointer types assigning 'int *', expected 'double *'}}
+ ip = dp; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}}
+ dp = ip; // expected-warning {{incompatible pointer types assigning to 'double *' from 'int *'}}
dp = 0 ? (double *)0 : (void *)0;
vp = 0 ? (double *)0 : (void *)0;
- ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning 'double *', expected 'int *'}}
+ ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}}
const int *cip;
vp = (0 ? vp : cip); // expected-warning {{discards qualifiers}}
@@ -66,5 +66,5 @@ extern int f1(void);
int f0(int a) {
// GCC considers this a warning.
- return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *', expected 'int'}}
+ return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *' from a function with result type 'int'}}
}
diff --git a/test/Sema/conditional.c b/test/Sema/conditional.c
index c3dbe1321b6b2..3d7bccaf97588 100644
--- a/test/Sema/conditional.c
+++ b/test/Sema/conditional.c
@@ -6,9 +6,9 @@ void _efree(void *ptr);
void free(void *ptr);
int _php_stream_free1() {
- return (1 ? free(0) : _efree(0)); // expected-error {{incompatible type returning 'void', expected 'int'}}
+ return (1 ? free(0) : _efree(0)); // expected-error {{returning 'void' from a function with incompatible result type 'int'}}
}
int _php_stream_free2() {
- return (1 ? _efree(0) : free(0)); // expected-error {{incompatible type returning 'void', expected 'int'}}
+ return (1 ? _efree(0) : free(0)); // expected-error {{returning 'void' from a function with incompatible result type 'int'}}
}
diff --git a/test/Sema/decl-invalid.c b/test/Sema/decl-invalid.c
index 815e6dd9ca508..f6fed3c92d0d9 100644
--- a/test/Sema/decl-invalid.c
+++ b/test/Sema/decl-invalid.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify
// See Sema::ParsedFreeStandingDeclSpec about the double diagnostic
-typedef union <anonymous> __mbstate_t; // expected-error {{declaration of anonymous union must be a definition}} expected-error {{declaration does not declare anything}}
+typedef union <anonymous> __mbstate_t; // expected-error {{declaration of anonymous union must be a definition}} expected-warning {{declaration does not declare anything}}
// PR2017
@@ -13,12 +13,12 @@ int a() {
expected-error{{expected identifier or '('}}
}
-int; // expected-error {{declaration does not declare anything}}
-typedef int; // expected-error {{declaration does not declare anything}}
-const int; // expected-error {{declaration does not declare anything}}
-struct; // expected-error {{declaration of anonymous struct must be a definition}} // expected-error {{declaration does not declare anything}}
+int; // expected-warning {{declaration does not declare anything}}
+typedef int; // expected-warning {{declaration does not declare anything}}
+const int; // expected-warning {{declaration does not declare anything}}
+struct; // expected-error {{declaration of anonymous struct must be a definition}} // expected-warning {{declaration does not declare anything}}
typedef int I;
-I; // expected-error {{declaration does not declare anything}}
+I; // expected-warning {{declaration does not declare anything}}
diff --git a/test/Sema/declspec.c b/test/Sema/declspec.c
index 1c87a0e21c5da..7354028cba392 100644
--- a/test/Sema/declspec.c
+++ b/test/Sema/declspec.c
@@ -10,7 +10,7 @@ int typedef validTypeDecl() { } // expected-error {{function definition declared
struct _zend_module_entry { } // expected-error {{expected ';' after struct}}
int gv1;
typedef struct _zend_function_entry { } // expected-error {{expected ';' after struct}} \
- // expected-error {{declaration does not declare anything}}
+ // expected-warning {{declaration does not declare anything}}
int gv2;
static void buggy(int *x) { }
diff --git a/test/Sema/enum.c b/test/Sema/enum.c
index 6177edff91c4d..ba4e56b907a72 100644
--- a/test/Sema/enum.c
+++ b/test/Sema/enum.c
@@ -91,8 +91,7 @@ static enum e1 badfunc(struct s1 *q) {
typedef enum {
an_enumerator = 20
} an_enum;
-// FIXME: why is this only a warning?
-char * s = (an_enum) an_enumerator; // expected-warning {{incompatible integer to pointer conversion initializing 'an_enum', expected 'char *'}}
+char * s = (an_enum) an_enumerator; // expected-warning {{incompatible integer to pointer conversion initializing 'char *' with an expression of type 'an_enum'}}
// PR4515
enum PR4515 {PR4515a=1u,PR4515b=(PR4515a-2)/2};
diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c
index 9acc63fa41a5e..dbb6e80aa6d57 100644
--- a/test/Sema/exprs.c
+++ b/test/Sema/exprs.c
@@ -84,7 +84,7 @@ void test11(struct mystruct P, float F) {
// PR3753
int test12(const char *X) {
- return X == "foo"; // expected-warning {{comparison against a string literal is unspecified}}
+ return X == "foo"; // expected-warning {{comparison against a string literal is unspecified (use strncmp instead)}}
}
int test12b(const char *X) {
@@ -128,3 +128,9 @@ void test17(int x) {
x = sizeof(x/0); // no warning.
}
+// PR6501
+void test18_a(int a);
+void test18(int b) {
+ test18_a(b, b); // expected-error {{too many arguments to function call, expected 1, have 2}}
+ test18_a(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+}
diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c
index cbda021cd282f..d2976238c0e5e 100644
--- a/test/Sema/ext_vector_casts.c
+++ b/test/Sema/ext_vector_casts.c
@@ -25,7 +25,7 @@ static void test() {
ivec4 = (int4)vec4_3;
i = (int)ivec4; // expected-error {{invalid conversion between vector type 'int4' and integer type 'int' of different size}}
- i = ivec4; // expected-error {{incompatible type assigning 'int4', expected 'int'}}
+ i = ivec4; // expected-error {{assigning to 'int' from incompatible type 'int4'}}
ivec4 = (int4)ptr; // expected-error {{invalid conversion between vector type 'int4' and scalar type 'int *'}}
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index dcc4c35d01eca..bdc2bb0c9abea 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -4,7 +4,7 @@
typedef __typeof(sizeof(int)) size_t;
typedef struct _FILE FILE;
int fprintf(FILE *, const char *restrict, ...);
-int printf(const char *restrict, ...);
+int printf(const char *restrict, ...); // expected-note{{passing argument to parameter here}}
int snprintf(char *restrict, size_t, const char *restrict, ...);
int sprintf(char *restrict, const char *restrict, ...);
int vasprintf(char **, const char *, va_list);
@@ -12,7 +12,7 @@ int asprintf(char **, const char *, ...);
int vfprintf(FILE *, const char *restrict, va_list);
int vprintf(const char *restrict, va_list);
int vsnprintf(char *, size_t, const char *, va_list);
-int vsprintf(char *restrict, const char *restrict, va_list);
+int vsprintf(char *restrict, const char *restrict, va_list); // expected-note{{passing argument to parameter here}}
char * global_fmt;
diff --git a/test/Sema/function-ptr.c b/test/Sema/function-ptr.c
index c1ff8e1d7b1f3..ff852725baefb 100644
--- a/test/Sema/function-ptr.c
+++ b/test/Sema/function-ptr.c
@@ -3,9 +3,9 @@ typedef int unary_int_func(int arg);
unary_int_func *func;
unary_int_func *set_func(void *p) {
- func = p; // expected-warning {{converts between void* and function pointer}}
- p = func; // expected-warning {{converts between void* and function pointer}}
+ func = p; // expected-warning {{converts between void pointer and function pointer}}
+ p = func; // expected-warning {{converts between void pointer and function pointer}}
- return p; // expected-warning {{converts between void* and function pointer}}
+ return p; // expected-warning {{converts between void pointer and function pointer}}
}
diff --git a/test/Sema/function-redecl.c b/test/Sema/function-redecl.c
index 1302b34b107a3..b8a64af96bcf6 100644
--- a/test/Sema/function-redecl.c
+++ b/test/Sema/function-redecl.c
@@ -123,7 +123,7 @@ a x;
a2 x2;
void test_x() {
x(5);
- x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int', expected 'int *'}}
+ x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'}}
}
enum e0 {};
diff --git a/test/Sema/incompatible-sign.c b/test/Sema/incompatible-sign.c
index a1592efc4c47d..6249feb6b1e71 100644
--- a/test/Sema/incompatible-sign.c
+++ b/test/Sema/incompatible-sign.c
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
-int a(int* x);
-int b(unsigned* y) { return a(y); } // expected-warning {{pointer types point to integer types with different sign}}
+int a(int* x); // expected-note{{passing argument to parameter 'x' here}}
+int b(unsigned* y) { return a(y); } // expected-warning {{passing 'unsigned int *' to parameter of type 'int *' converts between pointers to integer types with different sign}}
diff --git a/test/Sema/invalid-init-diag.c b/test/Sema/invalid-init-diag.c
index dec7d6c18f8a9..3e4870e0cab11 100644
--- a/test/Sema/invalid-init-diag.c
+++ b/test/Sema/invalid-init-diag.c
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
int a;
-struct {int x;} x = a; // expected-error {{incompatible type initializing 'int', expected 'struct <anonymous}}
+struct {int x;} x = a; // expected-error {{with an expression of incompatible type 'int'}}
diff --git a/test/Sema/offsetof.c b/test/Sema/offsetof.c
index 49d4eb43e4236..5026193943fff 100644
--- a/test/Sema/offsetof.c
+++ b/test/Sema/offsetof.c
@@ -53,4 +53,15 @@ int x[__builtin_offsetof(union x, x)];
struct incomplete; // expected-note 2 {{forward declaration of 'struct incomplete'}}
int test1[__builtin_offsetof(struct incomplete, foo)]; // expected-error {{offsetof of incomplete type 'struct incomplete'}}
-int test1[__builtin_offsetof(struct incomplete[10], [4].foo)]; // expected-error {{array has incomplete element type 'struct incomplete'}}
+int test2[__builtin_offsetof(struct incomplete[10], [4].foo)]; // expected-error {{array has incomplete element type 'struct incomplete'}}
+
+// Bitfields
+struct has_bitfields {
+ int i : 7;
+ int j : 12; // expected-note{{bit-field is declared here}}
+};
+
+int test3 = __builtin_offsetof(struct has_bitfields, j); // expected-error{{cannot compute offset of bit-field 'j'}}
+
+typedef struct Array { int array[1]; } Array;
+int test4 = __builtin_offsetof(Array, array);
diff --git a/test/Sema/parentheses.c b/test/Sema/parentheses.c
index 69c91cb15f47d..e53f0eb99bc1b 100644
--- a/test/Sema/parentheses.c
+++ b/test/Sema/parentheses.c
@@ -5,17 +5,21 @@
void if_assign(void) {
int i;
if (i = 4) {} // expected-warning {{assignment as a condition}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
if ((i = 4)) {}
}
void bitwise_rel(unsigned i) {
(void)(i & 0x2 == 0); // expected-warning {{& has lower precedence than ==}} \
- // expected-note{{place parentheses around the & expression to evaluate it first}}
+ // expected-note{{place parentheses around the & expression to evaluate it first}} \
+ // expected-note{{place parentheses around the == expression to silence this warning}}
(void)(0 == i & 0x2); // expected-warning {{& has lower precedence than ==}} \
- // expected-note{{place parentheses around the & expression to evaluate it first}}
+ // expected-note{{place parentheses around the & expression to evaluate it first}} \
+ // expected-note{{place parentheses around the == expression to silence this warning}}
(void)(i & 0xff < 30); // expected-warning {{& has lower precedence than <}} \
- // expected-note{{place parentheses around the & expression to evaluate it first}}
+ // expected-note{{place parentheses around the & expression to evaluate it first}} \
+ // expected-note{{place parentheses around the < expression to silence this warning}}
(void)((i & 0x2) == 0);
(void)(i & (0x2 == 0));
// Eager logical op
diff --git a/test/Sema/pointer-conversion.c b/test/Sema/pointer-conversion.c
index 7191bf7c63f46..2d755ae42f3dd 100644
--- a/test/Sema/pointer-conversion.c
+++ b/test/Sema/pointer-conversion.c
@@ -1,10 +1,10 @@
//RUN: %clang_cc1 -fsyntax-only -verify %s
char * c;
-char const ** c2 = &c; // expected-warning {{initializing, 'char const **' and 'char **' have different qualifiers in nested pointer types}}
+char const ** c2 = &c; // expected-warning {{discards qualifiers in nested pointer types}}
typedef char dchar;
-dchar *** c3 = &c2; // expected-warning {{initializing, 'dchar ***' and 'char const ***' have different qualifiers in nested pointer types}}
+dchar *** c3 = &c2; // expected-warning {{discards qualifiers in nested pointer types}}
volatile char * c4;
-char ** c5 = &c4; // expected-warning {{initializing, 'char **' and 'char volatile **' have different qualifiers in nested pointer types}}
+char ** c5 = &c4; // expected-warning {{discards qualifiers in nested pointer types}}
diff --git a/test/Sema/predef.c b/test/Sema/predef.c
index 9c1994699da76..08a4a2bf83e9f 100644
--- a/test/Sema/predef.c
+++ b/test/Sema/predef.c
@@ -6,7 +6,7 @@ void abcdefghi12(void) {
}
char *X = __func__; // expected-warning {{predefined identifier is only valid}} \
- expected-warning {{initializing 'char const [1]' discards qualifiers, expected 'char *'}}
+ expected-warning {{initializing 'char *' with an expression of type 'char const [1]' discards qualifiers}}
void a() {
__func__[0] = 'a'; // expected-error {{variable is not assignable}}
diff --git a/test/Sema/predefined-function.c b/test/Sema/predefined-function.c
index 665d0fa1a8b78..1c40b6e8c2c0e 100644
--- a/test/Sema/predefined-function.c
+++ b/test/Sema/predefined-function.c
@@ -4,13 +4,14 @@ char *funk(int format);
enum Test {A=-1};
char *funk(enum Test x);
-int eli(float b); // expected-note {{previous declaration is here}}
+int eli(float b); // expected-note {{previous declaration is here}} \
+// expected-note{{passing argument to parameter 'b' here}}
int b(int c) {return 1;}
int foo();
int foo() {
int eli(int (int)); // expected-error {{conflicting types for 'eli'}}
- eli(b); // expected-error{{incompatible type passing}}
+ eli(b); // expected-error{{passing 'int (int)' to parameter of incompatible type 'float'}}
return 0;
}
diff --git a/test/Sema/return.c b/test/Sema/return.c
index fab6a82aa7042..0d46d981bed20 100644
--- a/test/Sema/return.c
+++ b/test/Sema/return.c
@@ -225,7 +225,7 @@ void test33() {
// Test that 'static inline' functions are only analyzed for CFG-based warnings
// when they are used.
-static inline int si_has_missing_return() {} // no-warning
+static inline int si_has_missing_return() {} // expected-warning{{control reaches end of non-void function}}
static inline int si_has_missing_return_2() {}; // expected-warning{{control reaches end of non-void function}}
static inline int si_forward();
static inline int si_has_missing_return_3(int x) {
diff --git a/test/Sema/statements.c b/test/Sema/statements.c
index 6da2daa01ac23..e3c41f3e1aaf3 100644
--- a/test/Sema/statements.c
+++ b/test/Sema/statements.c
@@ -13,7 +13,7 @@ int test(int _x) {
// PR2374
int test2() { return ({L:5;}); }
-int test3() { return ({ {5;} }); } // expected-error {{incompatible type returning 'void', expected 'int'}}\
+int test3() { return ({ {5;} }); } // expected-error {{returning 'void' from a function with incompatible result type 'int'}}\
// expected-warning {{expression result unused}}
int test4() { return ({ ({5;}); }); }
int test5() { return ({L1: L2: L3: 5;}); }
@@ -41,3 +41,13 @@ void test11(int bit) {
{
}
}
+
+// rdar://3271964
+enum Numbers { kOne, kTwo, kThree, kFour};
+int test12(enum Numbers num) {
+ switch (num == kOne) {// expected-warning {{switch condition has boolean value}}
+ default:
+ case kThree:
+ break;
+ }
+} \ No newline at end of file
diff --git a/test/Sema/struct-compat.c b/test/Sema/struct-compat.c
index 2e112e17dade7..65bef9f60555f 100644
--- a/test/Sema/struct-compat.c
+++ b/test/Sema/struct-compat.c
@@ -13,5 +13,5 @@ struct x {int a;} *c = b; // expected-warning {{incompatible pointer types}}
struct x {int a;} r;
int b() {
-struct x {char x;} s = r; // expected-error {{incompatible type initializing}}
+struct x {char x;} s = r; // expected-error {{initializing 'struct x' with an expression of incompatible type 'struct x'}}
}
diff --git a/test/Sema/transparent-union.c b/test/Sema/transparent-union.c
index 03f6a53d059a0..cdfc8506d1b5d 100644
--- a/test/Sema/transparent-union.c
+++ b/test/Sema/transparent-union.c
@@ -4,7 +4,7 @@ typedef union {
float *fp;
} TU __attribute__((transparent_union));
-void f(TU);
+void f(TU); // expected-note{{passing argument to parameter here}}
void g(int *ip, float *fp, char *cp) {
f(ip);
diff --git a/test/Sema/typedef-retain.c b/test/Sema/typedef-retain.c
index 0ef15fdec6cd7..5b963c48b2cc0 100644
--- a/test/Sema/typedef-retain.c
+++ b/test/Sema/typedef-retain.c
@@ -5,11 +5,11 @@ typedef int int4 __attribute__((vector_size(16)));
typedef int4* int4p;
void test1(float4 a, int4 *result, int i) {
- result[i] = a; // expected-error {{assigning 'float4', expected 'int4'}}
+ result[i] = a; // expected-error {{assigning to 'int4' from incompatible type 'float4'}}
}
void test2(float4 a, int4p result, int i) {
- result[i] = a; // expected-error {{assigning 'float4', expected 'int4'}}
+ result[i] = a; // expected-error {{assigning to 'int4' from incompatible type 'float4'}}
}
// PR2039
diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c
index 4c6c47b345170..4ae0d4b46504a 100644
--- a/test/Sema/unused-expr.c
+++ b/test/Sema/unused-expr.c
@@ -104,3 +104,9 @@ void t8() {
}
void t9() __attribute__((warn_unused_result)); // expected-warning {{attribute 'warn_unused_result' cannot be applied to functions without return value}}
+
+// rdar://7410924
+void *some_function(void);
+void t10() {
+ (void*) some_function(); //expected-warning {{expression result unused; should this cast be to 'void'?}}
+}
diff --git a/test/Sema/vector-assign.c b/test/Sema/vector-assign.c
index d074a958fa0f3..05fc3b13db0c9 100644
--- a/test/Sema/vector-assign.c
+++ b/test/Sema/vector-assign.c
@@ -12,30 +12,30 @@ void test1() {
v2f v4;
v4ss v5;
- v1 = v2; // expected-warning {{incompatible vector types assigning 'v2u', expected 'v2s'}}
- v1 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v2s'}}
- v1 = v4; // expected-warning {{incompatible vector types assigning 'v2f', expected 'v2s'}}
- v1 = v5; // expected-warning {{incompatible vector types assigning 'v4ss', expected 'v2s'}}
+ v1 = v2; // expected-warning {{incompatible vector types assigning to 'v2s' from 'v2u'}}
+ v1 = v3; // expected-error {{assigning to 'v2s' from incompatible type 'v1s'}}
+ v1 = v4; // expected-warning {{incompatible vector types assigning to 'v2s' from 'v2f'}}
+ v1 = v5; // expected-warning {{incompatible vector types assigning to 'v2s' from 'v4ss'}}
- v2 = v1; // expected-warning {{incompatible vector types assigning 'v2s', expected 'v2u'}}
- v2 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v2u'}}
- v2 = v4; // expected-warning {{incompatible vector types assigning 'v2f', expected 'v2u'}}
- v2 = v5; // expected-warning {{incompatible vector types assigning 'v4ss', expected 'v2u'}}
+ v2 = v1; // expected-warning {{incompatible vector types assigning to 'v2u' from 'v2s'}}
+ v2 = v3; // expected-error {{assigning to 'v2u' from incompatible type 'v1s'}}
+ v2 = v4; // expected-warning {{incompatible vector types assigning to 'v2u' from 'v2f'}}
+ v2 = v5; // expected-warning {{incompatible vector types assigning to 'v2u' from 'v4ss'}}
- v3 = v1; // expected-error {{incompatible type assigning 'v2s', expected 'v1s'}}
- v3 = v2; // expected-error {{incompatible type assigning 'v2u', expected 'v1s'}}
- v3 = v4; // expected-error {{incompatible type assigning 'v2f', expected 'v1s'}}
- v3 = v5; // expected-error {{incompatible type assigning 'v4ss', expected 'v1s'}}
+ v3 = v1; // expected-error {{assigning to 'v1s' from incompatible type 'v2s'}}
+ v3 = v2; // expected-error {{assigning to 'v1s' from incompatible type 'v2u'}}
+ v3 = v4; // expected-error {{assigning to 'v1s' from incompatible type 'v2f'}}
+ v3 = v5; // expected-error {{assigning to 'v1s' from incompatible type 'v4ss'}}
- v4 = v1; // expected-warning {{incompatible vector types assigning 'v2s', expected 'v2f'}}
- v4 = v2; // expected-warning {{incompatible vector types assigning 'v2u', expected 'v2f'}}
- v4 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v2f'}}
- v4 = v5; // expected-warning {{incompatible vector types assigning 'v4ss', expected 'v2f'}}
+ v4 = v1; // expected-warning {{incompatible vector types assigning to 'v2f' from 'v2s'}}
+ v4 = v2; // expected-warning {{incompatible vector types assigning to 'v2f' from 'v2u'}}
+ v4 = v3; // expected-error {{assigning to 'v2f' from incompatible type 'v1s'}}
+ v4 = v5; // expected-warning {{incompatible vector types assigning to 'v2f' from 'v4ss'}}
- v5 = v1; // expected-warning {{incompatible vector types assigning 'v2s', expected 'v4ss'}}
- v5 = v2; // expected-warning {{incompatible vector types assigning 'v2u', expected 'v4ss'}}
- v5 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v4ss'}}
- v5 = v4; // expected-warning {{incompatible vector types assigning 'v2f', expected 'v4ss'}}
+ v5 = v1; // expected-warning {{incompatible vector types assigning to 'v4ss' from 'v2s'}}
+ v5 = v2; // expected-warning {{incompatible vector types assigning to 'v4ss' from 'v2u'}}
+ v5 = v3; // expected-error {{assigning to 'v4ss' from incompatible type 'v1s'}}
+ v5 = v4; // expected-warning {{incompatible vector types assigning to 'v4ss' from 'v2f'}}
}
// PR2263
@@ -47,7 +47,7 @@ float test2(__attribute__((vector_size(16))) float a, int b) {
typedef long long __attribute__((__vector_size__(2 * sizeof(long long))))
longlongvec;
-void test3a(longlongvec *);
+void test3a(longlongvec *); // expected-note{{passing argument to parameter here}}
void test3(const unsigned *src) {
- test3a(src); // expected-warning {{incompatible pointer types passing 'unsigned int const *', expected 'longlongvec *'}}
+ test3a(src); // expected-warning {{incompatible pointer types passing 'unsigned int const *' to parameter of type 'longlongvec *'}}
}
diff --git a/test/Sema/vector-cast.c b/test/Sema/vector-cast.c
index aab0ab4775abb..a717e86110191 100644
--- a/test/Sema/vector-cast.c
+++ b/test/Sema/vector-cast.c
@@ -30,9 +30,9 @@ type 't1' and integer type 'short' of different size}}
}
-void f2(t2 X);
+void f2(t2 X); // expected-note{{passing argument to parameter 'X' here}}
void f3(t3 Y) {
- f2(Y); // expected-warning {{incompatible vector types passing 't3', expected 't2'}}
+ f2(Y); // expected-warning {{incompatible vector types passing 't3' to parameter of type 't2'}}
}
diff --git a/test/Sema/warn-missing-braces.c b/test/Sema/warn-missing-braces.c
index 07eb61aac003e..ebfe9848306da 100644
--- a/test/Sema/warn-missing-braces.c
+++ b/test/Sema/warn-missing-braces.c
@@ -1,3 +1,3 @@
// RUN: %clang_cc1 -fsyntax-only -Wmissing-braces -verify %s
-int a[2][2] = { 0, 1, 2, 3 }; // expected-warning{{suggest braces}} expected-warning{{suggest braces}} \ No newline at end of file
+int a[2][2] = { 0, 1, 2, 3 }; // expected-warning{{suggest braces}} expected-warning{{suggest braces}}
diff --git a/test/Sema/warn-unused-function.c b/test/Sema/warn-unused-function.c
index b52f676ac58a4..d5e676b116033 100644
--- a/test/Sema/warn-unused-function.c
+++ b/test/Sema/warn-unused-function.c
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -Wunused-function -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
void foo() {}
static void f2() {}
@@ -28,3 +30,8 @@ static void f7(void) {}
__attribute__((unused)) static void bar(void);
void bar(void) { }
+__attribute__((constructor)) static void bar2(void);
+void bar2(void) { }
+
+__attribute__((destructor)) static void bar3(void);
+void bar3(void) { }
diff --git a/test/Sema/warn-unused-parameters.c b/test/Sema/warn-unused-parameters.c
index c6458cf9712bc..e47ddd5e00d51 100644
--- a/test/Sema/warn-unused-parameters.c
+++ b/test/Sema/warn-unused-parameters.c
@@ -1,13 +1,22 @@
-// RUN: %clang -fblocks -fsyntax-only -Wunused-parameter %s -Xclang -verify
+// RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused-parameter %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused %s 2>&1 | FileCheck -check-prefix=CHECK-unused %s
int f0(int x,
- int y, // expected-warning{{unused}}
+ int y,
int z __attribute__((unused))) {
return x;
}
void f1() {
(void)^(int x,
- int y, // expected-warning{{unused}}
+ int y,
int z __attribute__((unused))) { return x; };
}
+
+// Used when testing '-Wunused' to see that we only emit one diagnostic, and no
+// warnings for the above cases.
+static void achor() {};
+
+// CHECK: 5:12: warning: unused parameter 'y'
+// CHECK: 12:15: warning: unused parameter 'y'
+// CHECK-unused: 1 warning generated \ No newline at end of file
diff --git a/test/Sema/warn-unused-value.c b/test/Sema/warn-unused-value.c
index 2e0fa54effbff..16b787f774411 100644
--- a/test/Sema/warn-unused-value.c
+++ b/test/Sema/warn-unused-value.c
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
int i = 0;
int j = 0;
@@ -51,3 +53,16 @@ void pr4806() {
*pi; // expected-warning {{expression result unused}}
*pj;
}
+
+// Don't warn about unused '||', '&&' expressions that contain assignments.
+int test_logical_foo1();
+int test_logical_foo2();
+int test_logical_foo3();
+int test_logical_bar() {
+ int x = 0;
+ (x = test_logical_foo1()) || // no-warning
+ (x = test_logical_foo2()) || // no-warning
+ (x = test_logical_foo3()); // no-warning
+ return x;
+}
+
diff --git a/test/Sema/warn-write-strings.c b/test/Sema/warn-write-strings.c
index 938f0be7721fc..04af00ca2d835 100644
--- a/test/Sema/warn-write-strings.c
+++ b/test/Sema/warn-write-strings.c
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -verify -fsyntax-only -Wwrite-strings %s
// PR4804
-char* x = "foo"; // expected-warning {{initializing 'char const [4]' discards qualifiers, expected 'char *'}}
+char* x = "foo"; // expected-warning {{initializing 'char *' with an expression of type 'char const [4]' discards qualifiers}}
diff --git a/test/Sema/x86-builtin-palignr.c b/test/Sema/x86-builtin-palignr.c
new file mode 100644
index 0000000000000..eedf99bdfb6f6
--- /dev/null
+++ b/test/Sema/x86-builtin-palignr.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -target-feature +ssse3 -verify %s
+// Temporarily xfail this on windows.
+// XFAIL: win32
+
+#include <tmmintrin.h>
+
+__m64 foo(__m64 a, __m64 b, int c)
+{
+ return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}}
+}