aboutsummaryrefslogtreecommitdiff
path: root/test/Sema
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-12-30 11:49:41 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-12-30 11:49:41 +0000
commit45b533945f0851ec234ca846e1af5ee1e4df0b6e (patch)
tree0a5b74c0b9ca73aded34df95c91fcaf3815230d8 /test/Sema
parent7e86edd64bfae4e324224452e4ea879b3371a4bd (diff)
downloadsrc-45b533945f0851ec234ca846e1af5ee1e4df0b6e.tar.gz
src-45b533945f0851ec234ca846e1af5ee1e4df0b6e.zip
Vendor import of clang trunk r256633:vendor/clang/clang-trunk-r256633
Notes
Notes: svn path=/vendor/clang/dist/; revision=292920 svn path=/vendor/clang/clang-trunk-r256633/; revision=292923; tag=vendor/clang/clang-trunk-r256633
Diffstat (limited to 'test/Sema')
-rw-r--r--test/Sema/128bitint.c18
-rw-r--r--test/Sema/MicrosoftCompatibility.c2
-rw-r--r--test/Sema/address_spaces.c5
-rw-r--r--test/Sema/asm-label.c30
-rw-r--r--test/Sema/asm.c43
-rw-r--r--test/Sema/atomic-compare.c2
-rw-r--r--test/Sema/atomic-ops.c45
-rw-r--r--test/Sema/attr-availability-app-extensions.c10
-rw-r--r--test/Sema/attr-availability-tvos.c59
-rw-r--r--test/Sema/attr-availability-watchos.c54
-rw-r--r--test/Sema/attr-capabilities.c8
-rw-r--r--test/Sema/attr-coldhot.c6
-rw-r--r--test/Sema/attr-disable-tail-calls.c13
-rw-r--r--test/Sema/attr-flag-enum.c2
-rw-r--r--test/Sema/attr-mode-vector-types.c10
-rw-r--r--test/Sema/attr-notail.c14
-rw-r--r--test/Sema/attr-ownership.c10
-rw-r--r--test/Sema/auto-type.c26
-rw-r--r--test/Sema/bitfield.c10
-rw-r--r--test/Sema/bool-compare.c2
-rw-r--r--test/Sema/builtin-longjmp.c1
-rw-r--r--test/Sema/builtins-arm.c34
-rw-r--r--test/Sema/builtins-overflow.c22
-rw-r--r--test/Sema/callingconv-iamcu.c53
-rw-r--r--test/Sema/const-eval.c8
-rw-r--r--test/Sema/dllexport.c5
-rw-r--r--test/Sema/dllimport.c5
-rw-r--r--test/Sema/enable_if.c33
-rw-r--r--test/Sema/enum.c6
-rw-r--r--test/Sema/exprs.c1
-rw-r--r--test/Sema/ext_vector_casts.c12
-rw-r--r--test/Sema/ext_vector_conversions.c19
-rw-r--r--test/Sema/fn-ptr-as-fn-prototype.c2
-rw-r--r--test/Sema/function-redecl.c2
-rw-r--r--test/Sema/generic-selection.c8
-rw-r--r--test/Sema/inline-asm-validate-amdgpu.cl14
-rw-r--r--test/Sema/inline-asm-validate-x86.c26
-rw-r--r--test/Sema/inline.c2
-rw-r--r--test/Sema/internal_linkage.c21
-rw-r--r--test/Sema/mips-interrupt-attr.c29
-rw-r--r--test/Sema/ms_bitfield_layout.c220
-rw-r--r--test/Sema/ms_class_layout.cpp11
-rw-r--r--test/Sema/non-null-warning.c3
-rw-r--r--test/Sema/nonnull.c22
-rw-r--r--test/Sema/nullability.c7
-rw-r--r--test/Sema/overloadable.c14
-rw-r--r--test/Sema/parentheses.c20
-rw-r--r--test/Sema/pass-object-size.c52
-rw-r--r--test/Sema/pointer-addition.c10
-rw-r--r--test/Sema/redefine_extname.c6
-rw-r--r--test/Sema/short-enums.c2
-rw-r--r--test/Sema/struct-packed-align.c23
-rw-r--r--test/Sema/switch-1.c42
-rw-r--r--test/Sema/thread-specifier.c4
-rw-r--r--test/Sema/unused-expr.c8
-rw-r--r--test/Sema/varargs-win64.c6
-rw-r--r--test/Sema/varargs-x86-32.c5
-rw-r--r--test/Sema/varargs-x86-64.c72
-rw-r--r--test/Sema/vector-cast.c8
-rw-r--r--test/Sema/warn-absolute-value.c20
-rw-r--r--test/Sema/warn-double-promotion.c34
-rw-r--r--test/Sema/warn-extern-main.c56
-rw-r--r--test/Sema/warn-logical-not-compare.c204
-rw-r--r--test/Sema/warn-overlap.c34
-rw-r--r--test/Sema/warn-sizeof-arrayarg.c6
-rw-r--r--test/Sema/warn-thread-safety-analysis.c3
-rw-r--r--test/Sema/zvector.c148
67 files changed, 1470 insertions, 242 deletions
diff --git a/test/Sema/128bitint.c b/test/Sema/128bitint.c
index 6469d84c7cc5..45e1cd8d57ff 100644
--- a/test/Sema/128bitint.c
+++ b/test/Sema/128bitint.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 -fms-extensions %s -DHAVE
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu -fms-extensions %s -DHAVE_NOT
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 %s -DHAVE
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu %s -DHAVE_NOT
#ifdef HAVE
typedef int i128 __attribute__((__mode__(TI)));
@@ -17,28 +17,14 @@ __int128 i = (__int128)0;
unsigned __int128 u = (unsigned __int128)-1;
long long SignedTooBig = 123456789012345678901234567890; // expected-error {{integer literal is too large to be represented in any integer type}}
-__int128_t Signed128 = 123456789012345678901234567890i128;
-long long Signed64 = 123456789012345678901234567890i128; // expected-warning {{implicit conversion from '__int128' to 'long long' changes value from 123456789012345678901234567890 to -4362896299872285998}}
unsigned long long UnsignedTooBig = 123456789012345678901234567890; // expected-error {{integer literal is too large to be represented in any integer type}}
-__uint128_t Unsigned128 = 123456789012345678901234567890Ui128;
-unsigned long long Unsigned64 = 123456789012345678901234567890Ui128; // expected-warning {{implicit conversion from 'unsigned __int128' to 'unsigned long long' changes value from 123456789012345678901234567890 to 14083847773837265618}}
-
-// Ensure we don't crash when user passes 128-bit values to type safety
-// attributes.
-void pointer_with_type_tag_arg_num_1(void *buf, int datatype)
- __attribute__(( pointer_with_type_tag(mpi,0x10000000000000001i128,1) )); // expected-error {{attribute parameter 2 is out of bounds}}
-
-void pointer_with_type_tag_arg_num_2(void *buf, int datatype)
- __attribute__(( pointer_with_type_tag(mpi,1,0x10000000000000001i128) )); // expected-error {{attribute parameter 3 is out of bounds}}
void MPI_Send(void *buf, int datatype) __attribute__(( pointer_with_type_tag(mpi,1,2) ));
-static const __uint128_t mpi_int_wrong __attribute__(( type_tag_for_datatype(mpi,int) )) = 0x10000000000000001i128; // expected-error {{'type_tag_for_datatype' attribute requires the initializer to be an integer constant expression that can be represented by a 64 bit integer}}
static const int mpi_int __attribute__(( type_tag_for_datatype(mpi,int) )) = 10;
void test(int *buf)
{
- MPI_Send(buf, 0x10000000000000001i128); // expected-warning {{implicit conversion from '__int128' to 'int' changes value}}
}
#else
diff --git a/test/Sema/MicrosoftCompatibility.c b/test/Sema/MicrosoftCompatibility.c
index 010033bba00c..697d3f216637 100644
--- a/test/Sema/MicrosoftCompatibility.c
+++ b/test/Sema/MicrosoftCompatibility.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility -triple i686-pc-win32
enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
enum ENUM1 var1 = 3;
diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c
index 4756af9d9528..1922c8ae4f6f 100644
--- a/test/Sema/address_spaces.c
+++ b/test/Sema/address_spaces.c
@@ -67,3 +67,8 @@ void access_as_field()
typedef int PR4997 __attribute__((address_space(Foobar))); // expected-error {{use of undeclared identifier 'Foobar'}}
__attribute__((address_space("12"))) int *i; // expected-error {{'address_space' attribute requires an integer constant}}
+
+// Clang extension doesn't forbid operations on pointers to different address spaces.
+char* cmp(_AS1 char *x, _AS2 char *y) {
+ return x < y ? x : y; // expected-warning {{pointer type mismatch ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *')}}
+} \ No newline at end of file
diff --git a/test/Sema/asm-label.c b/test/Sema/asm-label.c
new file mode 100644
index 000000000000..87cda2f5335c
--- /dev/null
+++ b/test/Sema/asm-label.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -verify %s
+
+void f();
+void f() __asm__("fish");
+void g();
+
+void f() {
+ g();
+}
+void g() __asm__("gold"); // expected-error{{cannot apply asm label to function after its first use}}
+
+void h() __asm__("hose"); // expected-note{{previous declaration is here}}
+void h() __asm__("hair"); // expected-error{{conflicting asm label}}
+
+int x;
+int x __asm__("xenon");
+int y;
+
+int test() { return y; }
+
+int y __asm__("yacht"); // expected-error{{cannot apply asm label to variable after its first use}}
+
+int z __asm__("zebra"); // expected-note{{previous declaration is here}}
+int z __asm__("zooms"); // expected-error{{conflicting asm label}}
+
+
+// No diagnostics on the following.
+void __real_readlink() __asm("readlink");
+void readlink() __asm("__protected_readlink");
+void readlink() { __real_readlink(); }
diff --git a/test/Sema/asm.c b/test/Sema/asm.c
index 1a1e02993a72..d29b136a117a 100644
--- a/test/Sema/asm.c
+++ b/test/Sema/asm.c
@@ -1,7 +1,6 @@
// RUN: %clang_cc1 %s -Wno-private-extern -triple i386-pc-linux-gnu -verify -fsyntax-only
-
void f() {
int i;
@@ -154,10 +153,13 @@ double test15() {
// PR19837
struct foo {
int a;
- char b;
};
-register struct foo bar asm("sp"); // expected-error {{bad type for named register variable}}
-register float baz asm("sp"); // expected-error {{bad type for named register variable}}
+register struct foo bar asm("esp"); // expected-error {{bad type for named register variable}}
+register float baz asm("esp"); // expected-error {{bad type for named register variable}}
+
+register int r0 asm ("edi"); // expected-error {{register 'edi' unsuitable for global register variables on this target}}
+register long long r1 asm ("esp"); // expected-error {{size of register 'esp' does not match variable size}}
+register int r2 asm ("esp");
double f_output_constraint(void) {
double result;
@@ -211,13 +213,40 @@ typedef struct test16_foo {
unsigned int field2 : 2;
unsigned int field3 : 3;
} test16_foo;
-test16_foo x;
+typedef __attribute__((vector_size(16))) int test16_bar;
+register int test16_baz asm("esp");
+
void test16()
{
+ test16_foo a;
+ test16_bar b;
+
+ __asm__("movl $5, %0"
+ : "=rm" (a.field2)); // expected-error {{reference to a bit-field in asm input with a memory constraint '=rm'}}
+ __asm__("movl $5, %0"
+ :
+ : "m" (a.field3)); // expected-error {{reference to a bit-field in asm output with a memory constraint 'm'}}
__asm__("movl $5, %0"
- : "=rm" (x.field2)); // expected-error {{reference to a bit-field in asm output with a memory constraint '=rm'}}
+ : "=rm" (b[2])); // expected-error {{reference to a vector element in asm input with a memory constraint '=rm'}}
__asm__("movl $5, %0"
:
- : "m" (x.field3)); // expected-error {{reference to a bit-field in asm input with a memory constraint 'm'}}
+ : "m" (b[3])); // expected-error {{reference to a vector element in asm output with a memory constraint 'm'}}
+ __asm__("movl $5, %0"
+ : "=rm" (test16_baz)); // expected-error {{reference to a global register variable in asm input with a memory constraint '=rm'}}
+ __asm__("movl $5, %0"
+ :
+ : "m" (test16_baz)); // expected-error {{reference to a global register variable in asm output with a memory constraint 'm'}}
+}
+
+int test17(int t0)
+{
+ int r0, r1;
+ __asm ("addl %2, %2\n\t"
+ "movl $123, %0"
+ : "=a" (r0),
+ "=&r" (r1)
+ : "1" (t0), // expected-note {{constraint '1' is already present here}}
+ "1" (t0)); // expected-error {{more than one input constraint matches the same output '1'}}
+ return r0 + r1;
}
diff --git a/test/Sema/atomic-compare.c b/test/Sema/atomic-compare.c
index 01eb82004725..9e7555d57f5a 100644
--- a/test/Sema/atomic-compare.c
+++ b/test/Sema/atomic-compare.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wno-logical-not-parentheses
void f(_Atomic(int) a, _Atomic(int) b) {
if (a > b) {} // no warning
diff --git a/test/Sema/atomic-ops.c b/test/Sema/atomic-ops.c
index 71eaaa8b7a5b..9a37ec2a3876 100644
--- a/test/Sema/atomic-ops.c
+++ b/test/Sema/atomic-ops.c
@@ -85,41 +85,57 @@ _Static_assert(__atomic_always_lock_free(4, &i64), "");
_Static_assert(!__atomic_always_lock_free(8, &i32), "");
_Static_assert(__atomic_always_lock_free(8, &i64), "");
-void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d,
- int *I, int **P, float *D, struct S *s1, struct S *s2) {
+#define _AS1 __attribute__((address_space(1)))
+#define _AS2 __attribute__((address_space(2)))
+
+void f(_Atomic(int) *i, const _Atomic(int) *ci,
+ _Atomic(int*) *p, _Atomic(float) *d,
+ int *I, const int *CI,
+ int **P, float *D, struct S *s1, struct S *s2) {
__c11_atomic_init(I, 5); // expected-error {{pointer to _Atomic}}
+ __c11_atomic_init(ci, 5); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
+
__c11_atomic_load(0); // expected-error {{too few arguments to function}}
__c11_atomic_load(0,0,0); // expected-error {{too many arguments to function}}
__c11_atomic_store(0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}}
__c11_atomic_store((int*)0,0,0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
+ __c11_atomic_store(i, 0, memory_order_relaxed);
+ __c11_atomic_store(ci, 0, memory_order_relaxed); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
__c11_atomic_load(i, memory_order_seq_cst);
__c11_atomic_load(p, memory_order_seq_cst);
__c11_atomic_load(d, memory_order_seq_cst);
+ __c11_atomic_load(ci, memory_order_seq_cst); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
int load_n_1 = __atomic_load_n(I, memory_order_relaxed);
int *load_n_2 = __atomic_load_n(P, memory_order_relaxed);
float load_n_3 = __atomic_load_n(D, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
__atomic_load_n(s1, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
+ load_n_1 = __atomic_load_n(CI, memory_order_relaxed);
__atomic_load(i, I, memory_order_relaxed); // expected-error {{must be a pointer to a trivially-copyable type}}
+ __atomic_load(CI, I, memory_order_relaxed);
+
__atomic_load(I, i, memory_order_relaxed); // expected-warning {{passing '_Atomic(int) *' to parameter of type 'int *'}}
__atomic_load(I, *P, memory_order_relaxed);
__atomic_load(I, *P, memory_order_relaxed, 42); // expected-error {{too many arguments}}
(int)__atomic_load(I, I, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
__atomic_load(s1, s2, memory_order_acquire);
-
+ (void)__atomic_load(I, CI, memory_order_relaxed); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
__c11_atomic_store(i, 1, memory_order_seq_cst);
__c11_atomic_store(p, 1, memory_order_seq_cst); // expected-warning {{incompatible integer to pointer conversion}}
(int)__c11_atomic_store(d, 1, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
__atomic_store_n(I, 4, memory_order_release);
__atomic_store_n(I, 4.0, memory_order_release);
+ __atomic_store_n(CI, 4, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
__atomic_store_n(I, P, memory_order_release); // expected-warning {{parameter of type 'int'}}
__atomic_store_n(i, 1, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
__atomic_store_n(s1, *s2, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
+ __atomic_store_n(I, I, memory_order_release); // expected-warning {{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; dereference with *}}
__atomic_store(I, *P, memory_order_release);
+ __atomic_store(CI, I, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
__atomic_store(s1, s2, memory_order_release);
__atomic_store(i, I, memory_order_release); // expected-error {{trivially-copyable}}
@@ -131,6 +147,9 @@ void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d,
__atomic_exchange(s1, s2, s2, memory_order_seq_cst);
__atomic_exchange(s1, I, P, memory_order_seq_cst); // expected-warning 2{{parameter of type 'struct S *'}}
(int)__atomic_exchange(s1, s2, s2, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+ __atomic_exchange(I, I, I, memory_order_seq_cst);
+ __atomic_exchange(CI, I, I, memory_order_seq_cst); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
+ __atomic_exchange(I, I, CI, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
__c11_atomic_fetch_add(i, 1, memory_order_seq_cst);
__c11_atomic_fetch_add(p, 1, memory_order_seq_cst);
@@ -155,14 +174,27 @@ void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d,
_Bool cmpexch_1 = __c11_atomic_compare_exchange_strong(i, 0, 1, memory_order_seq_cst, memory_order_seq_cst);
_Bool cmpexch_2 = __c11_atomic_compare_exchange_strong(p, 0, (int*)1, memory_order_seq_cst, memory_order_seq_cst);
_Bool cmpexch_3 = __c11_atomic_compare_exchange_strong(d, (int*)0, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}}
+ (void)__c11_atomic_compare_exchange_strong(i, CI, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
+
+ _Bool cmpexchw_1 = __c11_atomic_compare_exchange_weak(i, 0, 1, memory_order_seq_cst, memory_order_seq_cst);
+ _Bool cmpexchw_2 = __c11_atomic_compare_exchange_weak(p, 0, (int*)1, memory_order_seq_cst, memory_order_seq_cst);
+ _Bool cmpexchw_3 = __c11_atomic_compare_exchange_weak(d, (int*)0, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}}
+ (void)__c11_atomic_compare_exchange_weak(i, CI, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
_Bool cmpexch_4 = __atomic_compare_exchange_n(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst);
_Bool cmpexch_5 = __atomic_compare_exchange_n(I, P, 5, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
_Bool cmpexch_6 = __atomic_compare_exchange_n(I, I, P, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int **' to parameter of type 'int'}}
+ (void)__atomic_compare_exchange_n(CI, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
+ (void)__atomic_compare_exchange_n(I, CI, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
_Bool cmpexch_7 = __atomic_compare_exchange(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int' to parameter of type 'int *'}}
_Bool cmpexch_8 = __atomic_compare_exchange(I, P, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
_Bool cmpexch_9 = __atomic_compare_exchange(I, I, I, 0, memory_order_seq_cst, memory_order_seq_cst);
+ (void)__atomic_compare_exchange(CI, I, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
+ (void)__atomic_compare_exchange(I, CI, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
+
+ // Pointers to different address spaces are allowed.
+ _Bool cmpexch_10 = __c11_atomic_compare_exchange_strong((_Atomic int _AS1 *)0x308, (int _AS2 *)0x309, 1, memory_order_seq_cst, memory_order_seq_cst);
const volatile int flag_k = 0;
volatile int flag = 0;
@@ -172,10 +204,9 @@ void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d,
__atomic_clear(&flag, memory_order_seq_cst);
(int)__atomic_clear(&flag, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
- const _Atomic(int) const_atomic;
- __c11_atomic_init(&const_atomic, 0); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
- __c11_atomic_store(&const_atomic, 0, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
- __c11_atomic_load(&const_atomic, memory_order_acquire); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
+ __c11_atomic_init(ci, 0); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
+ __c11_atomic_store(ci, 0, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
+ __c11_atomic_load(ci, memory_order_acquire); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
// Ensure the <stdatomic.h> macros behave appropriately.
atomic_int n = ATOMIC_VAR_INIT(123);
diff --git a/test/Sema/attr-availability-app-extensions.c b/test/Sema/attr-availability-app-extensions.c
index a84709281938..8f9dcbc763d1 100644
--- a/test/Sema/attr-availability-app-extensions.c
+++ b/test/Sema/attr-availability-app-extensions.c
@@ -1,14 +1,24 @@
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -fsyntax-only -fapplication-extension %s -verify
// RUN: %clang_cc1 -triple armv7-apple-ios9.0 -fsyntax-only -fapplication-extension %s -verify
+// RUN: %clang_cc1 -triple arm64-apple-tvos3.0 -fsyntax-only -fapplication-extension -DTVOS=1 -verify %s
+// RUN: %clang_cc1 -triple arm64-apple-tvos3.0 -fsyntax-only -fapplication-extension -verify %s
#if __has_feature(attribute_availability_app_extension)
__attribute__((availability(macosx_app_extension,unavailable)))
+#ifndef TVOS
__attribute__((availability(ios_app_extension,unavailable)))
+#else
+ __attribute__((availability(tvos_app_extension,unavailable)))
+#endif
#endif
void f0(int); // expected-note {{'f0' has been explicitly marked unavailable here}}
__attribute__((availability(macosx,unavailable)))
+#ifndef TVOS
__attribute__((availability(ios,unavailable)))
+#else
+ __attribute__((availability(tvos,unavailable)))
+#endif
void f1(int); // expected-note {{'f1' has been explicitly marked unavailable here}}
void test() {
diff --git a/test/Sema/attr-availability-tvos.c b/test/Sema/attr-availability-tvos.c
new file mode 100644
index 000000000000..b60fdb0d19cc
--- /dev/null
+++ b/test/Sema/attr-availability-tvos.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 "-triple" "x86_64-apple-tvos3.0" -fsyntax-only -verify %s
+
+void f0(int) __attribute__((availability(tvos,introduced=2.0,deprecated=2.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}
+void f1(int) __attribute__((availability(tvos,introduced=2.1)));
+void f2(int) __attribute__((availability(tvos,introduced=2.0,deprecated=3.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}
+void f3(int) __attribute__((availability(tvos,introduced=3.0)));
+void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(tvos,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}
+
+void f5(int) __attribute__((availability(tvos,introduced=2.0))) __attribute__((availability(tvos,deprecated=3.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
+void f6(int) __attribute__((availability(tvos,deprecated=3.0)));
+void f6(int) __attribute__((availability(tvos,introduced=2.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
+
+void test() {
+ f0(0); // expected-warning{{'f0' is deprecated: first deprecated in tvOS 2.1}}
+ f1(0);
+ f2(0); // expected-warning{{'f2' is deprecated: first deprecated in tvOS 3.0}}
+ f3(0);
+ f4(0); // expected-error{{f4' is unavailable: obsoleted in tvOS 3.0}}
+ f5(0); // expected-warning{{'f5' is deprecated: first deprecated in tvOS 3.0}}
+ f6(0); // expected-warning{{'f6' is deprecated: first deprecated in tvOS 3.0}}
+}
+
+// Anything iOS later than 8 does not apply to tvOS.
+void f9(int) __attribute__((availability(ios,introduced=2.0,deprecated=9.0)));
+
+void test_transcribed_availability() {
+ f9(0);
+}
+
+// Test tvOS specific attributes.
+void f0_tvos(int) __attribute__((availability(tvos,introduced=2.0,deprecated=2.1))); // expected-note {{'f0_tvos' has been explicitly marked deprecated here}}
+void f1_tvos(int) __attribute__((availability(tvos,introduced=2.1)));
+void f2_tvos(int) __attribute__((availability(tvos,introduced=2.0,deprecated=3.0))); // expected-note {{'f2_tvos' has been explicitly marked deprecated here}}
+void f3_tvos(int) __attribute__((availability(tvos,introduced=3.0)));
+void f4_tvos(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(tvos,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}
+void f5_tvos(int) __attribute__((availability(tvos,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0)));
+void f5_attr_reversed_tvos(int) __attribute__((availability(ios, deprecated=3.0))) __attribute__((availability(tvos,introduced=2.0)));
+void f5b_tvos(int) __attribute__((availability(tvos,introduced=2.0))) __attribute__((availability(tvos,deprecated=3.0))); // expected-note {{'f5b_tvos' has been explicitly marked deprecated here}}
+void f5c_tvos(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f5c_tvos' has been explicitly marked deprecated here}}
+void f6_tvos(int) __attribute__((availability(tvos,deprecated=3.0)));
+void f6_tvos(int) __attribute__((availability(tvos,introduced=2.0))); // expected-note {{'f6_tvos' has been explicitly marked deprecated here}}
+
+void test_tvos() {
+ f0_tvos(0); // expected-warning{{'f0_tvos' is deprecated: first deprecated in tvOS 2.1}}
+ f1_tvos(0);
+ f2_tvos(0); // expected-warning{{'f2_tvos' is deprecated: first deprecated in tvOS 3.0}}
+ f3_tvos(0);
+ f4_tvos(0); // expected-error{{'f4_tvos' is unavailable: obsoleted in tvOS 3.0}}
+ // We get no warning here because any explicit 'tvos' availability causes
+ // the ios availablity to not implicitly become 'tvos' availability. Otherwise we'd get
+ // a deprecated warning.
+ f5_tvos(0); // no-warning
+ f5_attr_reversed_tvos(0); // no-warning
+ // We get a deprecated warning here because both attributes are explicitly 'tvos'.
+ f5b_tvos(0); // expected-warning {{'f5b_tvos' is deprecated: first deprecated in tvOS 3.0}}
+ // We get a deprecated warning here because both attributes are 'ios' (both get mapped to 'tvos').
+ f5c_tvos(0); // expected-warning {{'f5c_tvos' is deprecated: first deprecated in tvOS 3.0}}
+ f6_tvos(0); // expected-warning{{'f6_tvos' is deprecated: first deprecated in tvOS 3.0}}
+}
diff --git a/test/Sema/attr-availability-watchos.c b/test/Sema/attr-availability-watchos.c
new file mode 100644
index 000000000000..cb9f968bd6ab
--- /dev/null
+++ b/test/Sema/attr-availability-watchos.c
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 "-triple" "arm64-apple-watchos3.0" -fsyntax-only -verify %s
+
+void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}
+void f1(int) __attribute__((availability(ios,introduced=2.1)));
+void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}
+void f3(int) __attribute__((availability(ios,introduced=3.0)));
+void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}
+void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
+void f6(int) __attribute__((availability(ios,deprecated=12.1))); // OK - not deprecated for watchOS
+void f7(int) __attribute__((availability(ios,deprecated=8.3))); // expected-note {{'f7' has been explicitly marked deprecated here}}
+void f8(int) __attribute__((availability(ios,introduced=2.0,obsoleted=10.0))); // expected-note {{explicitly marked unavailable}}
+
+void test() {
+ f0(0); // expected-warning{{'f0' is deprecated: first deprecated in watchOS 2.0}}
+ f1(0);
+ f2(0); // expected-warning{{'f2' is deprecated: first deprecated in watchOS 2.0}}
+ f3(0);
+ f4(0); // expected-error {{f4' is unavailable: obsoleted in watchOS 2.0}}
+ f5(0); // expected-warning {{'f5' is deprecated: first deprecated in watchOS 2.0}}
+ f6(0);
+ f7(0); // expected-warning {{'f7' is deprecated: first deprecated in watchOS 2.0}}
+ f8(0); // expected-error {{'f8' is unavailable: obsoleted in watchOS 3.0}}
+}
+
+// Test watchOS specific attributes.
+void f0_watchos(int) __attribute__((availability(watchos,introduced=2.0,deprecated=2.1))); // expected-note {{'f0_watchos' has been explicitly marked deprecated here}}
+void f1_watchos(int) __attribute__((availability(watchos,introduced=2.1)));
+void f2_watchos(int) __attribute__((availability(watchos,introduced=2.0,deprecated=3.0))); // expected-note {{'f2_watchos' has been explicitly marked deprecated here}}
+void f3_watchos(int) __attribute__((availability(watchos,introduced=3.0)));
+void f4_watchos(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(watchos,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}
+void f5_watchos(int) __attribute__((availability(watchos,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0)));
+void f5_attr_reversed_watchos(int) __attribute__((availability(ios, deprecated=3.0))) __attribute__((availability(watchos,introduced=2.0)));
+void f5b_watchos(int) __attribute__((availability(watchos,introduced=2.0))) __attribute__((availability(watchos,deprecated=3.0))); // expected-note {{'f5b_watchos' has been explicitly marked deprecated here}}
+void f5c_watchos(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f5c_watchos' has been explicitly marked deprecated here}}
+void f6_watchos(int) __attribute__((availability(watchos,deprecated=3.0)));
+void f6_watchos(int) __attribute__((availability(watchos,introduced=2.0))); // expected-note {{'f6_watchos' has been explicitly marked deprecated here}}
+
+void test_watchos() {
+ f0_watchos(0); // expected-warning{{'f0_watchos' is deprecated: first deprecated in watchOS 2.1}}
+ f1_watchos(0);
+ f2_watchos(0); // expected-warning{{'f2_watchos' is deprecated: first deprecated in watchOS 3.0}}
+ f3_watchos(0);
+ f4_watchos(0); // expected-error{{'f4_watchos' is unavailable: obsoleted in watchOS 3.0}}
+ // We get no warning here because any explicit 'watchos' availability causes
+ // the ios availablity to not implicitly become 'watchos' availability. Otherwise we'd get
+ // a deprecated warning.
+ f5_watchos(0); // no-warning
+ f5_attr_reversed_watchos(0); // no-warning
+ // We get a deprecated warning here because both attributes are explicitly 'watchos'.
+ f5b_watchos(0); // expected-warning {{'f5b_watchos' is deprecated: first deprecated in watchOS 3.0}}
+ // We get a deprecated warning here because both attributes are 'ios' (both get mapped to 'watchos').
+ f5c_watchos(0); // expected-warning {{'f5c_watchos' is deprecated: first deprecated in watchOS 2.0}}
+ f6_watchos(0); // expected-warning {{'f6_watchos' is deprecated: first deprecated in watchOS 3.0}}
+}
diff --git a/test/Sema/attr-capabilities.c b/test/Sema/attr-capabilities.c
index 5bfbdacf508f..89967704865f 100644
--- a/test/Sema/attr-capabilities.c
+++ b/test/Sema/attr-capabilities.c
@@ -4,11 +4,15 @@ typedef int __attribute__((capability("role"))) ThreadRole;
struct __attribute__((shared_capability("mutex"))) Mutex {};
struct NotACapability {};
+// Put capability attributes on unions
+union __attribute__((capability("mutex"))) MutexUnion { int a; char* b; };
+typedef union { int a; char* b; } __attribute__((capability("mutex"))) MutexUnion2;
+
// Test an invalid capability name
struct __attribute__((capability("wrong"))) IncorrectName {}; // expected-warning {{invalid capability name 'wrong'; capability name must be 'mutex' or 'role'}}
-int Test1 __attribute__((capability("test1"))); // expected-error {{'capability' attribute only applies to structs and typedefs}}
-int Test2 __attribute__((shared_capability("test2"))); // expected-error {{'shared_capability' attribute only applies to structs and typedefs}}
+int Test1 __attribute__((capability("test1"))); // expected-error {{'capability' attribute only applies to structs, unions, and typedefs}}
+int Test2 __attribute__((shared_capability("test2"))); // expected-error {{'shared_capability' attribute only applies to structs, unions, and typedefs}}
int Test3 __attribute__((acquire_capability("test3"))); // expected-warning {{'acquire_capability' attribute only applies to functions}}
int Test4 __attribute__((try_acquire_capability("test4"))); // expected-error {{'try_acquire_capability' attribute only applies to functions}}
int Test5 __attribute__((release_capability("test5"))); // expected-warning {{'release_capability' attribute only applies to functions}}
diff --git a/test/Sema/attr-coldhot.c b/test/Sema/attr-coldhot.c
index abadf889fc63..972f5a5266aa 100644
--- a/test/Sema/attr-coldhot.c
+++ b/test/Sema/attr-coldhot.c
@@ -6,5 +6,7 @@ int bar() __attribute__((__cold__));
int var1 __attribute__((__cold__)); // expected-warning{{'__cold__' attribute only applies to functions}}
int var2 __attribute__((__hot__)); // expected-warning{{'__hot__' attribute only applies to functions}}
-int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}}
-int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}}
+int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}} \
+// expected-note{{conflicting attribute is here}}
+int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}} \
+// expected-note{{conflicting attribute is here}}
diff --git a/test/Sema/attr-disable-tail-calls.c b/test/Sema/attr-disable-tail-calls.c
new file mode 100644
index 000000000000..4574d5e0b66b
--- /dev/null
+++ b/test/Sema/attr-disable-tail-calls.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void __attribute__((disable_tail_calls,naked)) foo1(int a) { // expected-error {{'disable_tail_calls' and 'naked' attributes are not compatible}} expected-note {{conflicting attribute is here}}
+ __asm__("");
+}
+
+void __attribute__((naked,disable_tail_calls)) foo2(int a) { // expected-error {{'naked' and 'disable_tail_calls' attributes are not compatible}} expected-note {{conflicting attribute is here}}
+ __asm__("");
+}
+
+int g0 __attribute__((disable_tail_calls)); // expected-warning {{'disable_tail_calls' attribute only applies to functions and methods}}
+
+int foo3(int a) __attribute__((disable_tail_calls("abc"))); // expected-error {{'disable_tail_calls' attribute takes no arguments}}
diff --git a/test/Sema/attr-flag-enum.c b/test/Sema/attr-flag-enum.c
index a53c1dc8e7d1..ae3e3ad5ab99 100644
--- a/test/Sema/attr-flag-enum.c
+++ b/test/Sema/attr-flag-enum.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -std=c11 -Wassign-enum %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -verify -fsyntax-only -std=c11 -Wassign-enum %s
enum __attribute__((flag_enum)) flag {
ea = 0x1,
diff --git a/test/Sema/attr-mode-vector-types.c b/test/Sema/attr-mode-vector-types.c
index 3893922a6a6d..15674412f156 100644
--- a/test/Sema/attr-mode-vector-types.c
+++ b/test/Sema/attr-mode-vector-types.c
@@ -9,6 +9,14 @@ typedef float __attribute__((mode(SF))) __attribute__((vector_size(256))) vec_t5
typedef float __attribute__((mode(DF))) __attribute__((vector_size(256))) vec_t6;
typedef float __attribute__((mode(XF))) __attribute__((vector_size(256))) vec_t7;
+typedef int v8qi __attribute__ ((mode(QI))) __attribute__ ((vector_size(8)));
+typedef int v8qi __attribute__ ((mode(V8QI)));
+// expected-warning@-1{{specifying vector types with the 'mode' attribute is deprecated; use the 'vector_size' attribute instead}}
+
+typedef float v4sf __attribute__((mode(V4SF)));
+// expected-warning@-1{{specifying vector types with the 'mode' attribute is deprecated; use the 'vector_size' attribute instead}}
+typedef float v4sf __attribute__((mode(SF))) __attribute__ ((vector_size(16)));
+
// Incorrect cases.
typedef float __attribute__((mode(QC))) __attribute__((vector_size(256))) vec_t8;
// expected-error@-1{{unsupported machine mode 'QC'}}
@@ -24,3 +32,5 @@ typedef float __attribute__((mode(DC))) __attribute__((vector_size(256))) vec_t1
// expected-error@-2{{type of machine mode does not support base vector types}}
typedef _Complex float __attribute__((mode(XC))) __attribute__((vector_size(256))) vec_t12;
// expected-error@-1{{invalid vector element type '_Complex float'}}
+typedef int __attribute__((mode(V3QI))) v3qi;
+// expected-error@-1{{unknown machine mode 'V3QI'}}
diff --git a/test/Sema/attr-notail.c b/test/Sema/attr-notail.c
new file mode 100644
index 000000000000..4d05fcf6f2c0
--- /dev/null
+++ b/test/Sema/attr-notail.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int callee0() __attribute__((not_tail_called,always_inline)); // expected-error{{'not_tail_called' and 'always_inline' attributes are not compatible}} \
+// expected-note{{conflicting attribute is here}}
+int callee1() __attribute__((always_inline,not_tail_called)); // expected-error{{'always_inline' and 'not_tail_called' attributes are not compatible}} \
+// expected-note{{conflicting attribute is here}}
+
+int foo(int a) {
+ return a ? callee0() : callee1();
+}
+
+int g0 __attribute__((not_tail_called)); // expected-warning {{'not_tail_called' attribute only applies to functions}}
+
+int foo2(int a) __attribute__((not_tail_called("abc"))); // expected-error {{'not_tail_called' attribute takes no arguments}}
diff --git a/test/Sema/attr-ownership.c b/test/Sema/attr-ownership.c
index d2e48c65a23c..f7969d4af93c 100644
--- a/test/Sema/attr-ownership.c
+++ b/test/Sema/attr-ownership.c
@@ -9,7 +9,7 @@ void f6(void) __attribute__((ownership_holds(foo, 1, 2, 3))); // expected-error
void f7(void) __attribute__((ownership_takes(foo))); // expected-error {{'ownership_takes' attribute takes at least 2 arguments}}
void f8(int *i, int *j, int k) __attribute__((ownership_holds(foo, 1, 2, 4))); // expected-error {{'ownership_holds' attribute parameter 3 is out of bounds}}
-int f9 __attribute__((ownership_takes(foo, 1))); // expected-warning {{'ownership_takes' attribute only applies to functions}}
+int f9 __attribute__((ownership_takes(foo, 1))); // expected-warning {{'ownership_takes' attribute only applies to non-K&R-style functions}}
void f10(int i) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute only applies to pointer arguments}}
void *f11(float i) __attribute__((ownership_returns(foo, 1))); // expected-error {{'ownership_returns' attribute only applies to integer arguments}}
@@ -19,6 +19,8 @@ void f13(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__(
void f14(int i, int j, int *k) __attribute__((ownership_holds(foo, 3))) __attribute__((ownership_takes(foo, 3))); // expected-error {{'ownership_holds' and 'ownership_takes' attributes are not compatible}}
void f15(int, int)
- __attribute__((ownership_returns(foo, 1))) // expected-note {{declared with index 1 here}}
- __attribute__((ownership_returns(foo, 2))); // expected-error {{'ownership_returns' attribute index does not match; here it is 2}}
-void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_holds(foo, 1))); // OK, same index
+ __attribute__((ownership_returns(foo, 1))) // expected-note {{declared with index 1 here}}
+ __attribute__((ownership_returns(foo, 2))); // expected-error {{'ownership_returns' attribute index does not match; here it is 2}}
+void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_holds(foo, 1))); // OK, same index
+void f17(void*) __attribute__((ownership_takes(__, 1)));
+void f18() __attribute__((ownership_takes(foo, 1))); // expected-warning {{'ownership_takes' attribute only applies to non-K&R-style functions}}
diff --git a/test/Sema/auto-type.c b/test/Sema/auto-type.c
new file mode 100644
index 000000000000..9fadb90c2cda
--- /dev/null
+++ b/test/Sema/auto-type.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -std=c11
+
+__auto_type a = 5; // expected-warning {{'__auto_type' is a GNU extension}}
+__extension__ __auto_type a1 = 5;
+#pragma clang diagnostic ignored "-Wgnu-auto-type"
+__auto_type b = 5.0;
+__auto_type c = &b;
+__auto_type d = (struct {int a;}) {5};
+_Static_assert(__builtin_types_compatible_p(__typeof(a), int), "");
+__auto_type e = e; // expected-error {{variable 'e' declared with '__auto_type' type cannot appear in its own initializer}}
+
+struct s { __auto_type a; }; // expected-error {{'__auto_type' not allowed in struct member}}
+
+__auto_type f = 1, g = 1.0; // expected-error {{'__auto_type' deduced as 'int' in declaration of 'f' and deduced as 'double' in declaration of 'g'}}
+
+__auto_type h() {} // expected-error {{'__auto_type' not allowed in function return type}}
+
+int i() {
+ struct bitfield { int field:2; };
+ __auto_type j = (struct bitfield){1}.field; // expected-error {{cannot pass bit-field as __auto_type initializer in C}}
+
+}
+
+int k(l)
+__auto_type l; // expected-error {{'__auto_type' not allowed in K&R-style function parameter}}
+{}
diff --git a/test/Sema/bitfield.c b/test/Sema/bitfield.c
index f214b671f6f9..810dc798eaa5 100644
--- a/test/Sema/bitfield.c
+++ b/test/Sema/bitfield.c
@@ -6,7 +6,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' (33 bits) exceeds size of its type (32 bits)}}
+ int b : 33; // expected-error{{width of bit-field 'b' (33 bits) exceeds width 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);
@@ -22,9 +22,12 @@ struct a {
int g : (_Bool)1;
// PR4017
- char : 10; // expected-error {{size of anonymous bit-field (10 bits) exceeds size of its type (8 bits)}}
+ char : 10; // expected-error {{width of anonymous bit-field (10 bits) exceeds width 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'}}
+
+ _Bool : 2; // expected-error {{width of anonymous bit-field (2 bits) exceeds width of its type (1 bit)}}
+ _Bool h : 5; // expected-error {{width of bit-field 'h' (5 bits) exceeds width of its type (1 bit)}}
};
struct b {unsigned x : 2;} x;
@@ -60,7 +63,8 @@ typedef unsigned Unsigned;
typedef signed Signed;
struct Test5 { unsigned n : 2; } t5;
-typedef __typeof__(t5.n) Unsigned; // Bitfield is unsigned
+// Bitfield is unsigned
+struct Test5 sometest5 = {-1}; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -1 to 3}}
typedef __typeof__(+t5.n) Signed; // ... but promotes to signed.
typedef __typeof__(t5.n + 0) Signed; // Arithmetic promotes.
diff --git a/test/Sema/bool-compare.c b/test/Sema/bool-compare.c
index 3f1f286a2a38..923ff4208e8b 100644
--- a/test/Sema/bool-compare.c
+++ b/test/Sema/bool-compare.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-logical-not-parentheses
void f(int x, int y, int z) {
diff --git a/test/Sema/builtin-longjmp.c b/test/Sema/builtin-longjmp.c
index 5ed393e591c9..fdfbcf861dda 100644
--- a/test/Sema/builtin-longjmp.c
+++ b/test/Sema/builtin-longjmp.c
@@ -4,7 +4,6 @@
// RUN: %clang_cc1 -triple powerpc-unknown-unknown -emit-llvm < %s| FileCheck %s
// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm < %s| FileCheck %s
-// RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm-only -verify %s
// RUN: %clang_cc1 -triple aarch64-unknown-unknown -emit-llvm-only -verify %s
// RUN: %clang_cc1 -triple mips-unknown-unknown -emit-llvm-only -verify %s
// RUN: %clang_cc1 -triple mips64-unknown-unknown -emit-llvm-only -verify %s
diff --git a/test/Sema/builtins-arm.c b/test/Sema/builtins-arm.c
index 37604dc8bd43..39cb2fa2962c 100644
--- a/test/Sema/builtins-arm.c
+++ b/test/Sema/builtins-arm.c
@@ -46,3 +46,37 @@ void test4() {
void test5() {
__builtin_arm_dbg(16); // expected-error {{argument should be a value from 0 to 15}}
}
+
+void test6(int a, int b, int c) {
+ __builtin_arm_mrc( a, 0, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
+ __builtin_arm_mrc(15, a, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
+ __builtin_arm_mrc(15, 0, a, 0, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
+ __builtin_arm_mrc(15, 0, 13, a, 3); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
+ __builtin_arm_mrc(15, 0, 13, 0, a); // expected-error {{argument to '__builtin_arm_mrc' must be a constant integer}}
+
+ __builtin_arm_mrc2( a, 0, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
+ __builtin_arm_mrc2(15, a, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
+ __builtin_arm_mrc2(15, 0, a, 0, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
+ __builtin_arm_mrc2(15, 0, 13, a, 3); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
+ __builtin_arm_mrc2(15, 0, 13, 0, a); // expected-error {{argument to '__builtin_arm_mrc2' must be a constant integer}}
+
+ __builtin_arm_mcr( a, 0, b, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
+ __builtin_arm_mcr(15, a, b, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
+ __builtin_arm_mcr(15, 0, b, a, 0, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
+ __builtin_arm_mcr(15, 0, b, 13, a, 3); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
+ __builtin_arm_mcr(15, 0, b, 13, 0, a); // expected-error {{argument to '__builtin_arm_mcr' must be a constant integer}}
+
+ __builtin_arm_mcr2( a, 0, b, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
+ __builtin_arm_mcr2(15, a, b, 13, 0, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
+ __builtin_arm_mcr2(15, 0, b, a, 0, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
+ __builtin_arm_mcr2(15, 0, b, 13, a, 3); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
+ __builtin_arm_mcr2(15, 0, b, 13, 0, a); // expected-error {{argument to '__builtin_arm_mcr2' must be a constant integer}}
+
+ __builtin_arm_mcrr( a, 0, b, c, 0); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
+ __builtin_arm_mcrr(15, a, b, c, 0); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
+ __builtin_arm_mcrr(15, 0, b, c, a); // expected-error {{argument to '__builtin_arm_mcrr' must be a constant integer}}
+
+ __builtin_arm_mcrr2( a, 0, b, c, 0); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
+ __builtin_arm_mcrr2(15, a, b, c, 0); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
+ __builtin_arm_mcrr2(15, 0, b, c, a); // expected-error {{argument to '__builtin_arm_mcrr2' must be a constant integer}}
+}
diff --git a/test/Sema/builtins-overflow.c b/test/Sema/builtins-overflow.c
new file mode 100644
index 000000000000..e2c07f08ec9f
--- /dev/null
+++ b/test/Sema/builtins-overflow.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#if __has_feature(__builtin_add_overflow)
+#warning defined as expected
+// expected-warning@-1 {{defined as expected}}
+#endif
+
+void test(void) {
+ unsigned r;
+ const char * c;
+ float f;
+ const unsigned q;
+
+ __builtin_add_overflow(); // expected-error {{too few arguments to function call, expected 3, have 0}}
+ __builtin_add_overflow(1, 1, 1, 1); // expected-error {{too many arguments to function call, expected 3, have 4}}
+
+ __builtin_add_overflow(c, 1, &r); // expected-error {{operand argument to overflow builtin must be an integer ('const char *' invalid)}}
+ __builtin_add_overflow(1, c, &r); // expected-error {{operand argument to overflow builtin must be an integer ('const char *' invalid)}}
+ __builtin_add_overflow(1, 1, 3); // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('int' invalid)}}
+ __builtin_add_overflow(1, 1, &f); // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('float *' invalid)}}
+ __builtin_add_overflow(1, 1, &q); // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('const unsigned int *' invalid)}}
+}
diff --git a/test/Sema/callingconv-iamcu.c b/test/Sema/callingconv-iamcu.c
new file mode 100644
index 000000000000..b66320ecf83b
--- /dev/null
+++ b/test/Sema/callingconv-iamcu.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-intel-elfiamcu -verify
+
+void __attribute__((fastcall)) foo(float *a) { // expected-warning {{calling convention 'fastcall' ignored for this target}}
+}
+
+void __attribute__((stdcall)) bar(float *a) { // expected-warning {{calling convention 'stdcall' ignored for this target}}
+}
+
+void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
+}
+
+void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{calling convention 'fastcall' ignored for this target}}
+}
+void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{calling convention 'stdcall' ignored for this target}}
+}
+void __attribute__((thiscall)) test4(int a, ...) { // expected-warning {{calling convention 'thiscall' ignored for this target}}
+}
+
+void __attribute__((cdecl)) ctest0() {}
+
+void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}}
+
+void (__attribute__((fastcall)) *pfoo)(float*) = foo; // expected-warning {{calling convention 'fastcall' ignored for this target}}
+
+void (__attribute__((stdcall)) *pbar)(float*) = bar; // expected-warning {{calling convention 'stdcall' ignored for this target}}
+
+void (*pctest0)() = ctest0;
+
+void ctest2() {}
+void (__attribute__((cdecl)) *pctest2)() = ctest2;
+
+typedef void (__attribute__((fastcall)) *Handler) (float *); // expected-warning {{calling convention 'fastcall' ignored for this target}}
+Handler H = foo;
+
+int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
+int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
+int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
+ // expected-error {{invalid PCS type}}
+int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
+/* These are ignored because the target is i386 and not ARM */
+int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
+int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
+int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
+
+void ctest3();
+void __attribute__((cdecl)) ctest3() {}
+
+typedef __attribute__((stdcall)) void (*PROC)(); // expected-warning {{calling convention 'stdcall' ignored for this target}}
+PROC __attribute__((cdecl)) ctest4(const char *x) {}
+
+void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {} // expected-warning {{calling convention 'intel_ocl_bicc' ignored for this target}}
+
+struct type_test {} __attribute__((stdcall)); // expected-warning {{calling convention 'stdcall' ignored for this target}} expected-warning {{'stdcall' attribute only applies to functions and methods}}
diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c
index 5f5b6f3dc198..bfb58bc573e1 100644
--- a/test/Sema/const-eval.c
+++ b/test/Sema/const-eval.c
@@ -118,10 +118,6 @@ float varfloat;
const float constfloat = 0;
EVAL_EXPR(43, varfloat && constfloat) // expected-error {{must have a constant size}}
-// <rdar://problem/11205586>
-// (Make sure we continue to reject this.)
-EVAL_EXPR(44, "x"[0]); // expected-error {{variable length array}}
-
// <rdar://problem/10962435>
EVAL_EXPR(45, ((char*)-1) + 1 == 0 ? 1 : -1)
EVAL_EXPR(46, ((char*)-1) + 1 < (char*) -1 ? 1 : -1)
@@ -137,3 +133,7 @@ EVAL_EXPR(51, 0 != (float)1e99)
// PR21945
void PR21945() { int i = (({}), 0l); }
+
+void PR24622();
+struct PR24622 {} pr24622;
+EVAL_EXPR(52, &pr24622 == (void *)&PR24622); // expected-error {{must have a constant size}}
diff --git a/test/Sema/dllexport.c b/test/Sema/dllexport.c
index 69aad2eb54c0..56c9e74225f2 100644
--- a/test/Sema/dllexport.c
+++ b/test/Sema/dllexport.c
@@ -109,6 +109,11 @@ __declspec(dllexport) void redecl6(); // expected-warning{{redeclaration of 'red
// External linkage is required.
__declspec(dllexport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllexport'}}
+// Static locals don't count as having external linkage.
+void staticLocalFunc() {
+ __declspec(dllexport) static int staticLocal; // expected-error{{'staticLocal' must have external linkage when declared 'dllexport'}}
+}
+
//===----------------------------------------------------------------------===//
diff --git a/test/Sema/dllimport.c b/test/Sema/dllimport.c
index d81aecd604c7..f863499cf840 100644
--- a/test/Sema/dllimport.c
+++ b/test/Sema/dllimport.c
@@ -168,3 +168,8 @@ __declspec(dllimport) inline void redecl7() {}
// External linkage is required.
__declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}}
+
+// Static locals don't count as having external linkage.
+void staticLocalFunc() {
+ __declspec(dllimport) static int staticLocal; // expected-error{{'staticLocal' must have external linkage when declared 'dllimport'}}
+}
diff --git a/test/Sema/enable_if.c b/test/Sema/enable_if.c
index 7faae43b577e..0cd9c48f42b5 100644
--- a/test/Sema/enable_if.c
+++ b/test/Sema/enable_if.c
@@ -5,6 +5,8 @@
typedef int mode_t;
typedef unsigned long size_t;
+const int TRUE = 1;
+
int open(const char *pathname, int flags) __attribute__((enable_if(!(flags & O_CREAT), "must specify mode when using O_CREAT"))) __attribute__((overloadable)); // expected-note{{candidate disabled: must specify mode when using O_CREAT}}
int open(const char *pathname, int flags, mode_t mode) __attribute__((overloadable)); // expected-note{{candidate function not viable: requires 3 arguments, but 2 were provided}}
@@ -91,6 +93,12 @@ void test4(int c) {
#endif
}
+void test5() {
+ int (*p1)(int) = &isdigit2;
+ int (*p2)(int) = isdigit2;
+ void *p3 = (void *)&isdigit2;
+ void *p4 = (void *)isdigit2;
+}
#ifndef CODEGEN
__attribute__((enable_if(n == 0, "chosen when 'n' is zero"))) void f1(int n); // expected-error{{use of undeclared identifier 'n'}}
@@ -109,4 +117,29 @@ void f(int n) __attribute__((enable_if(global == 0, "chosen when 'global' is zer
const int cst = 7;
void return_cst(void) __attribute__((overloadable)) __attribute__((enable_if(cst == 7, "chosen when 'cst' is 7")));
void test_return_cst() { return_cst(); }
+
+void f2(void) __attribute__((overloadable)) __attribute__((enable_if(1, "always chosen")));
+void f2(void) __attribute__((overloadable)) __attribute__((enable_if(0, "never chosen")));
+void f2(void) __attribute__((overloadable)) __attribute__((enable_if(TRUE, "always chosen #2")));
+void test6() {
+ void (*p1)(void) = &f2; // expected-error{{initializing 'void (*)(void)' with an expression of incompatible type '<overloaded function type>'}} expected-note@121{{candidate function}} expected-note@122{{candidate function made ineligible by enable_if}} expected-note@123{{candidate function}}
+ void (*p2)(void) = f2; // expected-error{{initializing 'void (*)(void)' with an expression of incompatible type '<overloaded function type>'}} expected-note@121{{candidate function}} expected-note@122{{candidate function made ineligible by enable_if}} expected-note@123{{candidate function}}
+ void *p3 = (void*)&f2; // expected-error{{address of overloaded function 'f2' is ambiguous}} expected-note@121{{candidate function}} expected-note@122{{candidate function made ineligible by enable_if}} expected-note@123{{candidate function}}
+ void *p4 = (void*)f2; // expected-error{{address of overloaded function 'f2' is ambiguous}} expected-note@121{{candidate function}} expected-note@122{{candidate function made ineligible by enable_if}} expected-note@123{{candidate function}}
+}
+
+void f3(int m) __attribute__((overloadable)) __attribute__((enable_if(m >= 0, "positive")));
+void f3(int m) __attribute__((overloadable)) __attribute__((enable_if(m < 0, "negative")));
+void test7() {
+ void (*p1)(int) = &f3; // expected-error{{initializing 'void (*)(int)' with an expression of incompatible type '<overloaded function type>'}} expected-note@131{{candidate function made ineligible by enable_if}} expected-note@132{{candidate function made ineligible by enable_if}}
+ void (*p2)(int) = f3; // expected-error{{initializing 'void (*)(int)' with an expression of incompatible type '<overloaded function type>'}} expected-note@131{{candidate function made ineligible by enable_if}} expected-note@132{{candidate function made ineligible by enable_if}}
+ void *p3 = (void*)&f3; // expected-error{{address of overloaded function 'f3' does not match required type 'void'}} expected-note@131{{candidate function made ineligible by enable_if}} expected-note@132{{candidate function made ineligible by enable_if}}
+ void *p4 = (void*)f3; // expected-error{{address of overloaded function 'f3' does not match required type 'void'}} expected-note@131{{candidate function made ineligible by enable_if}} expected-note@132{{candidate function made ineligible by enable_if}}
+}
+
+void f4(int m) __attribute__((enable_if(0, "")));
+void test8() {
+ void (*p1)(int) = &f4; // expected-error{{cannot take address of function 'f4' becuase it has one or more non-tautological enable_if conditions}}
+ void (*p2)(int) = f4; // expected-error{{cannot take address of function 'f4' becuase it has one or more non-tautological enable_if conditions}}
+}
#endif
diff --git a/test/Sema/enum.c b/test/Sema/enum.c
index fc2b491f5c30..3546bfe48fc6 100644
--- a/test/Sema/enum.c
+++ b/test/Sema/enum.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+// RUN: %clang_cc1 -triple %itanium_abi_triple %s -fsyntax-only -verify -pedantic
enum e {A,
B = 42LL << 32, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
C = -4, D = 12456 };
@@ -119,3 +119,7 @@ void crash(enum E* e) // expected-warning {{declaration of 'enum E' will not be
typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
+
+// PR24610
+enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
+typedef struct Color NewColor; // expected-error {{use of 'Color' with tag type that does not match previous declaration}}
diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c
index 17b1aa2851b0..5da4f949a150 100644
--- a/test/Sema/exprs.c
+++ b/test/Sema/exprs.c
@@ -97,6 +97,7 @@ int test9(struct f *P) {
R = __alignof(P->x); // expected-error {{invalid application of 'alignof' to bit-field}}
R = __alignof(P->y); // ok.
R = sizeof(P->x); // expected-error {{invalid application of 'sizeof' to bit-field}}
+ __extension__ ({ R = (__typeof__(P->x)) 2; }); // expected-error {{invalid application of 'typeof' to bit-field}}
return R;
}
diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c
index 949d67311b36..924013aeb29d 100644
--- a/test/Sema/ext_vector_casts.c
+++ b/test/Sema/ext_vector_casts.c
@@ -20,8 +20,8 @@ static void test() {
int *ptr;
int i;
- vec3 += vec2; // expected-error {{can't convert between vector values of different size}}
- vec4 += vec3; // expected-error {{can't convert between vector values of different size}}
+ vec3 += vec2; // expected-error {{cannot convert between vector values of different size}}
+ vec4 += vec3; // expected-error {{cannot convert between vector values of different size}}
vec4 = 5.0f;
vec4 = (float4)5.0f;
@@ -44,11 +44,11 @@ static void test() {
vec4 /= 5.2f;
vec4 %= 4; // expected-error {{invalid operands to binary expression ('float4' (vector of 4 'float' values) and 'int')}}
ivec4 %= 4;
- ivec4 += vec4; // expected-error {{can't convert between vector values of different size ('int4' (vector of 4 'int' values) and 'float4' (vector of 4 'float' values))}}
+ ivec4 += vec4; // expected-error {{cannot convert between vector values of different size ('int4' (vector of 4 'int' values) and 'float4' (vector of 4 'float' values))}}
ivec4 += (int4)vec4;
ivec4 -= ivec4;
ivec4 |= ivec4;
- ivec4 += ptr; // expected-error {{can't convert between vector and non-scalar values ('int4' (vector of 4 'int' values) and 'int *')}}
+ ivec4 += ptr; // expected-error {{cannot convert between vector and non-scalar values ('int4' (vector of 4 'int' values) and 'int *')}}
}
typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector element type 'float2' (vector of 2 'float' values)}}
@@ -102,11 +102,11 @@ static void splats(int i, long l, __uint128_t t, float f, double d) {
vs = 65536 + vs; // expected-warning {{implicit conversion from 'int' to 'short8' (vector of 8 'short' values) changes value from 65536 to 0}}
vs = vs + i; // expected-warning {{implicit conversion loses integer precision}}
vs = vs + 1;
- vs = vs + 1.f; // expected-error {{can't convert between vector values of different size}}
+ vs = vs + 1.f; // expected-error {{cannot convert between vector values of different size}}
vi = l + vi; // expected-warning {{implicit conversion loses integer precision}}
vi = 1 + vi;
- vi = vi + 2.0; // expected-error {{can't convert between vector values of different size}}
+ vi = vi + 2.0; // expected-error {{cannot convert between vector values of different size}}
vi = vi + 0xffffffff; // expected-warning {{implicit conversion changes signedness}}
vl = l + vl; // expected-warning {{implicit conversion changes signedness}}
diff --git a/test/Sema/ext_vector_conversions.c b/test/Sema/ext_vector_conversions.c
new file mode 100644
index 000000000000..aa57e2b17ea2
--- /dev/null
+++ b/test/Sema/ext_vector_conversions.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only -verify -Wconversion %s
+
+typedef __attribute__((ext_vector_type(4))) char char4;
+typedef __attribute__((ext_vector_type(4))) short short4;
+typedef __attribute__((ext_vector_type(1))) float float1;
+
+static void test() {
+ char4 vc4;
+ float f;
+ // Not allowed. There's no splatting conversion between float and int vector,
+ // and we don't want to bitcast f to vector-of-char (as would happen with the
+ // old-style vector types).
+ vc4 += f; // expected-error {{cannot convert between vector values of different size}}
+ short4 vs4;
+ long long ll;
+ // This one is OK; we don't re-interpret ll as short4, rather we splat its
+ // value, which should produce a warning about clamping.
+ vs4 += ll; // expected-warning {{implicit conversion loses integer precision}}
+}
diff --git a/test/Sema/fn-ptr-as-fn-prototype.c b/test/Sema/fn-ptr-as-fn-prototype.c
index 4b01b1316e10..0422f2b86ea9 100644
--- a/test/Sema/fn-ptr-as-fn-prototype.c
+++ b/test/Sema/fn-ptr-as-fn-prototype.c
@@ -7,7 +7,7 @@
// CHECK: typedef void (*g)();
typedef void (*g) ();
-// CHECK: enum {
+// CHECK: enum
enum {
k = -1
};
diff --git a/test/Sema/function-redecl.c b/test/Sema/function-redecl.c
index 561f7fae6b90..eb6e78595ae5 100644
--- a/test/Sema/function-redecl.c
+++ b/test/Sema/function-redecl.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
// PR3588
void g0(int, int);
diff --git a/test/Sema/generic-selection.c b/test/Sema/generic-selection.c
index 8cef975c709c..0563ec0f4fc0 100644
--- a/test/Sema/generic-selection.c
+++ b/test/Sema/generic-selection.c
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s
+void g(void);
+
void foo(int n) {
(void) _Generic(0,
struct A: 0, // expected-error {{type 'struct A' in generic association incomplete}}
@@ -23,4 +25,10 @@ void foo(int n) {
int a4[_Generic(0L, default: 1, short: 2, float: 3, int: 4) == 1 ? 1 : -1];
int a5[_Generic(0, int: 1, short: 2, float: 3) == 1 ? 1 : -1];
int a6[_Generic(0, short: 1, float: 2, int: 3) == 3 ? 1 : -1];
+
+ int a7[_Generic("test", char *: 1, default: 2) == 1 ? 1 : -1];
+ int a8[_Generic(g, void (*)(void): 1, default: 2) == 1 ? 1 : -1];
+
+ const int i = 12;
+ int a9[_Generic(i, int: 1, default: 2) == 1 ? 1 : -1];
}
diff --git a/test/Sema/inline-asm-validate-amdgpu.cl b/test/Sema/inline-asm-validate-amdgpu.cl
new file mode 100644
index 000000000000..d60b09e0ce9d
--- /dev/null
+++ b/test/Sema/inline-asm-validate-amdgpu.cl
@@ -0,0 +1,14 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x cl -triple amdgcn -fsyntax-only %s
+// expected-no-diagnostics
+
+kernel void test () {
+
+ int sgpr = 0, vgpr = 0, imm = 0;
+
+ // sgpr constraints
+ __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "s" (imm) : );
+
+ // vgpr constraints
+ __asm__ ("v_mov_b32 %0, %1" : "=v" (vgpr) : "v" (imm) : );
+}
diff --git a/test/Sema/inline-asm-validate-x86.c b/test/Sema/inline-asm-validate-x86.c
index 658b714056f8..f21ef6940a6d 100644
--- a/test/Sema/inline-asm-validate-x86.c
+++ b/test/Sema/inline-asm-validate-x86.c
@@ -52,6 +52,32 @@ void K(int i, int j) {
: "0"(i), "K"(96)); // expected-no-error
}
+void L(int i, int j) {
+ static const int Invalid1 = 1;
+ static const int Invalid2 = 42;
+ static const int Valid1 = 0xff;
+ static const int Valid2 = 0xffff;
+ static const int Valid3 = 0xffffffff;
+ __asm__("xorl %0,%2"
+ : "=r"(i)
+ : "0"(i), "L"(j)); // expected-error{{constraint 'L' expects an integer constant expression}}
+ __asm__("xorl %0,%2"
+ : "=r"(i)
+ : "0"(i), "L"(Invalid1)); // expected-error{{value '1' out of range for constraint 'L'}}
+ __asm__("xorl %0,%2"
+ : "=r"(i)
+ : "0"(i), "L"(Invalid2)); // expected-error{{value '42' out of range for constraint 'L'}}
+ __asm__("xorl %0,%2"
+ : "=r"(i)
+ : "0"(i), "L"(Valid1)); // expected-no-error
+ __asm__("xorl %0,%2"
+ : "=r"(i)
+ : "0"(i), "L"(Valid2)); // expected-no-error
+ __asm__("xorl %0,%2"
+ : "=r"(i)
+ : "0"(i), "L"(Valid3)); // expected-no-error
+}
+
void M(int i, int j) {
static const int BelowMin = -1;
static const int AboveMax = 4;
diff --git a/test/Sema/inline.c b/test/Sema/inline.c
index 8a3835b71ada..eced058f8ddc 100644
--- a/test/Sema/inline.c
+++ b/test/Sema/inline.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
#if defined(INCLUDE)
// -------
diff --git a/test/Sema/internal_linkage.c b/test/Sema/internal_linkage.c
new file mode 100644
index 000000000000..f4deccca63d1
--- /dev/null
+++ b/test/Sema/internal_linkage.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int var __attribute__((internal_linkage));
+int var2 __attribute__((internal_linkage,common)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
+ // expected-note{{conflicting attribute is here}}
+int var3 __attribute__((common,internal_linkage)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}} \
+ // expected-note{{conflicting attribute is here}}
+
+int var4 __attribute__((common)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}} \
+// expected-note{{previous definition is here}}
+int var4 __attribute__((internal_linkage)); // expected-note{{conflicting attribute is here}} \
+// expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'var4'}}
+
+int var5 __attribute__((internal_linkage)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}}
+int var5 __attribute__((common)); // expected-note{{conflicting attribute is here}}
+
+__attribute__((internal_linkage)) int f() {}
+struct __attribute__((internal_linkage)) S { // expected-warning{{'internal_linkage' attribute only applies to variables and functions}}
+};
+
+__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
diff --git a/test/Sema/mips-interrupt-attr.c b/test/Sema/mips-interrupt-attr.c
new file mode 100644
index 000000000000..17344b6edcf0
--- /dev/null
+++ b/test/Sema/mips-interrupt-attr.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -triple mips-img-elf -verify -fsyntax-only
+struct a { int b; };
+
+struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions and methods}}
+
+__attribute__((interrupt("EIC"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: 'EIC'}}
+
+__attribute__((interrupt("eic", 1))) void foo2() {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
+
+__attribute__((interrupt("eic"))) void foo3() {}
+__attribute__((interrupt("vector=sw0"))) void foo4() {}
+__attribute__((interrupt("vector=hw0"))) void foo5() {}
+__attribute__((interrupt("vector=hw1"))) void foo6() {}
+__attribute__((interrupt("vector=hw2"))) void foo7() {}
+__attribute__((interrupt("vector=hw3"))) void foo8() {}
+__attribute__((interrupt("vector=hw4"))) void foo9() {}
+__attribute__((interrupt("vector=hw5"))) void fooa() {}
+__attribute__((interrupt(""))) void food() {}
+
+__attribute__((interrupt)) int foob() {return 0;} // expected-warning {{MIPS 'interrupt' attribute only applies to functions that have a 'void' return type}}
+__attribute__((interrupt())) void fooc(int a) {} // expected-warning {{MIPS 'interrupt' attribute only applies to functions that have no parameters}}
+__attribute__((interrupt,mips16)) void fooe() {} // expected-error {{'interrupt' and 'mips16' attributes are not compatible}} \
+ // expected-note {{conflicting attribute is here}}
+__attribute__((mips16,interrupt)) void foof() {} // expected-error {{'mips16' and 'interrupt' attributes are not compatible}} \
+ // expected-note {{conflicting attribute is here}}
+__attribute__((interrupt)) __attribute__ ((mips16)) void foo10() {} // expected-error {{'interrupt' and 'mips16' attributes are not compatible}} \
+ // expected-note {{conflicting attribute is here}}
+__attribute__((mips16)) __attribute ((interrupt)) void foo11() {} // expected-error {{'mips16' and 'interrupt' attributes are not compatible}} \
+ // expected-note {{conflicting attribute is here}}
diff --git a/test/Sema/ms_bitfield_layout.c b/test/Sema/ms_bitfield_layout.c
index 293df770cd7e..8d377bc28d49 100644
--- a/test/Sema/ms_bitfield_layout.c
+++ b/test/Sema/ms_bitfield_layout.c
@@ -13,10 +13,16 @@ typedef struct A {
short y;
} A;
-// CHECK: Type: struct A
-// CHECK: Size:128
-// CHECK: Alignment:32
-// CHECK: FieldOffsets: [0, 32, 64, 64, 96, 99, 112]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct A
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 4:0-21 | int a
+// CHECK-NEXT: 8:- | int
+// CHECK-NEXT: 8:0-9 | int c
+// CHECK-NEXT: 12:0-2 | char b
+// CHECK-NEXT: 12:3-6 | char d
+// CHECK-NEXT: 14 | short y
+// CHECK-NEXT: | [sizeof=16, align=4]
typedef struct B {
char x;
@@ -25,10 +31,13 @@ typedef struct B {
char y;
} B;
-// CHECK: Type: struct B
-// CHECK: Size:48
-// CHECK: Alignment:16
-// CHECK: FieldOffsets: [0, 8, 16, 32]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct B
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 1:- | int
+// CHECK-NEXT: 2:0-3 | short a
+// CHECK-NEXT: 4 | char y
+// CHECK-NEXT: | [sizeof=6, align=2]
typedef struct C {
char x;
@@ -37,10 +46,13 @@ typedef struct C {
char y;
} C;
-// CHECK: Type: struct C
-// CHECK: Size:64
-// CHECK: Alignment:32
-// CHECK: FieldOffsets: [0, 16, 32, 32]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct C
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 2:0-3 | short a
+// CHECK-NEXT: 4:- | int
+// CHECK-NEXT: 4 | char y
+// CHECK-NEXT: | [sizeof=8, align=4]
typedef struct D {
char x;
@@ -49,10 +61,13 @@ typedef struct D {
char y;
} D;
-// CHECK: Type: struct D
-// CHECK: Size:16
-// CHECK: Alignment:8
-// CHECK: FieldOffsets: [0, 8, 8, 8]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct D
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 1:- | short
+// CHECK-NEXT: 1:- | int
+// CHECK-NEXT: 1 | char y
+// CHECK-NEXT: | [sizeof=2, align=1]
typedef union E {
char x;
@@ -62,10 +77,15 @@ typedef union E {
short y;
} E;
-// CHECK: Type: union E
-// CHECK: Size:64
-// CHECK: Alignment:16
-// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
+
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | union E
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 0:0-2 | long long a
+// CHECK-NEXT: 0:0-2 | int b
+// CHECK-NEXT: 0:- | long long
+// CHECK-NEXT: 0 | short
+// CHECK-NEXT: | [sizeof=8, align=2]
typedef struct F {
char x;
@@ -81,10 +101,20 @@ typedef struct F {
short y;
} F;
-// CHECK: Type: struct F
-// CHECK: Size:128
-// CHECK: Alignment:16
-// CHECK: FieldOffsets: [0, 8, 11, 16, 32, 38, 48, 64, 80, 96, 112]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct F
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 1:0-2 | char a
+// CHECK-NEXT: 1:3-5 | char b
+// CHECK-NEXT: 2:0-2 | char c
+// CHECK-NEXT: 4:0-5 | short d
+// CHECK-NEXT: 4:6-11 | short e
+// CHECK-NEXT: 6:0-5 | short f
+// CHECK-NEXT: 8:0-10 | short g
+// CHECK-NEXT:10:0-10 | short h
+// CHECK-NEXT:12:0-10 | short i
+// CHECK-NEXT: 14 | short y
+// CHECK-NEXT: | [sizeof=16, align=2]
typedef union G {
char x;
@@ -94,10 +124,14 @@ typedef union G {
short y;
} G;
-// CHECK: Type: union G
-// CHECK: Size:32
-// CHECK: Alignment:16
-// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | union G
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 0:0-2 | int a
+// CHECK-NEXT: 0:- | int
+// CHECK-NEXT: 0:- | long long
+// CHECK-NEXT: 0 | short y
+// CHECK-NEXT: | [sizeof=4, align=2]
typedef struct H {
unsigned short a : 1;
@@ -106,20 +140,25 @@ typedef struct H {
unsigned short c : 1;
} H;
-// CHECK: Type: struct H
-// CHECK: Size:32
-// CHECK: Alignment:16
-// CHECK: FieldOffsets: [0, 16, 16, 16]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct H
+// CHECK-NEXT: 0:0-0 | unsigned short a
+// CHECK-NEXT: 2:- | unsigned char
+// CHECK-NEXT: 2:- | unsigned long
+// CHECK-NEXT: 2:0-0 | unsigned short c
+// CHECK-NEXT: | [sizeof=4, align=2]
typedef struct I {
short : 8;
__declspec(align(16)) short : 8;
} I;
-// CHECK: Type: struct I
-// CHECK: Size:16
-// CHECK: Alignment:16
-// CHECK: FieldOffsets: [0, 8]
+
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct I
+// CHECK-NEXT: 0:0-7 | short
+// CHECK-NEXT: 1:0-7 | short
+// CHECK-NEXT: | [sizeof=2, align=2]
#pragma pack(push, 1)
@@ -133,10 +172,16 @@ typedef struct A1 {
short y;
} A1;
-// CHECK: Type: struct A1
-// CHECK: Size:96
-// CHECK: Alignment:8
-// CHECK: FieldOffsets: [0, 8, 40, 40, 72, 75, 80]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct A1
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 1:0-21 | int a
+// CHECK-NEXT: 5:- | int
+// CHECK-NEXT: 5:0-9 | int c
+// CHECK-NEXT: 9:0-2 | char b
+// CHECK-NEXT: 9:3-6 | char d
+// CHECK-NEXT: 10 | short y
+// CHECK-NEXT: | [sizeof=12, align=1]
typedef struct B1 {
char x;
@@ -145,10 +190,13 @@ typedef struct B1 {
char y;
} B1;
-// CHECK: Type: struct B1
-// CHECK: Size:32
-// CHECK: Alignment:8
-// CHECK: FieldOffsets: [0, 8, 8, 24]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct B1
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 1:- | int
+// CHECK-NEXT: 1:0-3 | short
+// CHECK-NEXT: 3 | char y
+// CHECK-NEXT: | [sizeof=4, align=1]
typedef struct C1 {
char x;
@@ -157,10 +205,13 @@ typedef struct C1 {
char y;
} C1;
-// CHECK: Type: struct C1
-// CHECK: Size:32
-// CHECK: Alignment:8
-// CHECK: FieldOffsets: [0, 8, 24, 24]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct C1
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 1:0-3 | short
+// CHECK-NEXT: 3:- | int
+// CHECK-NEXT: 3 | char y
+// CHECK-NEXT: | [sizeof=4, align=1]
typedef struct D1 {
char x;
@@ -169,10 +220,13 @@ typedef struct D1 {
char y;
} D1;
-// CHECK: Type: struct D1
-// CHECK: Size:16
-// CHECK: Alignment:8
-// CHECK: FieldOffsets: [0, 8, 8, 8]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct D1
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 1:- | short
+// CHECK-NEXT: 1:- | int
+// CHECK-NEXT: 1 | char y
+// CHECK-NEXT: | [sizeof=2, align=1]
typedef union E1 {
char x;
@@ -182,10 +236,14 @@ typedef union E1 {
short y;
} E1;
-// CHECK: Type: union E1
-// CHECK: Size:64
-// CHECK: Alignment:8
-// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | union E1
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 0:0-2 | long long a
+// CHECK-NEXT: 0:0-2 | int b
+// CHECK-NEXT: 0:- | long long
+// CHECK-NEXT: 0 | short y
+// CHECK-NEXT: | [sizeof=8, align=1]
typedef struct F1 {
char x;
@@ -201,10 +259,20 @@ typedef struct F1 {
short y;
} F1;
-// CHECK: Type: struct F1
-// CHECK: Size:120
-// CHECK: Alignment:8
-// CHECK: FieldOffsets: [0, 8, 11, 16, 24, 30, 40, 56, 72, 88, 104]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct F1
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 1:0-2 | char a
+// CHECK-NEXT: 1:3-5 | char b
+// CHECK-NEXT: 2:0-2 | char c
+// CHECK-NEXT: 3:0-5 | short d
+// CHECK-NEXT: 3:6-11 | short e
+// CHECK-NEXT: 5:0-5 | short f
+// CHECK-NEXT: 7:0-10 | short g
+// CHECK-NEXT: 9:0-10 | short h
+// CHECK-NEXT:11:0-10 | short i
+// CHECK-NEXT: 13 | short y
+// CHECK-NEXT: | [sizeof=15, align=1]
typedef union G1 {
char x;
@@ -214,10 +282,14 @@ typedef union G1 {
short y;
} G1;
-// CHECK: Type: union G1
-// CHECK: Size:32
-// CHECK: Alignment:8
-// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | union G1
+// CHECK-NEXT: 0 | char x
+// CHECK-NEXT: 0:0-2 | int a
+// CHECK-NEXT: 0:- | int
+// CHECK-NEXT: 0:- | long long
+// CHECK-NEXT: 0 | short y
+// CHECK-NEXT: | [sizeof=4, align=1]
typedef struct H1 {
unsigned long a : 1;
@@ -226,20 +298,24 @@ typedef struct H1 {
unsigned long c : 1;
} H1;
-// CHECK: Type: struct H1
-// CHECK: Size:64
-// CHECK: Alignment:8
-// CHECK: FieldOffsets: [0, 32, 32, 32]>
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct H1
+// CHECK-NEXT: 0:0-0 | unsigned long a
+// CHECK-NEXT: 4:- | unsigned char
+// CHECK-NEXT: 4:- | unsigned long
+// CHECK-NEXT: 4:0-0 | unsigned long c
+// CHECK-NEXT: | [sizeof=8, align=1]
typedef struct I1 {
short : 8;
__declspec(align(16)) short : 8;
} I1;
-// CHECK: Type: struct I1
-// CHECK: Size:16
-// CHECK: Alignment:8
-// CHECK: FieldOffsets: [0, 8]
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct I1
+// CHECK-NEXT: 0:0-7 | short
+// CHECK-NEXT: 1:0-7 | short
+// CHECK-NEXT: | [sizeof=2, align=1]
#pragma pack(pop)
diff --git a/test/Sema/ms_class_layout.cpp b/test/Sema/ms_class_layout.cpp
index 896d3edfda38..8638972430f6 100644
--- a/test/Sema/ms_class_layout.cpp
+++ b/test/Sema/ms_class_layout.cpp
@@ -236,11 +236,7 @@ int main() {
// CHECK-NEXT: 84 | int b_field
// CHECK-NEXT: 88 | int a_field
// CHECK-NEXT: 92 | char one
-
-// CHECK-NEXT: sizeof=80, align=8
-// CHECK-NEXT: nvsize=64, nvalign=8
-
-// CHECK: sizeof=96, align=8
+// CHECK-NEXT: sizeof=96, align=8
// CHECK-NEXT: nvsize=96, nvalign=8
// CHECK: %struct.BaseStruct = type { double, float, %class.C }
@@ -267,10 +263,7 @@ int main() {
// CHECK-NEXT: 84 | int b_field
// CHECK-NEXT: 88 | int a_field
// CHECK-NEXT: 92 | char one
-// CHECK-NEXT: sizeof=80, align=8
-// CHECK-NEXT: nvsize=64, nvalign=8
-
-// CHECK: 96 | int x
+// CHECK-NEXT: 96 | int x
// CHECK-NEXT: sizeof=104, align=8
// CHECK-NEXT: nvsize=104, nvalign=8
diff --git a/test/Sema/non-null-warning.c b/test/Sema/non-null-warning.c
index 024ef1eca667..7dfa3900cbb5 100644
--- a/test/Sema/non-null-warning.c
+++ b/test/Sema/non-null-warning.c
@@ -37,6 +37,9 @@ int * ret_nonnull() {
return 0; // expected-warning {{null returned from function that requires a non-null return value}}
}
+#define SAFE_CALL(X) if (X) foo(X)
int main () {
foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
+ SAFE_CALL(0); // expect no diagnostic for unreachable code.
}
diff --git a/test/Sema/nonnull.c b/test/Sema/nonnull.c
index 4b3df8518cfc..9503e7c32a86 100644
--- a/test/Sema/nonnull.c
+++ b/test/Sema/nonnull.c
@@ -89,7 +89,7 @@ void redecl_test(void *p) {
__attribute__((__nonnull__))
int evil_nonnull_func(int* pointer, void * pv)
{
- if (pointer == NULL) { // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is false on first encounter}}
+ if (pointer == NULL) { // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is 'false' on first encounter}}
return 0;
} else {
return *pointer;
@@ -101,13 +101,13 @@ int evil_nonnull_func(int* pointer, void * pv)
else
return *pointer;
- if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is false on first encounter}}
+ if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is 'false' on first encounter}}
}
void set_param_to_null(int**);
int another_evil_nonnull_func(int* pointer, char ch, void * pv) __attribute__((nonnull(1, 3)));
int another_evil_nonnull_func(int* pointer, char ch, void * pv) {
- if (pointer == NULL) { // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is false on first encounter}}
+ if (pointer == NULL) { // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is 'false' on first encounter}}
return 0;
} else {
return *pointer;
@@ -119,7 +119,7 @@ int another_evil_nonnull_func(int* pointer, char ch, void * pv) {
else
return *pointer;
- if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is false on first encounter}}
+ if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is 'false' on first encounter}}
}
extern void *returns_null(void**);
@@ -153,3 +153,17 @@ void pr21668_2(__attribute__((nonnull)) const char *p) {
if (p) // No warning
;
}
+
+__attribute__((returns_nonnull)) void *returns_nonnull_whee();
+
+void returns_nonnull_warning_tests() {
+ if (returns_nonnull_whee() == NULL) {} // expected-warning {{comparison of nonnull function call 'returns_nonnull_whee()' equal to a null pointer is 'false' on first encounter}}
+
+ if (returns_nonnull_whee() != NULL) {} // expected-warning {{comparison of nonnull function call 'returns_nonnull_whee()' not equal to a null pointer is 'true' on first encounter}}
+
+ if (returns_nonnull_whee()) {} // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}}
+ if (!returns_nonnull_whee()) {} // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}}
+
+ int and_again = !returns_nonnull_whee(); // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}}
+ and_again = !returns_nonnull_whee(); // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}}
+}
diff --git a/test/Sema/nullability.c b/test/Sema/nullability.c
index 59644c4193a8..bbe5cb4143a0 100644
--- a/test/Sema/nullability.c
+++ b/test/Sema/nullability.c
@@ -47,6 +47,7 @@ typedef _Nonnull int *(^ block_type_3)(int, int);
typedef _Nonnull int *(* function_pointer_type_3)(int, int);
typedef _Nonnull int_ptr (^ block_type_4)(int, int);
typedef _Nonnull int_ptr (* function_pointer_type_4)(int, int);
+typedef void (* function_pointer_type_5)(int_ptr _Nonnull);
void acceptFunctionPtr(_Nonnull int *(*)(void));
void acceptBlockPtr(_Nonnull int *(^)(void));
@@ -55,7 +56,8 @@ void testBlockFunctionPtrNullability() {
float *fp;
fp = (function_pointer_type_3)0; // expected-warning{{from 'function_pointer_type_3' (aka 'int * _Nonnull (*)(int, int)')}}
fp = (block_type_3)0; // expected-error{{from incompatible type 'block_type_3' (aka 'int * _Nonnull (^)(int, int)')}}
- fp = (function_pointer_type_4)0; // expected-warning{{from 'function_pointer_type_4' (aka 'int_ptr _Nonnull (*)(int, int)')}}
+ fp = (function_pointer_type_4)0; // expected-warning{{from 'function_pointer_type_4' (aka 'int * _Nonnull (*)(int, int)')}}
+ fp = (function_pointer_type_5)0; // expected-warning{{from 'function_pointer_type_5' (aka 'void (*)(int * _Nonnull)')}}
fp = (block_type_4)0; // expected-error{{from incompatible type 'block_type_4' (aka 'int_ptr _Nonnull (^)(int, int)')}}
acceptFunctionPtr(0); // no-warning
@@ -110,4 +112,7 @@ _Nonnull int *returns_int_ptr(int x) {
void nullable_to_nonnull(_Nullable int *ptr) {
int *a = ptr; // okay
_Nonnull int *b = ptr; // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
+ b = ptr; // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
+
+ accepts_nonnull_1(ptr); // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
}
diff --git a/test/Sema/overloadable.c b/test/Sema/overloadable.c
index bdd471477b47..3120649dbc02 100644
--- a/test/Sema/overloadable.c
+++ b/test/Sema/overloadable.c
@@ -85,3 +85,17 @@ void local() {
void after_local_1(int) __attribute__((overloadable)); // expected-error {{conflicting types}}
void after_local_2(int); // expected-error {{must have the 'overloadable' attribute}}
void after_local_3(int) __attribute__((overloadable));
+
+// Make sure we allow C-specific conversions in C.
+void conversions() {
+ void foo(char *c) __attribute__((overloadable));
+ void foo(char *c) __attribute__((overloadable, enable_if(c, "nope.jpg")));
+
+ void *ptr;
+ foo(ptr);
+
+ void multi_type(unsigned char *c) __attribute__((overloadable));
+ void multi_type(signed char *c) __attribute__((overloadable));
+ unsigned char *c;
+ multi_type(c);
+}
diff --git a/test/Sema/parentheses.c b/test/Sema/parentheses.c
index 739561dd2b33..8c6c4999f73a 100644
--- a/test/Sema/parentheses.c
+++ b/test/Sema/parentheses.c
@@ -55,6 +55,26 @@ void bitwise_rel(unsigned i) {
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:14-[[@LINE-2]]:14}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:19-[[@LINE-3]]:19}:")"
+ (void)(i ^ i | i); // expected-warning {{'^' within '|'}} \
+ // expected-note {{place parentheses around the '^' expression to silence this warning}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
+
+ (void)(i | i ^ i); // expected-warning {{'^' within '|'}} \
+ // expected-note {{place parentheses around the '^' expression to silence this warning}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:14-[[@LINE-2]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:19-[[@LINE-3]]:19}:")"
+
+ (void)(i & i ^ i); // expected-warning {{'&' within '^'}} \
+ // expected-note {{place parentheses around the '&' expression to silence this warning}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
+
+ (void)(i ^ i & i); // expected-warning {{'&' within '^'}} \
+ // expected-note {{place parentheses around the '&' expression to silence this warning}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:14-[[@LINE-2]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:19-[[@LINE-3]]:19}:")"
+
(void)(i ||
i && i); // expected-warning {{'&&' within '||'}} \
// expected-note {{place parentheses around the '&&' expression to silence this warning}}
diff --git a/test/Sema/pass-object-size.c b/test/Sema/pass-object-size.c
new file mode 100644
index 000000000000..e4f460b1785f
--- /dev/null
+++ b/test/Sema/pass-object-size.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -Wincompatible-pointer-types
+//
+// Tests for the pass_object_size attribute
+// Non-failure cases are covered in test/CodeGen/pass-object-size.c
+
+void a(void *p __attribute__((pass_object_size))); //expected-error{{'pass_object_size' attribute takes one argument}}
+void b(void *p __attribute__((pass_object_size(1.0)))); //expected-error{{'pass_object_size' attribute requires parameter 1 to be an integer constant}}
+
+void c(void *p __attribute__((pass_object_size(4)))); //expected-error{{'pass_object_size' attribute requires integer constant between 0 and 3 inclusive}}
+void d(void *p __attribute__((pass_object_size(-1)))); //expected-error{{'pass_object_size' attribute requires integer constant between 0 and 3 inclusive}}
+
+void e(void *p __attribute__((pass_object_size(1ULL<<32)))); //expected-error{{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
+
+void f(char p __attribute__((pass_object_size(0)))); //expected-error{{'pass_object_size' attribute only applies to constant pointer arguments}}
+void g(const char p __attribute__((pass_object_size(0)))); //expected-error{{'pass_object_size' attribute only applies to constant pointer arguments}}
+void h(char *p __attribute__((pass_object_size(0)))) {} //expected-error{{pass_object_size attribute only applies to constant pointer arguments}}
+void i(char *p __attribute__((pass_object_size(0)))); // OK -- const is only necessary on definitions, not decls.
+void j(char *p __attribute__((pass_object_size(0), pass_object_size(1)))); //expected-error{{'pass_object_size' attribute can only be applied once per parameter}}
+
+#define PS(N) __attribute__((pass_object_size(N)))
+#define overloaded __attribute__((overloadable))
+void Overloaded(void *p PS(0)) overloaded; //expected-note{{previous declaration is here}}
+void Overloaded(void *p PS(1)) overloaded; //expected-error{{conflicting pass_object_size attributes on parameters}}
+void Overloaded2(void *p PS(1), void *p2 PS(0)) overloaded; //expected-note{{previous declaration is here}}
+void Overloaded2(void *p PS(0), void *p2 PS(1)) overloaded; //expected-error{{conflicting pass_object_size attributes on parameters}}
+
+void Overloaded3(void *p PS(0), void *p2) overloaded; //expected-note{{previous declaration is here}}
+void Overloaded3(void *p, void *p2 PS(0)) overloaded; //expected-error{{conflicting pass_object_size attributes on parameters}}
+
+void TakeFn(void (*)(void *));
+void TakeFnOvl(void (*)(void *)) overloaded;
+void TakeFnOvl(void (*)(int *)) overloaded;
+
+void NotOverloaded(void *p PS(0));
+void IsOverloaded(void *p PS(0)) overloaded;
+void IsOverloaded(char *p) overloaded;
+void FunctionPtrs() {
+ void (*p)(void *) = NotOverloaded; //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
+ void (*p2)(void *) = &NotOverloaded; //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
+
+ void (*p3)(void *) = IsOverloaded; //expected-error{{initializing 'void (*)(void *)' with an expression of incompatible type '<overloaded function type>'}} expected-note@-6{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-5{{type mismatch}}
+ void (*p4)(void *) = &IsOverloaded; //expected-error{{initializing 'void (*)(void *)' with an expression of incompatible type '<overloaded function type>'}} expected-note@-7{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-6{{type mismatch}}
+
+ void (*p5)(char *) = IsOverloaded;
+ void (*p6)(char *) = &IsOverloaded;
+
+ TakeFn(NotOverloaded); //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
+ TakeFn(&NotOverloaded); //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
+
+ TakeFnOvl(NotOverloaded); //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
+ TakeFnOvl(&NotOverloaded); //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
+}
diff --git a/test/Sema/pointer-addition.c b/test/Sema/pointer-addition.c
index 667fe9a68c15..c71e96114b8a 100644
--- a/test/Sema/pointer-addition.c
+++ b/test/Sema/pointer-addition.c
@@ -14,10 +14,10 @@ void a(S* b, void* c) {
b = 1+b; // expected-error {{arithmetic on a pointer to an incomplete type}}
/* The next couple tests are only pedantic warnings in gcc */
void (*d)(S*,void*) = a;
- d += 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
- d++; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
- d--; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
- d -= 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
- (void)(1 + d); // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
+ d += 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
+ d++; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
+ d--; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
+ d -= 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
+ (void)(1 + d); // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
e++; // expected-error {{arithmetic on a pointer to an incomplete type}}
}
diff --git a/test/Sema/redefine_extname.c b/test/Sema/redefine_extname.c
new file mode 100644
index 000000000000..8202176c9f7b
--- /dev/null
+++ b/test/Sema/redefine_extname.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux -Wpragmas -verify %s
+
+// Check that pragma redefine_extname applies to external declarations only.
+#pragma redefine_extname foo_static bar_static
+static int foo_static() { return 1; } // expected-warning {{#pragma redefine_extname is applicable to external C declarations only; not applied to function 'foo_static'}}
+
diff --git a/test/Sema/short-enums.c b/test/Sema/short-enums.c
index 9bf0064646a7..464b09ee1054 100644
--- a/test/Sema/short-enums.c
+++ b/test/Sema/short-enums.c
@@ -1,5 +1,5 @@
// RUN: not %clang_cc1 -fsyntax-only %s -verify
-// RUN: %clang_cc1 -fshort-enums -fsyntax-only %s -verify
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fshort-enums -fsyntax-only %s -verify
// expected-no-diagnostics
enum x { A };
diff --git a/test/Sema/struct-packed-align.c b/test/Sema/struct-packed-align.c
index 417c30308ca3..abdcd8e6b9eb 100644
--- a/test/Sema/struct-packed-align.c
+++ b/test/Sema/struct-packed-align.c
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify
-// expected-no-diagnostics
+// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-coff -verify
// Packed structs.
struct s {
@@ -138,3 +138,24 @@ extern int n2[__alignof(struct nS) == 8 ? 1 : -1];
extern int n1[sizeof(struct nS) == 9 ? 1 : -1];
extern int n2[__alignof(struct nS) == 1 ? 1 : -1];
#endif
+
+// Packed attribute shouldn't be ignored for bit-field of char types.
+// Note from GCC reference manual: The 4.1, 4.2 and 4.3 series of GCC ignore
+// the packed attribute on bit-fields of type char. This has been fixed in
+// GCC 4.4 but the change can lead to differences in the structure layout.
+// See the documentation of -Wpacked-bitfield-compat for more information.
+struct packed_chars {
+ char a:4;
+ char b:8 __attribute__ ((packed));
+ // expected-warning@-1 {{'packed' attribute was ignored on bit-fields with single-byte alignment in older versions of GCC and Clang}}
+ char c:4;
+};
+
+#if defined(_WIN32) && !defined(__declspec) // _MSC_VER is unavailable in cc1.
+// On Windows clang uses MSVC compatible layout in this case.
+extern int o1[sizeof(struct packed_chars) == 3 ? 1 : -1];
+extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
+#else
+extern int o1[sizeof(struct packed_chars) == 2 ? 1 : -1];
+extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
+#endif
diff --git a/test/Sema/switch-1.c b/test/Sema/switch-1.c
index 5191c92e714d..144c3607f570 100644
--- a/test/Sema/switch-1.c
+++ b/test/Sema/switch-1.c
@@ -1,18 +1,50 @@
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -triple x86_64-apple-darwin10 -std=c++98 %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -triple x86_64-apple-darwin10 -std=c++11 %s
// rdar://11577384
// rdar://13423975
int f(int i) {
switch (i) {
- case 2147483647 + 2: // expected-warning {{overflow in expression; result is -2147483647 with type 'int'}}
+ case 2147483647 + 2:
+#if (__cplusplus <= 199711L) // C or C++03 or earlier modes
+ // expected-warning@-2 {{overflow in expression; result is -2147483647 with type 'int'}}
+#else
+ // expected-error@-4 {{case value is not a constant expression}} \
+ // expected-note@-4 {{value 2147483649 is outside the range of representable values of type 'int'}}
+#endif
return 1;
- case 9223372036854775807L * 4: // expected-warning {{overflow in expression; result is -4 with type 'long'}}
+ case 9223372036854775807L * 4:
+#if (__cplusplus <= 199711L)
+ // expected-warning@-2 {{overflow in expression; result is -4 with type 'long'}}
+#else
+ // expected-error@-4 {{case value is not a constant expression}} \
+ // expected-note@-4 {{value 36893488147419103228 is outside the range of representable values of type 'long'}}
+#endif
return 2;
- case (123456 *789012) + 1: // expected-warning {{overflow in expression; result is -1375982336 with type 'int'}}
+ case (123456 *789012) + 1:
+#if (__cplusplus <= 199711L)
+ // expected-warning@-2 {{overflow in expression; result is -1375982336 with type 'int'}}
+#else
+ // expected-error@-4 {{case value is not a constant expression}} \
+ // expected-note@-4 {{value 97408265472 is outside the range of representable values of type 'int'}}
+#endif
return 3;
- case (2147483647*4)/4: // expected-warning {{overflow in expression; result is -4 with type 'int'}}
- case (2147483647*4)%4: // expected-warning {{overflow in expression; result is -4 with type 'int'}}
+ case (2147483647*4)/4:
+#if (__cplusplus <= 199711L)
+ // expected-warning@-2 {{overflow in expression; result is -4 with type 'int'}}
+#else
+ // expected-error@-4 {{case value is not a constant expression}} \
+ // expected-note@-4 {{value 8589934588 is outside the range of representable values of type 'int'}}
+#endif
+ case (2147483647*4)%4:
+#if (__cplusplus <= 199711L)
+ // expected-warning@-2 {{overflow in expression; result is -4 with type 'int'}}
+#else
+ // expected-error@-4 {{case value is not a constant expression}} \
+ // expected-note@-4 {{value 8589934588 is outside the range of representable values of type 'int'}}
+#endif
return 4;
case 2147483647:
return 0;
diff --git a/test/Sema/thread-specifier.c b/test/Sema/thread-specifier.c
index 3968ae14cf2a..a93850da0077 100644
--- a/test/Sema/thread-specifier.c
+++ b/test/Sema/thread-specifier.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -DGNU
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DGNU
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DGNU -std=c++98
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -DC11 -D__thread=_Thread_local
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++98
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DCXX11 -D__thread=thread_local -std=c++11 -Wno-deprecated
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++11 -Wno-deprecated
diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c
index 43d8150b02cb..09359687d532 100644
--- a/test/Sema/unused-expr.c
+++ b/test/Sema/unused-expr.c
@@ -156,3 +156,11 @@ void t11(int i, int j) {
#undef M5
#undef M6
#undef M7
+
+#define UNREFERENCED_PARAMETER(x) (x)
+
+void unused_parm(int a) {
+ // Don't warn if the warning is introduced by a macro that's spelled
+ // UNREFERENCED_PARAMETER, as that's a commonly used macro in Windows headers.
+ UNREFERENCED_PARAMETER(a);
+}
diff --git a/test/Sema/varargs-win64.c b/test/Sema/varargs-win64.c
new file mode 100644
index 000000000000..06d1c7f246b9
--- /dev/null
+++ b/test/Sema/varargs-win64.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-pc-win32
+
+void __attribute__((sysv_abi)) foo(int a, ...) {
+ __builtin_va_list ap;
+ __builtin_va_start(ap, a); // expected-error {{'va_start' used in System V ABI function}}
+}
diff --git a/test/Sema/varargs-x86-32.c b/test/Sema/varargs-x86-32.c
new file mode 100644
index 000000000000..6f57022ffcbf
--- /dev/null
+++ b/test/Sema/varargs-x86-32.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple i386-apple-darwin9
+
+void foo(int a, ...) {
+ __builtin_ms_va_start((void *)0, a); // expected-error {{this builtin is only available on x86-64 targets}}
+}
diff --git a/test/Sema/varargs-x86-64.c b/test/Sema/varargs-x86-64.c
index 2fe9b10cf78d..d50dd6a6fc19 100644
--- a/test/Sema/varargs-x86-64.c
+++ b/test/Sema/varargs-x86-64.c
@@ -6,3 +6,75 @@ void f1() {
(void)__builtin_va_arg(args2, int); // expected-error {{first argument to 'va_arg' is of type 'const __builtin_va_list' and not 'va_list'}}
}
+void f2(int a, ...) {
+ __builtin_ms_va_list ap;
+ __builtin_ms_va_start(ap, a); // expected-error {{'__builtin_ms_va_start' used in System V ABI function}}
+}
+
+void __attribute__((ms_abi)) g1(int a) {
+ __builtin_ms_va_list ap;
+
+ __builtin_ms_va_start(ap, a, a); // expected-error {{too many arguments to function}}
+ __builtin_ms_va_start(ap, a); // expected-error {{'va_start' used in function with fixed args}}
+}
+
+void __attribute__((ms_abi)) g2(int a, int b, ...) {
+ __builtin_ms_va_list ap;
+
+ __builtin_ms_va_start(ap, 10); // expected-warning {{second parameter of 'va_start' not last named argument}}
+ __builtin_ms_va_start(ap, a); // expected-warning {{second parameter of 'va_start' not last named argument}}
+ __builtin_ms_va_start(ap, b);
+}
+
+void __attribute__((ms_abi)) g3(float a, ...) {
+ __builtin_ms_va_list ap;
+
+ __builtin_ms_va_start(ap, a);
+ __builtin_ms_va_start(ap, (a));
+}
+
+void __attribute__((ms_abi)) g5() {
+ __builtin_ms_va_list ap;
+ __builtin_ms_va_start(ap, ap); // expected-error {{'va_start' used in function with fixed args}}
+}
+
+void __attribute__((ms_abi)) g6(int a, ...) {
+ __builtin_ms_va_list ap;
+ __builtin_ms_va_start(ap); // expected-error {{too few arguments to function}}
+}
+
+void __attribute__((ms_abi))
+bar(__builtin_ms_va_list authors, ...) {
+ __builtin_ms_va_start(authors, authors);
+ (void)__builtin_va_arg(authors, int);
+ __builtin_ms_va_end(authors);
+}
+
+void __attribute__((ms_abi)) g7(int a, ...) {
+ __builtin_ms_va_list ap;
+ __builtin_ms_va_start(ap, a);
+ // FIXME: This error message is sub-par.
+ __builtin_va_arg(ap, int) = 1; // expected-error {{expression is not assignable}}
+ int *x = &__builtin_va_arg(ap, int); // expected-error {{cannot take the address of an rvalue}}
+ __builtin_ms_va_end(ap);
+}
+
+void __attribute__((ms_abi)) g8(int a, ...) {
+ __builtin_ms_va_list ap;
+ __builtin_ms_va_start(ap, a);
+ (void)__builtin_va_arg(ap, void); // expected-error {{second argument to 'va_arg' is of incomplete type 'void'}}
+ __builtin_ms_va_end(ap);
+}
+
+enum E { x = -1, y = 2, z = 10000 };
+void __attribute__((ms_abi)) g9(__builtin_ms_va_list args) {
+ (void)__builtin_va_arg(args, float); // expected-warning {{second argument to 'va_arg' is of promotable type 'float'}}
+ (void)__builtin_va_arg(args, enum E); // no-warning
+ (void)__builtin_va_arg(args, short); // expected-warning {{second argument to 'va_arg' is of promotable type 'short'}}
+ (void)__builtin_va_arg(args, char); // expected-warning {{second argument to 'va_arg' is of promotable type 'char'}}
+}
+
+void __attribute__((ms_abi)) g10(int a, ...) {
+ __builtin_va_list ap;
+ __builtin_va_start(ap, a); // expected-error {{'va_start' used in Win64 ABI function}}
+}
diff --git a/test/Sema/vector-cast.c b/test/Sema/vector-cast.c
index 0415c13990c8..03db5408c458 100644
--- a/test/Sema/vector-cast.c
+++ b/test/Sema/vector-cast.c
@@ -3,12 +3,20 @@
typedef long long t1 __attribute__ ((vector_size (8)));
typedef char t2 __attribute__ ((vector_size (16)));
typedef float t3 __attribute__ ((vector_size (16)));
+typedef short s2 __attribute__ ((vector_size(4)));
+
+typedef enum { Evalue = 0x10000 } E;
void f()
{
t1 v1;
t2 v2;
t3 v3;
+ s2 v4;
+ E e;
+
+ e = (E)v4;
+ v4 = (s2)e;
v2 = (t2)v1; // expected-error {{invalid conversion between vector type \
't2' (vector of 16 'char' values) and 't1' (vector of 1 'long long' value) of different size}}
diff --git a/test/Sema/warn-absolute-value.c b/test/Sema/warn-absolute-value.c
index 70601db63a1f..109d515d3b2b 100644
--- a/test/Sema/warn-absolute-value.c
+++ b/test/Sema/warn-absolute-value.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value -Wno-int-conversion
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -Wno-int-conversion -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
int abs(int);
long int labs(long int);
@@ -780,3 +780,19 @@ void test_unsigned_long(unsigned long x) {
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
}
+long long test_array() {
+ return llabs((long long[]){1});
+ // expected-warning@-1 {{absolute value of array type}}
+}
+long long test_function_pointer() {
+ return llabs(&test_function_pointer);
+ // expected-warning@-1 {{absolute value of pointer type}}
+}
+long long test_void_pointer(void *x) {
+ return llabs(x);
+ // expected-warning@-1 {{absolute value of pointer type}}
+}
+long long test_function() {
+ return llabs(test_function);
+ // expected-warning@-1 {{absolute value of function type}}
+}
diff --git a/test/Sema/warn-double-promotion.c b/test/Sema/warn-double-promotion.c
new file mode 100644
index 000000000000..b6fd0c5ec629
--- /dev/null
+++ b/test/Sema/warn-double-promotion.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s -Wdouble-promotion
+
+float ReturnFloatFromDouble(double d) {
+ return d;
+}
+
+float ReturnFloatFromLongDouble(long double ld) {
+ return ld;
+}
+
+double ReturnDoubleFromLongDouble(long double ld) {
+ return ld;
+}
+
+double ReturnDoubleFromFloat(float f) {
+ return f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
+}
+
+long double ReturnLongDoubleFromFloat(float f) {
+ return f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
+}
+
+long double ReturnLongDoubleFromDouble(double d) {
+ return d; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
+}
+
+void Convert(float f, double d, long double ld) {
+ d = f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
+ ld = f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
+ ld = d; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
+ f = d;
+ f = ld;
+ d = ld;
+}
diff --git a/test/Sema/warn-extern-main.c b/test/Sema/warn-extern-main.c
new file mode 100644
index 000000000000..62c2c9b4a86c
--- /dev/null
+++ b/test/Sema/warn-extern-main.c
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST1
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST2
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST3
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST4
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST5
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST6
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST7
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST8
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST9 -ffreestanding
+
+#if TEST1
+int main; // expected-warning{{variable named 'main' with external linkage has undefined behavior}}
+
+#elif TEST2
+extern int main; // expected-warning{{variable named 'main' with external linkage has undefined behavior}}
+
+#elif TEST3
+// expected-no-diagnostics
+void x() {
+ static int main;
+}
+
+#elif TEST4
+void x() {
+ extern int main; // expected-warning{{variable named 'main' with external linkage has undefined behavior}}
+}
+
+#elif TEST5
+// expected-no-diagnostics
+void x() {
+ int main;
+}
+
+#elif TEST6
+// expected-no-diagnostics
+static int main;
+
+#elif TEST7
+// expected-no-diagnostics
+void x() {
+ auto int main;
+}
+
+#elif TEST8
+// expected-no-diagnostics
+void x() {
+ register int main;
+}
+
+#elif TEST9
+// expected-no-diagnostics
+int main;
+
+#else
+#error Unknown Test
+#endif
diff --git a/test/Sema/warn-logical-not-compare.c b/test/Sema/warn-logical-not-compare.c
new file mode 100644
index 000000000000..b67845ec84a0
--- /dev/null
+++ b/test/Sema/warn-logical-not-compare.c
@@ -0,0 +1,204 @@
+// RUN: %clang_cc1 -fsyntax-only -Wlogical-not-parentheses -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wlogical-not-parentheses -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+int getInt();
+
+int test1(int i1, int i2) {
+ int ret;
+
+ ret = !i1 == i2;
+ // expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:9: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
+ // CHECK: to silence this warning
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
+
+ ret = !i1 != i2;
+ //expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:9: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
+ // CHECK: to silence this warning
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
+
+ ret = !i1 < i2;
+ //expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:9: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:17-[[line]]:17}:")"
+ // CHECK: to silence this warning
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
+
+ ret = !i1 > i2;
+ //expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:9: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:17-[[line]]:17}:")"
+ // CHECK: to silence this warning
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
+
+ ret = !i1 <= i2;
+ //expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:9: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
+ // CHECK: to silence this warning
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
+
+ ret = !i1 >= i2;
+ //expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:9: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
+ // CHECK: to silence this warning
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
+
+ ret = i1 == i2;
+ ret = i1 != i2;
+ ret = i1 < i2;
+ ret = i1 > i2;
+ ret = i1 <= i2;
+ ret = i1 >= i2;
+
+ // Warning silenced by parens.
+ ret = (!i1) == i2;
+ ret = (!i1) != i2;
+ ret = (!i1) < i2;
+ ret = (!i1) > i2;
+ ret = (!i1) <= i2;
+ ret = (!i1) >= i2;
+
+ ret = !getInt() == i1;
+ // expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:9: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:24-[[line]]:24}:")"
+ // CHECK: to silence this warning
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
+
+ ret = (!getInt()) == i1;
+ return ret;
+}
+
+enum E {e1, e2};
+enum E getE();
+
+int test2 (enum E e) {
+ int ret;
+ ret = e == e1;
+ ret = e == getE();
+ ret = getE() == e1;
+ ret = getE() == getE();
+
+ ret = !e == e1;
+ // expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:9: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:17-[[line]]:17}:")"
+ // CHECK: to silence this warning
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:11-[[line]]:11}:")"
+
+ ret = !e == getE();
+ // expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:9: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:21-[[line]]:21}:")"
+ // CHECK: to silence this warning
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:11-[[line]]:11}:")"
+
+ ret = !getE() == e1;
+ // expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:9: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:22-[[line]]:22}:")"
+ // CHECK: to silence this warning
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:16-[[line]]:16}:")"
+
+ ret = !getE() == getE();
+ // expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:9: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:26-[[line]]:26}:")"
+ // CHECK: to silence this warning
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:16-[[line]]:16}:")"
+
+ ret = !(e == e1);
+ ret = !(e == getE());
+ ret = !(getE() == e1);
+ ret = !(getE() == getE());
+
+ ret = (!e) == e1;
+ ret = (!e) == getE();
+ ret = (!getE()) == e1;
+ ret = (!getE()) == getE();
+
+ return ret;
+}
+
+int PR16673(int x) {
+ int ret;
+ // Make sure we don't emit a fixit for the left paren, but not the right paren.
+#define X(x) x
+ ret = X(!x == 1 && 1);
+ // expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
+ // expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
+ // expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.c:[[line:[0-9]*]]:11: warning
+ // CHECK: to evaluate the comparison first
+ // CHECK-NOT: fix-it
+ // CHECK: to silence this warning
+ // CHECK-NOT: fix-it
+ return ret;
+}
+
+int compare_pointers(int* a, int* b) {
+ int ret;
+ ret = !!a == !!b;
+ ret = !!a != !!b;
+ return ret;
+}
diff --git a/test/Sema/warn-overlap.c b/test/Sema/warn-overlap.c
index 44d6ad5efa5e..1e8a614d0ffc 100644
--- a/test/Sema/warn-overlap.c
+++ b/test/Sema/warn-overlap.c
@@ -2,6 +2,16 @@
#define mydefine 2
+enum Choices {
+ CHOICE_0 = 0,
+ CHOICE_1 = 1
+};
+
+enum Unchoices {
+ UNCHOICE_0 = 0,
+ UNCHOICE_1 = 1
+};
+
void f(int x) {
int y = 0;
@@ -54,6 +64,30 @@ void f(int x) {
if (x == mydefine && x > 3) { }
if (x == (mydefine + 1) && x > 3) { }
+
+ if (x != CHOICE_0 || x != CHOICE_1) { } // expected-warning {{overlapping comparisons always evaluate to true}}
+ if (x == CHOICE_0 && x == CHOICE_1) { } // expected-warning {{overlapping comparisons always evaluate to false}}
+
+ // Don't warn if comparing x to different types
+ if (x == CHOICE_0 && x == 1) { }
+ if (x != CHOICE_0 || x != 1) { }
+
+ // "Different types" includes different enums
+ if (x == CHOICE_0 && x == UNCHOICE_1) { }
+ if (x != CHOICE_0 || x != UNCHOICE_1) { }
+}
+
+void enums(enum Choices c) {
+ if (c != CHOICE_0 || c != CHOICE_1) { } // expected-warning {{overlapping comparisons always evaluate to true}}
+ if (c == CHOICE_0 && c == CHOICE_1) { } // expected-warning {{overlapping comparisons always evaluate to false}}
+
+ // Don't warn if comparing x to different types
+ if (c == CHOICE_0 && c == 1) { }
+ if (c != CHOICE_0 || c != 1) { }
+
+ // "Different types" includes different enums
+ if (c == CHOICE_0 && c == UNCHOICE_1) { }
+ if (c != CHOICE_0 || c != UNCHOICE_1) { }
}
// Don't generate a warning here.
diff --git a/test/Sema/warn-sizeof-arrayarg.c b/test/Sema/warn-sizeof-arrayarg.c
index ba8a5fa975a4..32fd2b4d3745 100644
--- a/test/Sema/warn-sizeof-arrayarg.c
+++ b/test/Sema/warn-sizeof-arrayarg.c
@@ -4,11 +4,7 @@ typedef int Arr[10];
typedef int trungl_int;
-void f(int a[10], Arr arr) { // \
-// expected-note {{declared here}} \
-// expected-note {{declared here}} \
-// expected-note {{declared here}} \
-// expected-note {{declared here}}
+void f(int a[10], Arr arr) { // expected-note 4 {{declared here}}
/* Should warn. */
(void)sizeof(a); // \
diff --git a/test/Sema/warn-thread-safety-analysis.c b/test/Sema/warn-thread-safety-analysis.c
index 55e6e707f013..a0c4026b9136 100644
--- a/test/Sema/warn-thread-safety-analysis.c
+++ b/test/Sema/warn-thread-safety-analysis.c
@@ -81,7 +81,8 @@ int main() {
mutex_shared_lock(&mu2);
Foo_fun1(1);
- mutex_shared_lock(&mu1); // expected-warning{{acquiring mutex 'mu1' that is already held}}
+ mutex_shared_lock(&mu1); // expected-warning{{acquiring mutex 'mu1' that is already held}} \
+ expected-warning{{mutex 'mu1' must be acquired before 'mu2'}}
mutex_unlock(&mu1);
mutex_unlock(&mu2);
mutex_shared_lock(&mu1);
diff --git a/test/Sema/zvector.c b/test/Sema/zvector.c
index 5220a629cfe1..d1cf1aa01f4b 100644
--- a/test/Sema/zvector.c
+++ b/test/Sema/zvector.c
@@ -309,14 +309,14 @@ void foo(void)
// -------------------------------------------------------------------------
sc = sc + sc2;
- sc = sc + uc2; // expected-error {{can't convert}}
- sc = uc + sc2; // expected-error {{can't convert}}
+ sc = sc + uc2; // expected-error {{cannot convert}}
+ sc = uc + sc2; // expected-error {{cannot convert}}
sc = sc + bc2;
sc = bc + sc2;
uc = uc + uc2;
- uc = sc + uc2; // expected-error {{can't convert}}
- uc = uc + sc2; // expected-error {{can't convert}}
+ uc = sc + uc2; // expected-error {{cannot convert}}
+ uc = uc + sc2; // expected-error {{cannot convert}}
uc = bc + uc2;
uc = uc + bc2;
@@ -326,14 +326,14 @@ void foo(void)
bc = bc + sc2; // expected-error {{incompatible type}}
bc = sc + bc2; // expected-error {{incompatible type}}
- sc = sc + sc_scalar; // expected-error {{can't convert}}
- sc = sc + uc_scalar; // expected-error {{can't convert}}
- sc = sc_scalar + sc; // expected-error {{can't convert}}
- sc = uc_scalar + sc; // expected-error {{can't convert}}
- uc = uc + sc_scalar; // expected-error {{can't convert}}
- uc = uc + uc_scalar; // expected-error {{can't convert}}
- uc = sc_scalar + uc; // expected-error {{can't convert}}
- uc = uc_scalar + uc; // expected-error {{can't convert}}
+ sc = sc + sc_scalar; // expected-error {{cannot convert}}
+ sc = sc + uc_scalar; // expected-error {{cannot convert}}
+ sc = sc_scalar + sc; // expected-error {{cannot convert}}
+ sc = uc_scalar + sc; // expected-error {{cannot convert}}
+ uc = uc + sc_scalar; // expected-error {{cannot convert}}
+ uc = uc + uc_scalar; // expected-error {{cannot convert}}
+ uc = sc_scalar + uc; // expected-error {{cannot convert}}
+ uc = uc_scalar + uc; // expected-error {{cannot convert}}
ss = ss + ss2;
us = us + us2;
@@ -348,30 +348,30 @@ void foo(void)
bl = bl + bl2; // expected-error {{invalid operands}}
fd = fd + fd2;
- fd = fd + ul2; // expected-error {{can't convert}}
- fd = sl + fd2; // expected-error {{can't convert}}
+ fd = fd + ul2; // expected-error {{cannot convert}}
+ fd = sl + fd2; // expected-error {{cannot convert}}
sc += sc2;
- sc += uc2; // expected-error {{can't convert}}
+ sc += uc2; // expected-error {{cannot convert}}
sc += bc2;
uc += uc2;
- uc += sc2; // expected-error {{can't convert}}
+ uc += sc2; // expected-error {{cannot convert}}
uc += bc2;
bc += bc2; // expected-error {{invalid operands}}
- bc += sc2; // expected-error {{can't convert}}
- bc += uc2; // expected-error {{can't convert}}
+ bc += sc2; // expected-error {{cannot convert}}
+ bc += uc2; // expected-error {{cannot convert}}
- sc += ss2; // expected-error {{can't convert}}
- sc += si2; // expected-error {{can't convert}}
- sc += sl2; // expected-error {{can't convert}}
- sc += fd2; // expected-error {{can't convert}}
+ sc += ss2; // expected-error {{cannot convert}}
+ sc += si2; // expected-error {{cannot convert}}
+ sc += sl2; // expected-error {{cannot convert}}
+ sc += fd2; // expected-error {{cannot convert}}
- sc += sc_scalar; // expected-error {{can't convert}}
- sc += uc_scalar; // expected-error {{can't convert}}
- uc += sc_scalar; // expected-error {{can't convert}}
- uc += uc_scalar; // expected-error {{can't convert}}
+ sc += sc_scalar; // expected-error {{cannot convert}}
+ sc += uc_scalar; // expected-error {{cannot convert}}
+ uc += sc_scalar; // expected-error {{cannot convert}}
+ uc += uc_scalar; // expected-error {{cannot convert}}
ss += ss2;
us += us2;
@@ -395,7 +395,7 @@ void foo(void)
uc = uc - uc2;
bc = bc - bc2; // expected-error {{invalid operands}}
- sc = uc - sc2; // expected-error {{can't convert}}
+ sc = uc - sc2; // expected-error {{cannot convert}}
sc = sc - bc2;
uc = bc - uc2;
@@ -403,9 +403,9 @@ void foo(void)
uc -= uc2;
bc -= bc2; // expected-error {{invalid operands}}
- sc -= uc2; // expected-error {{can't convert}}
+ sc -= uc2; // expected-error {{cannot convert}}
uc -= bc2;
- bc -= sc2; // expected-error {{can't convert}}
+ bc -= sc2; // expected-error {{cannot convert}}
ss -= ss2;
us -= us2;
@@ -430,17 +430,17 @@ void foo(void)
uc = uc * uc2;
bc = bc * bc2; // expected-error {{invalid operands}}
- sc = uc * sc2; // expected-error {{can't convert}}
- sc = sc * bc2; // expected-error {{can't convert}}
- uc = bc * uc2; // expected-error {{can't convert}}
+ sc = uc * sc2; // expected-error {{cannot convert}}
+ sc = sc * bc2; // expected-error {{cannot convert}}
+ uc = bc * uc2; // expected-error {{cannot convert}}
sc *= sc2;
uc *= uc2;
bc *= bc2; // expected-error {{invalid operands}}
- sc *= uc2; // expected-error {{can't convert}}
- uc *= bc2; // expected-error {{can't convert}}
- bc *= sc2; // expected-error {{can't convert}}
+ sc *= uc2; // expected-error {{cannot convert}}
+ uc *= bc2; // expected-error {{cannot convert}}
+ bc *= sc2; // expected-error {{cannot convert}}
ss *= ss2;
us *= us2;
@@ -464,17 +464,17 @@ void foo(void)
uc = uc / uc2;
bc = bc / bc2; // expected-error {{invalid operands}}
- sc = uc / sc2; // expected-error {{can't convert}}
- sc = sc / bc2; // expected-error {{can't convert}}
- uc = bc / uc2; // expected-error {{can't convert}}
+ sc = uc / sc2; // expected-error {{cannot convert}}
+ sc = sc / bc2; // expected-error {{cannot convert}}
+ uc = bc / uc2; // expected-error {{cannot convert}}
sc /= sc2;
uc /= uc2;
bc /= bc2; // expected-error {{invalid operands}}
- sc /= uc2; // expected-error {{can't convert}}
- uc /= bc2; // expected-error {{can't convert}}
- bc /= sc2; // expected-error {{can't convert}}
+ sc /= uc2; // expected-error {{cannot convert}}
+ uc /= bc2; // expected-error {{cannot convert}}
+ bc /= sc2; // expected-error {{cannot convert}}
ss /= ss2;
us /= us2;
@@ -498,17 +498,17 @@ void foo(void)
uc = uc % uc2;
bc = bc % bc2; // expected-error {{invalid operands}}
- sc = uc % sc2; // expected-error {{can't convert}}
- sc = sc % bc2; // expected-error {{can't convert}}
- uc = bc % uc2; // expected-error {{can't convert}}
+ sc = uc % sc2; // expected-error {{cannot convert}}
+ sc = sc % bc2; // expected-error {{cannot convert}}
+ uc = bc % uc2; // expected-error {{cannot convert}}
sc %= sc2;
uc %= uc2;
bc %= bc2; // expected-error {{invalid operands}}
- sc %= uc2; // expected-error {{can't convert}}
- uc %= bc2; // expected-error {{can't convert}}
- bc %= sc2; // expected-error {{can't convert}}
+ sc %= uc2; // expected-error {{cannot convert}}
+ uc %= bc2; // expected-error {{cannot convert}}
+ bc %= sc2; // expected-error {{cannot convert}}
ss %= ss2;
us %= us2;
@@ -529,14 +529,14 @@ void foo(void)
// -------------------------------------------------------------------------
sc = sc & sc2;
- sc = sc & uc2; // expected-error {{can't convert}}
- sc = uc & sc2; // expected-error {{can't convert}}
+ sc = sc & uc2; // expected-error {{cannot convert}}
+ sc = uc & sc2; // expected-error {{cannot convert}}
sc = sc & bc2;
sc = bc & sc2;
uc = uc & uc2;
- uc = sc & uc2; // expected-error {{can't convert}}
- uc = uc & sc2; // expected-error {{can't convert}}
+ uc = sc & uc2; // expected-error {{cannot convert}}
+ uc = uc & sc2; // expected-error {{cannot convert}}
uc = bc & uc2;
uc = uc & bc2;
@@ -553,25 +553,25 @@ void foo(void)
fd = fd & ul2; // expected-error {{invalid operands}}
sc &= sc2;
- sc &= uc2; // expected-error {{can't convert}}
+ sc &= uc2; // expected-error {{cannot convert}}
sc &= bc2;
uc &= uc2;
- uc &= sc2; // expected-error {{can't convert}}
+ uc &= sc2; // expected-error {{cannot convert}}
uc &= bc2;
bc &= bc2;
- bc &= sc2; // expected-error {{can't convert}}
- bc &= uc2; // expected-error {{can't convert}}
+ bc &= sc2; // expected-error {{cannot convert}}
+ bc &= uc2; // expected-error {{cannot convert}}
- sc &= ss2; // expected-error {{can't convert}}
- sc &= si2; // expected-error {{can't convert}}
- sc &= sl2; // expected-error {{can't convert}}
+ sc &= ss2; // expected-error {{cannot convert}}
+ sc &= si2; // expected-error {{cannot convert}}
+ sc &= sl2; // expected-error {{cannot convert}}
sc &= fd2; // expected-error {{invalid operands}}
- us &= bc2; // expected-error {{can't convert}}
- ui &= bc2; // expected-error {{can't convert}}
- ul &= bc2; // expected-error {{can't convert}}
+ us &= bc2; // expected-error {{cannot convert}}
+ ui &= bc2; // expected-error {{cannot convert}}
+ ul &= bc2; // expected-error {{cannot convert}}
fd &= bc2; // expected-error {{invalid operands}}
ss &= ss2;
@@ -591,11 +591,11 @@ void foo(void)
// -------------------------------------------------------------------------
sc = sc | sc2;
- sc = sc | uc2; // expected-error {{can't convert}}
+ sc = sc | uc2; // expected-error {{cannot convert}}
sc = sc | bc2;
uc = uc | uc2;
- uc = sc | uc2; // expected-error {{can't convert}}
+ uc = sc | uc2; // expected-error {{cannot convert}}
uc = bc | uc2;
bc = bc | bc2;
@@ -625,11 +625,11 @@ void foo(void)
// -------------------------------------------------------------------------
sc = sc ^ sc2;
- sc = sc ^ uc2; // expected-error {{can't convert}}
+ sc = sc ^ uc2; // expected-error {{cannot convert}}
sc = sc ^ bc2;
uc = uc ^ uc2;
- uc = sc ^ uc2; // expected-error {{can't convert}}
+ uc = sc ^ uc2; // expected-error {{cannot convert}}
uc = bc ^ uc2;
bc = bc ^ bc2;
@@ -862,10 +862,10 @@ void foo(void)
(void)(uc == uc2);
(void)(bc == bc2);
- (void)(sc == uc); // expected-error {{can't convert}}
+ (void)(sc == uc); // expected-error {{cannot convert}}
(void)(sc == bc);
- (void)(uc == sc); // expected-error {{can't convert}}
+ (void)(uc == sc); // expected-error {{cannot convert}}
(void)(uc == bc);
(void)(bc == sc);
@@ -884,8 +884,8 @@ void foo(void)
(void)(bl == bl2);
(void)(fd == fd2);
- (void)(fd == ul); // expected-error {{can't convert}}
- (void)(ul == fd); // expected-error {{can't convert}}
+ (void)(fd == ul); // expected-error {{cannot convert}}
+ (void)(ul == fd); // expected-error {{cannot convert}}
// -------------------------------------------------------------------------
// Test that == rules apply to != too.
@@ -895,7 +895,7 @@ void foo(void)
(void)(uc != uc2);
(void)(bc != bc2);
- (void)(sc != uc); // expected-error {{can't convert}}
+ (void)(sc != uc); // expected-error {{cannot convert}}
(void)(sc != bc);
(void)(ss != ss2);
@@ -919,7 +919,7 @@ void foo(void)
(void)(uc <= uc2);
(void)(bc <= bc2);
- (void)(sc <= uc); // expected-error {{can't convert}}
+ (void)(sc <= uc); // expected-error {{cannot convert}}
(void)(sc <= bc);
(void)(ss <= ss2);
@@ -943,7 +943,7 @@ void foo(void)
(void)(uc >= uc2);
(void)(bc >= bc2);
- (void)(sc >= uc); // expected-error {{can't convert}}
+ (void)(sc >= uc); // expected-error {{cannot convert}}
(void)(sc >= bc);
(void)(ss >= ss2);
@@ -967,7 +967,7 @@ void foo(void)
(void)(uc < uc2);
(void)(bc < bc2);
- (void)(sc < uc); // expected-error {{can't convert}}
+ (void)(sc < uc); // expected-error {{cannot convert}}
(void)(sc < bc);
(void)(ss < ss2);
@@ -991,7 +991,7 @@ void foo(void)
(void)(uc > uc2);
(void)(bc > bc2);
- (void)(sc > uc); // expected-error {{can't convert}}
+ (void)(sc > uc); // expected-error {{cannot convert}}
(void)(sc > bc);
(void)(ss > ss2);