diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:02:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:02:28 +0000 |
commit | 7442d6faa2719e4e7d33a7021c406c5a4facd74d (patch) | |
tree | c72b9241553fc9966179aba84f90f17bfa9235c3 /test/Sema | |
parent | b52119637f743680a99710ce5fdb6646da2772af (diff) |
Notes
Diffstat (limited to 'test/Sema')
35 files changed, 561 insertions, 64 deletions
diff --git a/test/Sema/address-unaligned.c b/test/Sema/address-unaligned.c new file mode 100644 index 0000000000000..6719509051b3d --- /dev/null +++ b/test/Sema/address-unaligned.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify %s +// expected-no-diagnostics + +typedef +struct __attribute__((packed)) S1 { + char c0; + int x; + char c1; +} S1; + +void bar(__unaligned int *); + +void foo(__unaligned S1* s1) +{ + bar(&s1->x); +} diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c index 3fe93155451fd..018a8521bfc50 100644 --- a/test/Sema/address_spaces.c +++ b/test/Sema/address_spaces.c @@ -20,7 +20,7 @@ void foo(_AS3 float *a, _AS1 int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}} __attribute__((address_space(-1))) int *_boundsA; // expected-error {{address space is negative}} - __attribute__((address_space(0x7FFFFF))) int *_boundsB; + __attribute__((address_space(0x7FFFFF))) int *_boundsB; // expected-error {{address space is larger than the maximum supported}} __attribute__((address_space(0x1000000))) int *_boundsC; // expected-error {{address space is larger than the maximum supported}} // chosen specifically to overflow 32 bits and come out reasonable __attribute__((address_space(4294967500))) int *_boundsD; // expected-error {{address space is larger than the maximum supported}} diff --git a/test/Sema/alias-redefinition.c b/test/Sema/alias-redefinition.c index 91f4b2714cd03..a4c06eebf499b 100644 --- a/test/Sema/alias-redefinition.c +++ b/test/Sema/alias-redefinition.c @@ -19,9 +19,8 @@ void f4() {} void fun4(void) __attribute((alias("f4"))); void fun4(void); -// FIXME: We should produce a special case error for this. void f5() {} -void __attribute((alias("f5"))) fun5(void) {} // expected-error {{redefinition of 'fun5'}} // expected-note {{previous definition}} +void __attribute((alias("f5"))) fun5(void) {} // expected-error {{definition 'fun5' cannot also be an alias}} int var1 __attribute((alias("v1"))); // expected-error {{definition 'var1' cannot also be an alias}} static int var2 __attribute((alias("v2"))) = 2; // expected-error {{definition 'var2' cannot also be an alias}} diff --git a/test/Sema/alloc-align-attr.c b/test/Sema/alloc-align-attr.c new file mode 100644 index 0000000000000..bf8591625dab2 --- /dev/null +++ b/test/Sema/alloc-align-attr.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// return values +void test_void_alloc_align(void) __attribute__((alloc_align(1))); // expected-warning {{'alloc_align' attribute only applies to return values that are pointers}} +void *test_ptr_alloc_align(int a) __attribute__((alloc_align(1))); // no-warning + +int j __attribute__((alloc_align(1))); // expected-warning {{'alloc_align' attribute only applies to non-K&R-style functions}} +void *test_no_params_zero(void) __attribute__((alloc_align(0))); // expected-error {{'alloc_align' attribute parameter 1 is out of bounds}} +void *test_no_params(void) __attribute__((alloc_align(1))); // expected-error {{'alloc_align' attribute parameter 1 is out of bounds}} +void *test_incorrect_param_type(float a) __attribute__((alloc_align(1))); // expected-error {{'alloc_align' attribute argument may only refer to a function parameter of integer type}} + +// argument type +void *test_bad_param_type(void) __attribute((alloc_align(1.1))); // expected-error {{'alloc_align' attribute requires parameter 1 to be an integer constant}} + +// argument count +void *test_no_fn_proto() __attribute__((alloc_align)); // expected-error {{'alloc_align' attribute takes one argument}} +void *test_no_fn_proto() __attribute__((alloc_align())); // expected-error {{'alloc_align' attribute takes one argument}} +void *test_no_fn_proto() __attribute__((alloc_align(32, 45, 37))); // expected-error {{'alloc_align' attribute takes one argument}} + diff --git a/test/Sema/altivec-init.c b/test/Sema/altivec-init.c index 973aab15d4660..1c20450a6d015 100644 --- a/test/Sema/altivec-init.c +++ b/test/Sema/altivec-init.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple=powerpc-apple-darwin8 -faltivec -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 %s -triple=powerpc-apple-darwin8 -target-feature +altivec -verify -pedantic -fsyntax-only typedef int v4 __attribute((vector_size(16))); typedef short v8 __attribute((vector_size(16))); @@ -23,8 +23,8 @@ v8 foo(void) { return (v8){0, 1, 2, 3, 1, 2, 3, 4}; - // FIXME: test that (type)(fn)(args) still works with -faltivec - // FIXME: test that c++ overloaded commas still work -faltivec + // FIXME: test that (type)(fn)(args) still works with -maltivec + // FIXME: test that c++ overloaded commas still work -maltivec } void __attribute__((__overloadable__)) f(v4 a) diff --git a/test/Sema/arm-interrupt-attr.c b/test/Sema/arm-interrupt-attr.c index b9684f0b46c1e..3a6cdbe0e0725 100644 --- a/test/Sema/arm-interrupt-attr.c +++ b/test/Sema/arm-interrupt-attr.c @@ -17,3 +17,19 @@ __attribute__((interrupt("UNDEF"))) void foo7() {} __attribute__((interrupt)) void foo8() {} __attribute__((interrupt())) void foo9() {} __attribute__((interrupt(""))) void foo10() {} + +void callee1(); +__attribute__((interrupt("IRQ"))) void callee2(); +void caller1() { + callee1(); + callee2(); +} +__attribute__((interrupt("IRQ"))) void caller2() { + callee1(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}} + callee2(); +} + +void (*callee3)(); +__attribute__((interrupt("IRQ"))) void caller3() { + callee3(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}} +} diff --git a/test/Sema/ast-print.c b/test/Sema/ast-print.c index 4c0aef5b2f3fc..f701b12209537 100644 --- a/test/Sema/ast-print.c +++ b/test/Sema/ast-print.c @@ -65,3 +65,12 @@ void initializers() { // CHECK: } z = {(struct Z){}}; } z = {(struct Z){}}; } + +// CHECK-LABEL: enum EnumWithAttributes { +enum EnumWithAttributes { + // CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))), + EnumWithAttributesFoo __attribute__((deprecated)), + // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50 + EnumWithAttributesBar __attribute__((unavailable)) = 50 + // CHECK-NEXT: } __attribute__((deprecated(""))) +} __attribute__((deprecated)); diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c index 8566a0e94362b..89c06860fb4e6 100644 --- a/test/Sema/attr-deprecated.c +++ b/test/Sema/attr-deprecated.c @@ -1,10 +1,12 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only +// RUN: %clang_cc1 %s -std=c89 -verify -fsyntax-only +// RUN: %clang_cc1 %s -std=c99 -verify -fsyntax-only int f() __attribute__((deprecated)); // expected-note 2 {{'f' has been explicitly marked deprecated here}} -void g() __attribute__((deprecated)); -void g(); // expected-note {{'g' has been explicitly marked deprecated here}} +void g() __attribute__((deprecated));// expected-note {{'g' has been explicitly marked deprecated here}} +void g(); -extern int var __attribute__((deprecated)); // expected-note {{'var' has been explicitly marked deprecated here}} +extern int var __attribute__((deprecated)); // expected-note 2 {{'var' has been explicitly marked deprecated here}} int a() { int (*ptr)() = f; // expected-warning {{'f' is deprecated}} @@ -17,13 +19,13 @@ int a() { } // test if attributes propagate to variables -extern int var; // expected-note {{'var' has been explicitly marked deprecated here}} +extern int var; int w() { return var; // expected-warning {{'var' is deprecated}} } -int old_fn() __attribute__ ((deprecated)); -int old_fn(); // expected-note {{'old_fn' has been explicitly marked deprecated here}} +int old_fn() __attribute__ ((deprecated));// expected-note {{'old_fn' has been explicitly marked deprecated here}} +int old_fn(); int (*fn_ptr)() = old_fn; // expected-warning {{'old_fn' is deprecated}} int old_fn() { @@ -44,8 +46,8 @@ void test1(struct foo *F) { typedef struct foo foo_dep __attribute__((deprecated)); // expected-note 12 {{'foo_dep' has been explicitly marked deprecated here}} foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}} -struct __attribute__((deprecated, - invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}} expected-note 2 {{'bar_dep' has been explicitly marked deprecated here}} +struct __attribute__((deprecated, // expected-note 2 {{'bar_dep' has been explicitly marked deprecated here}} + invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}} struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}} @@ -121,11 +123,12 @@ struct test22 { __attribute((deprecated)) foo_dep e, f; }; -typedef int test23_ty __attribute((deprecated)); +typedef int test23_ty __attribute((deprecated)); // Redefining a typedef is a C11 feature. #if __STDC_VERSION__ <= 199901L // expected-note@-3 {{'test23_ty' has been explicitly marked deprecated here}} #else -typedef int test23_ty; // expected-note {{'test23_ty' has been explicitly marked deprecated here}} +// expected-note@-5 {{'test23_ty' has been explicitly marked deprecated here}} +typedef int test23_ty; #endif test23_ty test23_v; // expected-warning {{'test23_ty' is deprecated}} diff --git a/test/Sema/attr-external-source-symbol.c b/test/Sema/attr-external-source-symbol.c new file mode 100644 index 0000000000000..af6e6bc79e7b6 --- /dev/null +++ b/test/Sema/attr-external-source-symbol.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s + +void threeClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration))); + +void twoClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module"))); + +void fourClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}} + +void oneClause() __attribute__((external_source_symbol(generated_declaration))); + +void noArguments() +__attribute__((external_source_symbol)); // expected-error {{'external_source_symbol' attribute takes at least 1 argument}} + +void namedDeclsOnly() { + int (^block)(void) = ^ (void) + __attribute__((external_source_symbol(language="Swift"))) { // expected-warning {{'external_source_symbol' attribute only applies to named declarations}} + return 1; + }; +} diff --git a/test/Sema/attr-ifunc.c b/test/Sema/attr-ifunc.c index d177b7168488f..8f9c22f849272 100644 --- a/test/Sema/attr-ifunc.c +++ b/test/Sema/attr-ifunc.c @@ -39,5 +39,9 @@ void f1() __attribute__((ifunc("f1_ifunc"))); //expected-error@-1 {{definition with same mangled name as another definition}} void* f1_ifunc() { return 0; } +void* f6_ifunc(int i); +void __attribute__((ifunc("f6_ifunc"))) f6() {} +//expected-error@-1 {{definition 'f6' cannot also be an ifunc}} + #endif #endif diff --git a/test/Sema/auto-type.c b/test/Sema/auto-type.c index 9fadb90c2cda8..ff7228785ac38 100644 --- a/test/Sema/auto-type.c +++ b/test/Sema/auto-type.c @@ -7,7 +7,7 @@ __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}} +__auto_type e = e; // expected-error {{variable 'e' declared with deduced type '__auto_type' cannot appear in its own initializer}} struct s { __auto_type a; }; // expected-error {{'__auto_type' not allowed in struct member}} diff --git a/test/Sema/avr-interrupt-attr.c b/test/Sema/avr-interrupt-attr.c new file mode 100644 index 0000000000000..2dfc72a354da3 --- /dev/null +++ b/test/Sema/avr-interrupt-attr.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 %s -triple avr-unknown-unknown -verify -fsyntax-only +struct a { int b; }; + +struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions}} + +__attribute__((interrupt(12))) void foo(void) { } // expected-error {{'interrupt' attribute takes no arguments}} + +__attribute__((interrupt)) void food() {} diff --git a/test/Sema/avr-signal-attr.c b/test/Sema/avr-signal-attr.c new file mode 100644 index 0000000000000..a5920bf4045c6 --- /dev/null +++ b/test/Sema/avr-signal-attr.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 %s -triple avr-unknown-unknown -verify -fsyntax-only +struct a { int b; }; + +struct a test __attribute__((signal)); // expected-warning {{'signal' attribute only applies to functions}} + +__attribute__((signal(12))) void foo(void) { } // expected-error {{'signal' attribute takes no arguments}} + +__attribute__((signal)) void food() {} diff --git a/test/Sema/builtins-ppc.c b/test/Sema/builtins-ppc.c index 60872a614e4c8..5c45d02b414cb 100644 --- a/test/Sema/builtins-ppc.c +++ b/test/Sema/builtins-ppc.c @@ -1,9 +1,9 @@ // REQUIRES: powerpc-registered-target -// RUN: %clang_cc1 -faltivec -target-feature +htm \ +// RUN: %clang_cc1 -target-feature +altivec -target-feature +htm \ // RUN: -triple powerpc64-unknown-unknown -DTEST_HTM -fsyntax-only \ // RUN: -verify %s -// RUN: %clang_cc1 -faltivec -target-feature +crypto \ +// RUN: %clang_cc1 -target-feature +altivec -target-feature +crypto \ // RUN: -triple powerpc64le-unknown-unknown -DTEST_CRYPTO -fsyntax-only \ // RUN: -verify %s diff --git a/test/Sema/builtins-x86.c b/test/Sema/builtins-x86.c index 6929dcc650909..074efe16ade6b 100644 --- a/test/Sema/builtins-x86.c +++ b/test/Sema/builtins-x86.c @@ -4,6 +4,7 @@ typedef long long __m128i __attribute__((__vector_size__(16))); typedef float __m128 __attribute__((__vector_size__(16))); typedef double __m128d __attribute__((__vector_size__(16))); +typedef long long __m512i __attribute__((__vector_size__(64))); typedef float __m512 __attribute__((__vector_size__(64))); typedef double __m512d __attribute__((__vector_size__(64))); @@ -69,3 +70,16 @@ __m128i test__builtin_ia32_vpcomq(__m128i __a, __m128i __b) { __mmask16 test__builtin_ia32_cmpps512_mask_rounding(__m512 __a, __m512 __b, __mmask16 __u) { __builtin_ia32_cmpps512_mask(__a, __b, 0, __u, 0); // expected-error {{invalid rounding argument}} } + +__m128i test_mm_mask_i32gather_epi32(__m128i a, int const *b, __m128i c, __m128i mask) { + return __builtin_ia32_gatherd_d(a, b, c, mask, 5); // expected-error {{scale argument must be 1, 2, 4, or 8}} +} + +__m512i _mm512_mask_prefetch_i32gather_ps(__m512i index, __mmask16 mask, int const *addr) { + return __builtin_ia32_gatherpfdps(mask, index, addr, 5, 1); // expected-error {{scale argument must be 1, 2, 4, or 8}} +} + +__m512 _mm512_mask_prefetch_i32gather_ps_2(__m512i index, __mmask16 mask, int const *addr) { + return __builtin_ia32_gatherpfdps(mask, index, addr, 1, 1); // expected-error {{argument should be a value from 2 to 3}} +} + diff --git a/test/Sema/callingconv-cast.c b/test/Sema/callingconv-cast.c index 12c0dcbc256ac..599a7d1e66d7d 100644 --- a/test/Sema/callingconv-cast.c +++ b/test/Sema/callingconv-cast.c @@ -15,6 +15,13 @@ void mismatched_before_winapi(int x) {} // expected-note@+1 3 {{consider defining 'mismatched' with the 'stdcall' calling convention}} void mismatched(int x) {} +// expected-note@+1 {{consider defining 'mismatched_declaration' with the 'stdcall' calling convention}} +void mismatched_declaration(int x); + +// expected-note@+1 {{consider defining 'suggest_fix_first_redecl' with the 'stdcall' calling convention}} +void suggest_fix_first_redecl(int x); +void suggest_fix_first_redecl(int x); + typedef void (WINAPI *callback_t)(int); void take_callback(callback_t callback); @@ -46,6 +53,12 @@ int main() { // Another way to suppress the warning. take_callback((callback_t)(void*)mismatched); + // Warn on declarations as well as definitions. + // expected-warning@+1 {{cast between incompatible calling conventions 'cdecl' and 'stdcall'}} + take_callback((callback_t)mismatched_declaration); + // expected-warning@+1 {{cast between incompatible calling conventions 'cdecl' and 'stdcall'}} + take_callback((callback_t)suggest_fix_first_redecl); + // Don't warn, because we're casting from stdcall to cdecl. Usually that means // the programmer is rinsing the function pointer through some kind of opaque // API. diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index bfb58bc573e1e..1b0a325dd1883 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux %s -Wno-tautological-pointer-compare +// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux %s -Wno-tautological-pointer-compare #define EVAL_EXPR(testno, expr) int test##testno = sizeof(struct{char qq[expr];}); int x; @@ -126,7 +126,7 @@ EVAL_EXPR(48, &x != &x - 1 ? 1 : -1) EVAL_EXPR(49, &x < &x - 100 ? 1 : -1) // expected-error {{must have a constant size}} extern struct Test50S Test50; -EVAL_EXPR(50, &Test50 < (struct Test50S*)((unsigned)&Test50 + 10)) // expected-error {{must have a constant size}} +EVAL_EXPR(50, &Test50 < (struct Test50S*)((unsigned long)&Test50 + 10)) // expected-error {{must have a constant size}} // <rdar://problem/11874571> EVAL_EXPR(51, 0 != (float)1e99) @@ -137,3 +137,10 @@ void PR21945() { int i = (({}), 0l); } void PR24622(); struct PR24622 {} pr24622; EVAL_EXPR(52, &pr24622 == (void *)&PR24622); // expected-error {{must have a constant size}} + +// We evaluate these by providing 2s' complement semantics in constant +// expressions, like we do for integers. +void *PR28739a = (__int128)(unsigned long)-1 + &PR28739a; +void *PR28739b = &PR28739b + (__int128)(unsigned long)-1; +__int128 PR28739c = (&PR28739c + (__int128)(unsigned long)-1) - &PR28739c; +void *PR28739d = &(&PR28739d)[(__int128)(unsigned long)-1]; diff --git a/test/Sema/declspec-naked.c b/test/Sema/declspec-naked.c new file mode 100644 index 0000000000000..ad40941a5f002 --- /dev/null +++ b/test/Sema/declspec-naked.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fsyntax-only -fdeclspec -verify %s +// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -fsyntax-only -fdeclspec -verify %s +// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fsyntax-only -fdeclspec -verify %s +#if defined(_M_IX86) || defined(_M_ARM) +// CHECK: expected-no-diagnostics +#endif + +void __declspec(naked) f(void) {} +#if !defined(_M_IX86) && !defined(_M_ARM) +// expected-error@-2{{'naked' attribute is not supported on 'x86_64'}} +#endif diff --git a/test/Sema/designated-initializers.c b/test/Sema/designated-initializers.c index a4582deb171e2..43f3318824d58 100644 --- a/test/Sema/designated-initializers.c +++ b/test/Sema/designated-initializers.c @@ -351,3 +351,20 @@ overwrite_string4[] = { { { 'f', 'o', 'o' }, 1 }, [0].L[4] = 'x' // no-warning }; + +struct { + struct { } s1; + union { + int a; + int b; + } u1; +} s = { + .s1 = { + .x = 0, // expected-error{{field designator}} + }, + + .u1 = { + .a = 0, + .b = 0, + }, +}; diff --git a/test/Sema/enable_if.c b/test/Sema/enable_if.c index a11f53eb49303..9125bfaf0f148 100644 --- a/test/Sema/enable_if.c +++ b/test/Sema/enable_if.c @@ -139,8 +139,8 @@ void test7() { 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}} + void (*p1)(int) = &f4; // expected-error{{cannot take address of function 'f4' because it has one or more non-tautological enable_if conditions}} + void (*p2)(int) = f4; // expected-error{{cannot take address of function 'f4' because it has one or more non-tautological enable_if conditions}} } void regular_enable_if(int a) __attribute__((enable_if(a, ""))); // expected-note 3{{declared here}} diff --git a/test/Sema/enum-attr.c b/test/Sema/enum-attr.c new file mode 100644 index 0000000000000..933d8ccdcd89c --- /dev/null +++ b/test/Sema/enum-attr.c @@ -0,0 +1,130 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wassign-enum -Wswitch-enum -Wcovered-switch-default %s + +enum Enum { + A0 = 1, A1 = 10 +}; + +enum __attribute__((enum_extensibility(closed))) EnumClosed { + B0 = 1, B1 = 10 +}; + +enum __attribute__((enum_extensibility(open))) EnumOpen { + C0 = 1, C1 = 10 +}; + +enum __attribute__((flag_enum)) EnumFlag { + D0 = 1, D1 = 8 +}; + +enum __attribute__((flag_enum,enum_extensibility(closed))) EnumFlagClosed { + E0 = 1, E1 = 8 +}; + +enum __attribute__((flag_enum,enum_extensibility(open))) EnumFlagOpen { + F0 = 1, F1 = 8 +}; + +enum __attribute__((enum_extensibility(arg1))) EnumInvalidArg { // expected-warning{{'enum_extensibility' attribute argument not supported: 'arg1'}} + X0 +}; + +// FIXME: The warning should mention that enum_extensibility takes only one argument. +enum __attribute__((enum_extensibility(closed,open))) EnumTooManyArgs { // expected-error{{use of undeclared identifier 'open'}} + X1 +}; + +enum __attribute__((enum_extensibility())) EnumTooFewArgs { // expected-error{{'enum_extensibility' attribute takes one argument}} + X2 +}; + +struct __attribute__((enum_extensibility(open))) S { // expected-warning{{'enum_extensibility' attribute only applies to enums}}{ +}; + +void test() { + enum Enum t0 = 100; // expected-warning{{integer constant not in range of enumerated type}} + t0 = 1; + + switch (t0) { // expected-warning{{enumeration value 'A1' not handled in switch}} + case A0: break; + case 16: break; // expected-warning{{case value not in enumerated type}} + } + + switch (t0) { + case A0: break; + case A1: break; + default: break; // expected-warning{{default label in switch which covers all enumeration}} + } + + enum EnumClosed t1 = 100; // expected-warning{{integer constant not in range of enumerated type}} + t1 = 1; + + switch (t1) { // expected-warning{{enumeration value 'B1' not handled in switch}} + case B0: break; + case 16: break; // expected-warning{{case value not in enumerated type}} + } + + switch (t1) { + case B0: break; + case B1: break; + default: break; // expected-warning{{default label in switch which covers all enumeration}} + } + + enum EnumOpen t2 = 100; + t2 = 1; + + switch (t2) { // expected-warning{{enumeration value 'C1' not handled in switch}} + case C0: break; + case 16: break; + } + + switch (t2) { + case C0: break; + case C1: break; + default: break; + } + + enum EnumFlag t3 = 5; // expected-warning{{integer constant not in range of enumerated type}} + t3 = 9; + + switch (t3) { // expected-warning{{enumeration value 'D1' not handled in switch}} + case D0: break; + case 9: break; + case 16: break; // expected-warning{{case value not in enumerated type}} + } + + switch (t3) { + case D0: break; + case D1: break; + default: break; + } + + enum EnumFlagClosed t4 = 5; // expected-warning{{integer constant not in range of enumerated type}} + t4 = 9; + + switch (t4) { // expected-warning{{enumeration value 'E1' not handled in switch}} + case E0: break; + case 9: break; + case 16: break; // expected-warning{{case value not in enumerated type}} + } + + switch (t4) { + case E0: break; + case E1: break; + default: break; + } + + enum EnumFlagOpen t5 = 5; + t5 = 9; + + switch (t5) { // expected-warning{{enumeration value 'F1' not handled in switch}} + case F0: break; + case 9: break; + case 16: break; + } + + switch (t5) { + case F0: break; + case F1: break; + default: break; + } +} diff --git a/test/Sema/expr-address-of.c b/test/Sema/expr-address-of.c index 32bd0dfdd5b0e..480871afad2a5 100644 --- a/test/Sema/expr-address-of.c +++ b/test/Sema/expr-address-of.c @@ -102,8 +102,9 @@ char* f7() { register struct {char* x;} t1 = {"Hello"}; char* dummy1 = &(t1.x[0]); - struct {int a : 10;} t2; + struct {int a : 10; struct{int b : 10;};} t2; int* dummy2 = &(t2.a); // expected-error {{address of bit-field requested}} + int* dummy3 = &(t2.b); // expected-error {{address of bit-field requested}} void* t3 = &(*(void*)0); } diff --git a/test/Sema/invalid-assignment-constant-address-space.c b/test/Sema/invalid-assignment-constant-address-space.c deleted file mode 100644 index 77d6b331c2012..0000000000000 --- a/test/Sema/invalid-assignment-constant-address-space.c +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only - -#define OPENCL_CONSTANT 8388354 -int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0}; - -void foo() { - c[0] = 1; //expected-error{{read-only variable is not assignable}} -} diff --git a/test/Sema/knr-def-call.c b/test/Sema/knr-def-call.c index 80ad0d820b1a1..2bd4a79fd0f81 100644 --- a/test/Sema/knr-def-call.c +++ b/test/Sema/knr-def-call.c @@ -1,13 +1,13 @@ -// RUN: %clang_cc1 -Wconversion -Wliteral-conversion -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple i386-pc-unknown -Wconversion -Wliteral-conversion -fsyntax-only -verify %s // C DR #316, PR 3626. void f0(a, b, c, d) int a,b,c,d; {} -void t0(void) { +void t0(void) { f0(1); // expected-warning{{too few arguments}} } void f1(a, b) int a, b; {} -void t1(void) { +void t1(void) { f1(1, 2, 3); // expected-warning{{too many arguments}} } @@ -30,7 +30,7 @@ char *rindex(s, c) // PR8314 void proto(int); -void proto(x) +void proto(x) int x; { } @@ -39,3 +39,9 @@ void use_proto() { proto(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}} (&proto)(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}} } + +// PR31020 +void func(short d) __attribute__((cdecl)); // expected-note{{previous declaration is here}} +void __attribute__((cdecl)) func(d) + short d; // expected-warning{{promoted type 'int' of K&R function parameter is not compatible with the parameter type 'short' declared in a previous prototype}} +{} diff --git a/test/Sema/ms-inline-asm.c b/test/Sema/ms-inline-asm.c index abf10b67cce18..952112ea8cf88 100644 --- a/test/Sema/ms-inline-asm.c +++ b/test/Sema/ms-inline-asm.c @@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fms-extensions -fasm-blocks -Wno-microsoft -Wunused-label -verify -fsyntax-only +// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fms-extensions -fasm-blocks -Wno-microsoft -Wunused-label -verify -fsyntax-only void t1(void) { __asm __asm // expected-error {{__asm used with no assembly instructions}} diff --git a/test/Sema/nonnull.c b/test/Sema/nonnull.c index e98a8194dbebd..217bbb16df600 100644 --- a/test/Sema/nonnull.c +++ b/test/Sema/nonnull.c @@ -167,3 +167,10 @@ void returns_nonnull_warning_tests() { 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}} } + +void pr30828(char *p __attribute__((nonnull))); +void pr30828(char *p) {} + +void call_pr30828() { + pr30828(0); // expected-warning {{null passed to a callee that requires a non-null argument}} +} diff --git a/test/Sema/pr30306.cpp b/test/Sema/pr30306.cpp new file mode 100644 index 0000000000000..413e2f5ab5595 --- /dev/null +++ b/test/Sema/pr30306.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -x c++ -triple x86_64-pc-linux-gnu -emit-llvm < %s | FileCheck %s + +struct A { A(int); ~A(); }; +int f(const A &); +// CHECK: call void @_ZN1AC1Ei +// CHECK-NEXT: call i32 @_Z1fRK1A +// CHECK-NEXT: call void @_ZN1AD1Ev +// CHECK: call void @_ZN1AC1Ei +// CHECK-NEXT: call i32 @_Z1fRK1A +// CHECK-NEXT: call void @_ZN1AD1Ev +template<typename T> void g() { + int a[f(3)]; + int b[f(3)]; +} +int main() { g<int>(); } diff --git a/test/Sema/template-specialization.cpp b/test/Sema/template-specialization.cpp deleted file mode 100644 index ae7bc332fccee..0000000000000 --- a/test/Sema/template-specialization.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -verify -fsyntax-only %s -// Verify the absence of assertion failures when solving calls to unresolved -// template member functions. - -struct A { - template <typename T> - static void bar(int) { } // expected-note {{candidate template ignored: couldn't infer template argument 'T'}} -}; - -struct B { - template <int i> - static void foo() { - int array[i]; - A::template bar(array[0]); // expected-error {{no matching function for call to 'bar'}} - } -}; - -int main() { - B::foo<4>(); // expected-note {{in instantiation of function template specialization 'B::foo<4>'}} - return 0; -} diff --git a/test/Sema/transparent-union.c b/test/Sema/transparent-union.c index a1a67dfd26fc9..dfbadcfe62c7a 100644 --- a/test/Sema/transparent-union.c +++ b/test/Sema/transparent-union.c @@ -54,11 +54,21 @@ typedef union { aligned_struct8 s8; // expected-warning{{alignment of field}} } TU1 __attribute__((transparent_union)); +typedef union __attribute__((transparent_union)) { + aligned_struct4 s4; // expected-note{{alignment of first field}} + aligned_struct8 s8; // expected-warning{{alignment of field}} +} TU1b ; + typedef union { char c; // expected-note{{size of first field is 8 bits}} int i; // expected-warning{{size of field}} } TU2 __attribute__((transparent_union)); +typedef union __attribute__((transparent_union)){ + char c; // expected-note{{size of first field is 8 bits}} + int i; // expected-warning{{size of field}} +} TU2b; + typedef union { float f; // expected-warning{{floating}} } TU3 __attribute__((transparent_union)); @@ -98,3 +108,17 @@ union pr30520a { int b[]; } __attribute__((transparent_union)); // expected-erro union pr30520s { struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}} union pr30520s2 { int *v; struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}} + +typedef union __attribute__((__transparent_union__)) { + int *i; + struct st *s; +} TU6; + +void bar(TU6); + +void foo11(int *i) { + bar(i); +} +void foo2(struct st *s) { + bar(s); +} diff --git a/test/Sema/unaligned-qualifier.c b/test/Sema/unaligned-qualifier.c new file mode 100644 index 0000000000000..3a66c4ffbb3b2 --- /dev/null +++ b/test/Sema/unaligned-qualifier.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -fms-extensions + +int __unaligned * p1; // expected-note {{previous definition is here}} +int * p1; // expected-error {{redefinition of 'p1' with a different type: 'int *' vs '__unaligned int *'}} diff --git a/test/Sema/vector-ops.c b/test/Sema/vector-ops.c index f2953417f545e..9cdd9d2f1748a 100644 --- a/test/Sema/vector-ops.c +++ b/test/Sema/vector-ops.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion +// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple x86_64-apple-darwin10 typedef unsigned int v2u __attribute__ ((vector_size (8))); typedef int v2s __attribute__ ((vector_size (8))); typedef float v2f __attribute__ ((vector_size(8))); @@ -13,9 +13,9 @@ void test1(v2u v2ua, v2s v2sa, v2f v2fa) { (void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}} // Comparison operators - v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'int __attribute__((ext_vector_type(2)))' (vector of 2 'int' values)}} + v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} v2sa = (v2ua==v2sa); - + // Arrays int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values)}} int array2[17]; @@ -26,4 +26,110 @@ void test1(v2u v2ua, v2s v2sa, v2f v2fa) { v2s *v2s_ptr; v2s_ptr = v2u_ptr; // expected-warning{{converts between pointers to integer types with different sign}} } - + +void testLogicalVecVec(v2u v2ua, v2s v2sa, v2f v2fa) { + + // Logical operators + v2ua = v2ua && v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + v2ua = v2ua || v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + + v2ua = v2sa && v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + v2ua = v2sa || v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + + v2ua = v2ua && v2fa; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + v2ua = v2ua || v2fa; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + + v2ua = v2sa && v2fa; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + v2ua = v2sa || v2fa; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + + v2sa = v2sa && v2sa; + v2sa = v2sa || v2sa; + + v2sa = v2ua && v2ua; + v2sa = v2ua || v2ua; + + v2sa = v2sa && v2ua; + v2sa = v2sa || v2ua; + + v2sa = v2sa && v2fa; + v2sa = v2sa || v2fa; + + v2sa = v2ua && v2fa; + v2sa = v2ua || v2fa; + + v2fa = v2fa && v2fa; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + v2fa = v2fa || v2fa; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + + v2fa = v2sa && v2fa; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + v2fa = v2sa || v2fa; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + + v2fa = v2ua && v2fa; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + v2fa = v2ua || v2fa; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + + v2fa = v2ua && v2ua; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + v2fa = v2ua || v2ua; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + + v2fa = v2sa && v2sa; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + v2fa = v2sa || v2sa; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + + v2fa = v2sa && v2ua; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} + v2fa = v2sa || v2ua; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}} +} + +void testLogicalVecScalar(v2u v2ua, v2s v2sa, v2f v2fa) { + + unsigned u1; + v2ua = v2ua && u1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'unsigned int')}} + v2ua = v2ua || u1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'unsigned int')}} + + v2sa = v2sa && u1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'unsigned int')}} + v2sa = v2sa || u1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'unsigned int')}} + + v2ua = v2sa && u1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'unsigned int')}} + v2ua = v2sa || u1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'unsigned int')}} + v2sa = v2ua && u1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'unsigned int')}} + v2sa = v2ua || u1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'unsigned int')}} + + v2ua = v2fa && u1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'unsigned int')}} + v2ua = v2fa || u1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'unsigned int')}} + + v2sa = v2fa && u1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'unsigned int')}} + v2sa = v2fa || u1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'unsigned int')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'unsigned int')}} + + int s1; + v2ua = v2ua && s1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'int')}} + v2ua = v2ua || s1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'int')}} + + v2sa = v2sa && s1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'int')}} + v2sa = v2sa || s1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'int')}} + + v2ua = v2sa && s1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'int')}} + v2ua = v2sa || s1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'int')}} + v2sa = v2ua && s1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'int')}} + v2sa = v2ua || s1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'int')}} + + v2ua = v2fa && s1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'int')}} + v2ua = v2fa || s1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'int')}} + + v2sa = v2fa && s1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'int')}} + v2sa = v2fa || s1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'int')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'int')}} + + float f1; + v2ua = v2ua && f1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'float')}} + v2ua = v2ua || f1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'float')}} + + v2sa = v2sa && f1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'float')}} + v2sa = v2sa || f1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'float')}} + + v2ua = v2sa && f1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'float')}} + v2ua = v2sa || f1; // expected-error {{cannot convert between vector values of different size ('v2s' (vector of 2 'int' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'float')}} + v2sa = v2ua && f1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'float')}} + v2sa = v2ua || f1; // expected-error {{cannot convert between vector values of different size ('v2u' (vector of 2 'unsigned int' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'float')}} + + v2ua = v2fa && f1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'float')}} + v2ua = v2fa || f1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'float')}} + + v2sa = v2fa && f1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'float')}} + v2sa = v2fa || f1; // expected-error {{cannot convert between vector values of different size ('v2f' (vector of 2 'float' values) and 'float')}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'float')}} + +} diff --git a/test/Sema/warn-strict-prototypes.c b/test/Sema/warn-strict-prototypes.c index 496579c1f60e8..a28f57d48c84f 100644 --- a/test/Sema/warn-strict-prototypes.c +++ b/test/Sema/warn-strict-prototypes.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -Wstrict-prototypes -verify %s -// RUN: %clang_cc1 -fsyntax-only -Wstrict-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -verify %s +// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s // function declaration with unspecified params void foo1(); // expected-warning {{this function declaration is not a prototype}} @@ -60,3 +60,8 @@ void foo10(p, p2) void *p; {} // expected-warning {{old-style function definitio // K&R function definition with previous prototype declared is not diagnosed. void foo11(int p, int p2); void foo11(p, p2) int p; int p2; {} + +// PR31020 +void __attribute__((cdecl)) foo12(d) // expected-warning {{this old-style function definition is not preceded by a prototype}} + short d; +{} diff --git a/test/Sema/warn-unreachable.c b/test/Sema/warn-unreachable.c index 34e0296a20490..440aa0a5a174c 100644 --- a/test/Sema/warn-unreachable.c +++ b/test/Sema/warn-unreachable.c @@ -451,3 +451,50 @@ void unaryOpFixitCastSubExpr(int x) { // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:")" unaryOpFixitCastSubExpr(x); // expected-warning {{code will never be executed}} } + +#define false 0 +#define true 1 + +void testTrueFalseMacros() { + if (false) // expected-note {{silence by adding parentheses to mark code as explicitly dead}} + testTrueFalseMacros(); // expected-warning {{code will never be executed}} + if (!true) // expected-note {{silence by adding parentheses to mark code as explicitly dead}} + testTrueFalseMacros(); // expected-warning {{code will never be executed}} +} + +int pr13910_foo(int x) { + if (x == 1) + return 0; + else + return x; + __builtin_unreachable(); // expected no warning +} + +int pr13910_bar(int x) { + switch (x) { + default: + return x + 1; + } + pr13910_foo(x); // expected-warning {{code will never be executed}} +} + +int pr13910_bar2(int x) { + if (x == 1) + return 0; + else + return x; + pr13910_foo(x); // expected-warning {{code will never be executed}} + __builtin_unreachable(); // expected no warning + pr13910_foo(x); // expected-warning {{code will never be executed}} +} + +void pr13910_noreturn() { + raze(); + __builtin_unreachable(); // expected no warning +} + +void pr13910_assert() { + myassert(0 && "unreachable"); + return; + __builtin_unreachable(); // expected no warning +} diff --git a/test/Sema/xray-log-args-oob.c b/test/Sema/xray-log-args-oob.c new file mode 100644 index 0000000000000..a6be0f81cb47c --- /dev/null +++ b/test/Sema/xray-log-args-oob.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11 +void foo(int) __attribute__((xray_log_args(1))); +struct __attribute__((xray_log_args(1))) a { int x; }; // expected-warning {{'xray_log_args' attribute only applies to functions and methods}} + +void fop() __attribute__((xray_log_args(1))); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}} + +void foq() __attribute__((xray_log_args(-1))); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}} + +void fos() __attribute__((xray_log_args(0))); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}} diff --git a/test/Sema/xray-log-args-oob.cpp b/test/Sema/xray-log-args-oob.cpp new file mode 100644 index 0000000000000..414bce0c334a7 --- /dev/null +++ b/test/Sema/xray-log-args-oob.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++ +void foo [[clang::xray_log_args(1)]] (int); +struct [[clang::xray_log_args(1)]] a { int x; }; // expected-warning {{'xray_log_args' attribute only applies to functions and methods}} + +void fop [[clang::xray_log_args(1)]] (); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}} + +void foq [[clang::xray_log_args(-1)]] (); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}} + +void fos [[clang::xray_log_args(0)]] (); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}} |