diff options
Diffstat (limited to 'test/Sema')
48 files changed, 1130 insertions, 111 deletions
diff --git a/test/Sema/2007-10-01-BuildArrayRef.c b/test/Sema/2007-10-01-BuildArrayRef.c new file mode 100644 index 000000000000..4692731b5c25 --- /dev/null +++ b/test/Sema/2007-10-01-BuildArrayRef.c @@ -0,0 +1,20 @@ +// RUN: not %clang_cc1_only -c %s -o - > /dev/null +// PR 1603 +void func() +{ + const int *arr; + arr[0] = 1; // expected-error {{assignment of read-only location}} +} + +struct foo { + int bar; +}; +struct foo sfoo = { 0 }; + +int func2() +{ + const struct foo *fp; + fp = &sfoo; + fp[0].bar = 1; // expected-error {{ assignment of read-only member}} + return sfoo.bar; +} diff --git a/test/Sema/2009-03-09-WeakDeclarations-1.c b/test/Sema/2009-03-09-WeakDeclarations-1.c new file mode 100644 index 000000000000..f219de6b848f --- /dev/null +++ b/test/Sema/2009-03-09-WeakDeclarations-1.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 %s -triple i686-apple-darwin +// Insist upon warnings for inappropriate weak attributes. + +// O.K. +extern int ext_weak_import __attribute__ ((__weak_import__)); + +// These are inappropriate, and should generate warnings: +int decl_weak_import __attribute__ ((__weak_import__)); // expected-warning {'weak_import' attribute cannot be specified on a definition} +int decl_initialized_weak_import __attribute__ ((__weak_import__)) = 13; // expected-warning {'weak_import' attribute cannot be specified on a definition} + +// O.K. +extern int ext_f(void) __attribute__ ((__weak_import__)); + +// These are inappropriate, and should generate warnings: +int def_f(void) __attribute__ ((__weak_import__)); +int __attribute__ ((__weak_import__)) decl_f(void) {return 0;}; diff --git a/test/Sema/2009-04-22-UnknownSize.c b/test/Sema/2009-04-22-UnknownSize.c new file mode 100644 index 000000000000..9f717408b5ea --- /dev/null +++ b/test/Sema/2009-04-22-UnknownSize.c @@ -0,0 +1,4 @@ +// RUN: not %clang_cc1 %s -emit-llvm -o - +// PR2958 +static struct foo s; // expected-error { tentative definition has type 'struct foo' that is never completed } +struct foo *p = &s; diff --git a/test/Sema/2009-07-17-VoidParameter.c b/test/Sema/2009-07-17-VoidParameter.c new file mode 100644 index 000000000000..68d1b1ec33ad --- /dev/null +++ b/test/Sema/2009-07-17-VoidParameter.c @@ -0,0 +1,4 @@ +// RUN: not %clang_cc1 -emit-llvm %s -o - +// PR4214 +typedef void vt; +void (*func_ptr)(vt my_vt); // expected-error {argument may not have 'void' type} diff --git a/test/Sema/2010-05-31-palignr.c b/test/Sema/2010-05-31-palignr.c new file mode 100644 index 000000000000..12be29af95c0 --- /dev/null +++ b/test/Sema/2010-05-31-palignr.c @@ -0,0 +1,22 @@ +// RUN: not %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o /dev/null %s + +#include <tmmintrin.h> + +extern int i; + +int main () +{ +#if defined( __SSSE3__ ) + + typedef int16_t vSInt16 __attribute__ ((__vector_size__ (16))); + + short dtbl[] = {1,2,3,4,5,6,7,8}; + vSInt16 *vdtbl = (vSInt16*) dtbl; + + vSInt16 v0; + v0 = *vdtbl; + v0 = _mm_alignr_epi8(v0, v0, i); // expected-error {{argument to '__builtin_ia32_palignr128' must be a constant integer}} + + return 0; +#endif +} diff --git a/test/Sema/Inputs/pragma-arc-cf-code-audited.h b/test/Sema/Inputs/pragma-arc-cf-code-audited.h new file mode 100644 index 000000000000..6ea360c34bb5 --- /dev/null +++ b/test/Sema/Inputs/pragma-arc-cf-code-audited.h @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + +#pragma clang arc_cf_code_audited begin diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c index a53bb4da0003..24799daa9e50 100644 --- a/test/Sema/address_spaces.c +++ b/test/Sema/address_spaces.c @@ -44,3 +44,7 @@ void test3(void) { extern void test3_helper(char *p); // expected-note {{passing argument to parameter 'p' here}} test3_helper(test3_array); // expected-error {{changes address space of pointer}} } + +typedef void ft(void); +_AS1 ft qf; // expected-error {{function type may not be qualified with an address space}} +typedef _AS1 ft qft; // expected-error {{function type may not be qualified with an address space}} diff --git a/test/Sema/alignas.c b/test/Sema/alignas.c new file mode 100644 index 000000000000..5832393e3b61 --- /dev/null +++ b/test/Sema/alignas.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c1x %s + +_Alignas(3) int align_illegal; //expected-error {{requested alignment is not a power of 2}} +_Alignas(int) char align_big; +_Alignas(1) int align_small; // FIXME: this should be rejected +_Alignas(1) unsigned _Alignas(8) int _Alignas(1) align_multiple; + +struct align_member { + _Alignas(8) int member; +}; + +typedef _Alignas(8) char align_typedef; // FIXME: this should be rejected + +_Static_assert(__alignof(align_big) == __alignof(int), "k's alignment is wrong"); +_Static_assert(__alignof(align_small) == 1, "j's alignment is wrong"); +_Static_assert(__alignof(align_multiple) == 8, "l's alignment is wrong"); +_Static_assert(__alignof(struct align_member) == 8, "quuux's alignment is wrong"); +_Static_assert(sizeof(struct align_member) == 8, "quuux's size is wrong"); +_Static_assert(__alignof(align_typedef) == 8, "typedef's alignment is wrong"); diff --git a/test/Sema/annotate.c b/test/Sema/annotate.c index 6f81491f1ffa..5b2727752bbd 100644 --- a/test/Sema/annotate.c +++ b/test/Sema/annotate.c @@ -4,4 +4,7 @@ void __attribute__((annotate("foo"))) foo(float *a) { __attribute__((annotate("bar"))) int x; __attribute__((annotate(1))) int y; // expected-error {{argument to annotate attribute was not a string literal}} __attribute__((annotate("bar", 1))) int z; // expected-error {{attribute takes one argument}} + int u = __builtin_annotation(z, (char*) 0); // expected-error {{__builtin_annotation requires a non wide string constant}} + int v = __builtin_annotation(z, (char*) L"bar"); // expected-error {{__builtin_annotation requires a non wide string constant}} + int w = __builtin_annotation(z, "foo"); } diff --git a/test/Sema/array-bounds-ptr-arith.c b/test/Sema/array-bounds-ptr-arith.c new file mode 100644 index 000000000000..c0e0d0ea785d --- /dev/null +++ b/test/Sema/array-bounds-ptr-arith.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -verify -Warray-bounds-pointer-arithmetic %s + +// Test case from PR10615 +struct ext2_super_block{ + unsigned char s_uuid[8]; // expected-note {{declared here}} +}; +void* ext2_statfs (struct ext2_super_block *es,int a) +{ + return (void *)es->s_uuid + sizeof(int); // no-warning +} +void* broken (struct ext2_super_block *es,int a) +{ + return (void *)es->s_uuid + 80; // expected-warning {{refers past the end of the array}} +} diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c index 345ab6981b17..bc958c3eea60 100644 --- a/test/Sema/array-init.c +++ b/test/Sema/array-init.c @@ -53,7 +53,7 @@ void func() { void test() { int y1[3] = { - { 1, 2, 3 } // expected-warning{{braces around scalar initializer}} expected-warning{{excess elements in scalar initializer}} + { 1, 2, 3 } // expected-warning{{excess elements in scalar initializer}} }; int y3[4][3] = { { 1, 3, 5 }, diff --git a/test/Sema/atomic-ops.c b/test/Sema/atomic-ops.c new file mode 100644 index 000000000000..51b46bd5d0ea --- /dev/null +++ b/test/Sema/atomic-ops.c @@ -0,0 +1,37 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only + +// Basic parsing/Sema tests for __atomic_* + +// FIXME: Need to implement __atomic_is_lock_free + +typedef enum memory_order { + memory_order_relaxed, memory_order_consume, memory_order_acquire, + memory_order_release, memory_order_acq_rel, memory_order_seq_cst +} memory_order; + +void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d) { + __atomic_load(0); // expected-error {{too few arguments to function}} + __atomic_load(0,0,0); // expected-error {{too many arguments to function}} + __atomic_store(0,0,0); // expected-error {{first argument to atomic operation}} + __atomic_store((int*)0,0,0); // expected-error {{first argument to atomic operation}} + + __atomic_load(i, memory_order_seq_cst); + __atomic_load(p, memory_order_seq_cst); + __atomic_load(d, memory_order_seq_cst); + + __atomic_store(i, 1, memory_order_seq_cst); + __atomic_store(p, 1, memory_order_seq_cst); // expected-warning {{incompatible integer to pointer conversion}} + (int)__atomic_store(d, 1, memory_order_seq_cst); // expected-error {{operand of type 'void'}} + + __atomic_fetch_add(i, 1, memory_order_seq_cst); + __atomic_fetch_add(p, 1, memory_order_seq_cst); + __atomic_fetch_add(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer or pointer}} + + __atomic_fetch_and(i, 1, memory_order_seq_cst); + __atomic_fetch_and(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}} + __atomic_fetch_and(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}} + + __atomic_compare_exchange_strong(i, 0, 1, memory_order_seq_cst, memory_order_seq_cst); + __atomic_compare_exchange_strong(p, 0, (int*)1, memory_order_seq_cst, memory_order_seq_cst); + __atomic_compare_exchange_strong(d, (int*)0, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}} +} diff --git a/test/Sema/atomic-type.c b/test/Sema/atomic-type.c new file mode 100644 index 000000000000..8e725403ae90 --- /dev/null +++ b/test/Sema/atomic-type.c @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only + +// Basic parsing/Sema tests for _Atomic +// No operations are actually supported on objects of this type yet. +// The qualifier syntax is not supported yet. +_Atomic(int) t1; +_Atomic(int) *t2 = &t1; +void testf(void*); +void f(void) { + _Atomic(_Atomic(int)*) t3; + _Atomic(_Atomic(int)*) *t4[2] = { &t3, 0 }; + testf(t4); +} +extern _Atomic(int (*)(int(*)[], int(*)[10])) mergetest; +extern _Atomic(int (*)(int(*)[10], int(*)[])) mergetest; +extern _Atomic(int (*)(int(*)[10], int(*)[10])) mergetest; + +_Atomic(int()) error1; // expected-error {{_Atomic cannot be applied to function type}} +_Atomic(struct ErrorS) error2; // expected-error {{_Atomic cannot be applied to incomplete type}} +_Atomic(int[10]) error3; // expected-error {{_Atomic cannot be applied to array type}} +_Atomic(const int) error4; // expected-error {{_Atomic cannot be applied to qualified type}} +_Atomic(_Atomic(int)) error5; // expected-error {{_Atomic cannot be applied to atomic type}} diff --git a/test/Sema/attr-availability.c b/test/Sema/attr-availability.c index 1314cf5a5b03..f6ed13190ed8 100644 --- a/test/Sema/attr-availability.c +++ b/test/Sema/attr-availability.c @@ -2,5 +2,6 @@ void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in Mac OS X version 10.2 before it was introduced in version 10.4; attribute ignored}} void f1() __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0))); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}} +void f2() __attribute__((availability(ios,introduced=2.1,deprecated=2.1))); -void f2() __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}} +void f3() __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}} diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c index eeef0d757a70..2889f8fa1146 100644 --- a/test/Sema/attr-deprecated.c +++ b/test/Sema/attr-deprecated.c @@ -109,7 +109,7 @@ enum __attribute__((deprecated)) Test20 { void test20() { enum Test20 f; // expected-warning {{'Test20' is deprecated}} f = test20_a; // expected-warning {{'test20_a' is deprecated}} - f = test20_b; + f = test20_b; // expected-warning {{'Test20' is deprecated}} } char test21[__has_feature(attribute_deprecated_with_message) ? 1 : -1]; diff --git a/test/Sema/attr-returns-twice.c b/test/Sema/attr-returns-twice.c new file mode 100644 index 000000000000..13f53e36de79 --- /dev/null +++ b/test/Sema/attr-returns-twice.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only + +int a __attribute__((returns_twice)); // expected-warning {{'returns_twice' attribute only applies to functions}} + +__attribute__((returns_twice)) void t0(void) { +} + +void t1() __attribute__((returns_twice)); + +void t2() __attribute__((returns_twice(2))); // expected-error {{attribute takes no arguments}} + +typedef void (*t3)(void) __attribute__((returns_twice)); // expected-warning {{'returns_twice' attribute only applies to functions}} diff --git a/test/Sema/attr-sentinel.c b/test/Sema/attr-sentinel.c index 5ca6a8d00113..abc108fdc785 100644 --- a/test/Sema/attr-sentinel.c +++ b/test/Sema/attr-sentinel.c @@ -4,13 +4,15 @@ #define ATTR __attribute__ ((__sentinel__)) -void foo1 (int x, ...) ATTR; // expected-note 2 {{function has been explicitly marked sentinel here}} +void foo1 (int x, ...) ATTR; // expected-note 3 {{function has been explicitly marked sentinel here}} void foo5 (int x, ...) __attribute__ ((__sentinel__(1))); // expected-note {{function has been explicitly marked sentinel here}} void foo6 (int x, ...) __attribute__ ((__sentinel__(5))); // expected-note {{function has been explicitly marked sentinel here}} void foo7 (int x, ...) __attribute__ ((__sentinel__(0))); // expected-note {{function has been explicitly marked sentinel here}} void foo10 (int x, ...) __attribute__ ((__sentinel__(1,1))); void foo12 (int x, ... ) ATTR; // expected-note {{function has been explicitly marked sentinel here}} +#define FOOMACRO(...) foo1(__VA_ARGS__) + void test1() { foo1(1, NULL); // OK foo1(1, 0) ; // expected-warning {{missing sentinel in function call}} @@ -30,6 +32,9 @@ void test1() { struct A a, b, c; foo1(3, &a, &b, &c); // expected-warning {{missing sentinel in function call}} foo1(3, &a, &b, &c, (struct A*) 0); + + // PR11002 + FOOMACRO(1, 2); // expected-warning {{missing sentinel in function call}} } diff --git a/test/Sema/attr-unavailable-message.c b/test/Sema/attr-unavailable-message.c index 9f663fc4efd4..9b0c3debd8a7 100644 --- a/test/Sema/attr-unavailable-message.c +++ b/test/Sema/attr-unavailable-message.c @@ -26,3 +26,24 @@ void unavail(void) { void (*fp)() = &bar; double (*fp4)(double) = dfoo; } + +// rdar://10201690 +enum foo { + a = 1, + b __attribute__((deprecated())) = 2, + c = 3 +}__attribute__((deprecated())); + +enum fee { // expected-note 2 {{declaration has been explicitly marked unavailable here}} + r = 1, + s = 2, + t = 3 +}__attribute__((unavailable())); + +enum fee f() { // expected-error {{error: 'fee' is unavailable}} + int i = a; // expected-warning {{'foo' is deprecated }} + + i = b; // expected-warning {{'b' is deprecated}} + + return r; // expected-error {{'fee' is unavailable}} +} diff --git a/test/Sema/complex-init-list.c b/test/Sema/complex-init-list.c new file mode 100644 index 000000000000..5b5d7ce1436b --- /dev/null +++ b/test/Sema/complex-init-list.c @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic + +// This file tests the clang extension which allows initializing the components +// of a complex number individually using an initialization list. Basically, +// if you have an explicit init list for a complex number that contains two +// initializers, this extension kicks in to turn it into component-wise +// initialization. +// +// This extension is useful because there isn't any way to accurately build +// a complex number at the moment besides setting the components with +// __real__ and __imag__, which is inconvenient and not usable for constants. +// (Of course, there are other extensions we could implement that would +// allow this, like some sort of __builtin_build_complex.) +// +// FIXME: It would be a good idea to have a warnings for implicit +// real->complex and complex->real conversions; as-is, it's way too easy +// to get implicit conversions when they are not intended. + +// Basic testcase +_Complex float valid1 = { 1.0f, 2.0f }; // expected-warning {{specifying real and imaginary components is an extension}} + + +// Struct for nesting tests +struct teststruct { _Complex float x; }; + + +// Random other valid stuff +_Complex int valid2 = { 1, 2 }; // expected-warning {{complex integer}} expected-warning {{specifying real and imaginary components is an extension}} +struct teststruct valid3 = { { 1.0f, 2.0f} }; // expected-warning {{specifying real and imaginary components is an extension}} +_Complex float valid4[2] = { {1.0f, 1.0f}, {1.0f, 1.0f} }; // expected-warning 2 {{specifying real and imaginary components is an extension}} +// FIXME: We need some sort of warning for valid5 +_Complex float valid5 = {1.0f, 1.0fi}; // expected-warning {{imaginary constants}} expected-warning {{specifying real and imaginary components is an extension}} + + +// Random invalid stuff +struct teststruct invalid1 = { 1, 2 }; // expected-warning {{excess elements}} +_Complex float invalid2 = { 1, 2, 3 }; // expected-warning {{excess elements}} +_Complex float invalid3 = {}; // expected-error {{scalar initializer cannot be empty}} expected-warning {{GNU empty initializer}} + + +// Check incomplete array sizing +_Complex float sizetest1[] = { {1.0f, 1.0f}, {1.0f, 1.0f} }; // expected-warning 2 {{specifying real and imaginary components is an extension}} +_Complex float sizecheck1[(sizeof(sizetest1) == sizeof(*sizetest1)*2) ? 1 : -1]; +_Complex float sizetest2[] = { 1.0f, 1.0f, {1.0f, 1.0f} }; // expected-warning {{specifying real and imaginary components is an extension}} +_Complex float sizecheck2[(sizeof(sizetest2) == sizeof(*sizetest2)*3) ? 1 : -1]; diff --git a/test/Sema/conditional-expr.c b/test/Sema/conditional-expr.c index 7a8c9e9f3612..436ecdbebce8 100644 --- a/test/Sema/conditional-expr.c +++ b/test/Sema/conditional-expr.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wsign-compare %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wsign-conversion %s void foo() { *(0 ? (double *)0 : (void *)0) = 0; // FIXME: GCC doesn't consider the the following two statements to be errors. @@ -36,12 +36,12 @@ void foo() { *(0 ? (asdf) 0 : &x) = 10; unsigned long test0 = 5; - test0 = test0 ? (long) test0 : test0; // expected-warning {{operands of ? are integers of different signs}} - test0 = test0 ? (int) test0 : test0; // expected-warning {{operands of ? are integers of different signs}} - test0 = test0 ? (short) test0 : test0; // expected-warning {{operands of ? are integers of different signs}} - test0 = test0 ? test0 : (long) test0; // expected-warning {{operands of ? are integers of different signs}} - test0 = test0 ? test0 : (int) test0; // expected-warning {{operands of ? are integers of different signs}} - test0 = test0 ? test0 : (short) test0; // expected-warning {{operands of ? are integers of different signs}} + test0 = test0 ? (long) test0 : test0; // expected-warning {{operand of ? changes signedness: 'long' to 'unsigned long'}} + test0 = test0 ? (int) test0 : test0; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}} + test0 = test0 ? (short) test0 : test0; // expected-warning {{operand of ? changes signedness: 'short' to 'unsigned long'}} + test0 = test0 ? test0 : (long) test0; // expected-warning {{operand of ? changes signedness: 'long' to 'unsigned long'}} + test0 = test0 ? test0 : (int) test0; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}} + test0 = test0 ? test0 : (short) test0; // expected-warning {{operand of ? changes signedness: 'short' to 'unsigned long'}} test0 = test0 ? test0 : (long) 10; test0 = test0 ? test0 : (int) 10; test0 = test0 ? test0 : (short) 10; @@ -49,12 +49,17 @@ void foo() { test0 = test0 ? (int) 10 : test0; test0 = test0 ? (short) 10 : test0; + int test1; enum Enum { EVal }; test0 = test0 ? EVal : test0; - test0 = test0 ? EVal : (int) test0; // okay: EVal is an int - test0 = test0 ? // expected-warning {{operands of ? are integers of different signs}} + test1 = test0 ? EVal : (int) test0; + test0 = test0 ? (unsigned) EVal - : (int) test0; + : (int) test0; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}} + + test0 = test0 ? EVal : test1; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}} + test0 = test0 ? test1 : EVal; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}} + } int Postgresql() { diff --git a/test/Sema/conversion.c b/test/Sema/conversion.c index 03204c63e965..842641bf1056 100644 --- a/test/Sema/conversion.c +++ b/test/Sema/conversion.c @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wconversion -nostdinc -isystem %S/Inputs -triple x86_64-apple-darwin %s -Wno-unreachable-code +// RUN: %clang_cc1 -fsyntax-only -verify -Wconversion \ +// RUN: -nostdsysteminc -nobuiltininc -isystem %S/Inputs \ +// RUN: -triple x86_64-apple-darwin %s -Wno-unreachable-code #include <conversion.h> diff --git a/test/Sema/crash-invalid-array.c b/test/Sema/crash-invalid-array.c new file mode 100644 index 000000000000..a3bc03b70b56 --- /dev/null +++ b/test/Sema/crash-invalid-array.c @@ -0,0 +1,17 @@ +// RUN: not %clang_cc1 -O1 %s -emit-llvm +// PR6913 + +#include <stdio.h> + +int main() +{ + int x[10][10]; + int (*p)[] = x; // expected-error {{invalid use of array with unspecified bounds} + + int i; + + for(i = 0; i < 10; ++i) + { + p[i][i] = i; + } +} diff --git a/test/Sema/dllimport-dllexport.c b/test/Sema/dllimport-dllexport.c index f09e3cf69ab5..610059ec9f6b 100644 --- a/test/Sema/dllimport-dllexport.c +++ b/test/Sema/dllimport-dllexport.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify %s inline void __attribute__((dllexport)) foo1(){} // expected-warning{{dllexport attribute ignored}} inline void __attribute__((dllimport)) foo2(){} // expected-warning{{dllimport attribute ignored}} diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c index 9ce1481f16c5..72cff65f4837 100644 --- a/test/Sema/exprs.c +++ b/test/Sema/exprs.c @@ -163,7 +163,7 @@ void test17(int x) { } // PR6501 -void test18_a(int a); // expected-note {{'test18_a' declared here}} +void test18_a(int a); // expected-note 2 {{'test18_a' declared here}} void test18(int b) { test18_a(b, b); // expected-error {{too many arguments to function call, expected 1, have 2}} test18_a(); // expected-error {{too few arguments to function call, expected 1, have 0}} @@ -183,7 +183,9 @@ void test19() { } int test20(int x) { - return x && 4; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}} + return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \ + // expected-note {{use '&' for a bitwise operation}} \ + // expected-note {{remove constant to silence this warning}} return x && sizeof(int) == 4; // no warning, RHS is logical op. @@ -192,20 +194,32 @@ int test20(int x) { return x || 0; return x || 1; - return x || -1; // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}} - return x || 5; // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}} + return x || -1; // expected-warning {{use of logical '||' with constant operand}} \ + // expected-note {{use '|' for a bitwise operation}} + return x || 5; // expected-warning {{use of logical '||' with constant operand}} \ + // expected-note {{use '|' for a bitwise operation}} return x && 0; return x && 1; - return x && -1; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}} - return x && 5; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}} + return x && -1; // expected-warning {{use of logical '&&' with constant operand}} \ + // expected-note {{use '&' for a bitwise operation}} \ + // expected-note {{remove constant to silence this warning}} + return x && 5; // expected-warning {{use of logical '&&' with constant operand}} \ + // expected-note {{use '&' for a bitwise operation}} \ + // expected-note {{remove constant to silence this warning}} return x || (0); return x || (1); - return x || (-1); // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}} - return x || (5); // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}} + return x || (-1); // expected-warning {{use of logical '||' with constant operand}} \ + // expected-note {{use '|' for a bitwise operation}} + return x || (5); // expected-warning {{use of logical '||' with constant operand}} \ + // expected-note {{use '|' for a bitwise operation}} return x && (0); return x && (1); - return x && (-1); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}} - return x && (5); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}} + return x && (-1); // expected-warning {{use of logical '&&' with constant operand}} \ + // expected-note {{use '&' for a bitwise operation}} \ + // expected-note {{remove constant to silence this warning}} + return x && (5); // expected-warning {{use of logical '&&' with constant operand}} \ + // expected-note {{use '&' for a bitwise operation}} \ + // expected-note {{remove constant to silence this warning}} } diff --git a/test/Sema/flexible-array-init.c b/test/Sema/flexible-array-init.c index 12f5d4f5d605..78fc7c5e0df3 100644 --- a/test/Sema/flexible-array-init.c +++ b/test/Sema/flexible-array-init.c @@ -7,9 +7,7 @@ struct one { struct one x2 = { 5, 1, 2, 3 }; // expected-warning{{flexible array initialization is a GNU extension}} void test() { - struct one x3 = {5, {1, 2, 3}}; // \ - // expected-warning{{flexible array initialization is a GNU extension}} \ - // expected-error {{non-static initialization of a variable with flexible array member}} + struct one x3 = {5, {1, 2, 3}}; // expected-error{{initialization of flexible array member is not allowed}} struct one x3a = { 5 }; struct one x3b = { .a = 5 }; struct one x3c = { 5, {} }; // expected-warning{{use of GNU empty initializer extension}} \ @@ -19,22 +17,23 @@ void test() { struct foo { int x; - int y[]; // expected-note 6 {{initialized flexible array member 'y' is here}} + int y[]; // expected-note 8 {{initialized flexible array member 'y' is here}} }; struct bar { struct foo z; }; // expected-warning {{'z' may not be nested in a struct due to flexible array member}} struct foo a = { 1, { 2, 3, 4 } }; // expected-warning{{flexible array initialization is a GNU extension}} -struct bar b = { { 1, { 2, 3, 4 } } }; // expected-error{{non-empty initialization of flexible array member inside subobject}} +struct bar b = { { 1, { 2, 3, 4 } } }; // expected-error{{initialization of flexible array member is not allowed}} struct bar c = { { 1, { } } }; // // expected-warning{{flexible array initialization is a GNU extension}} \ // expected-warning{{use of GNU empty initializer extension}} \ // expected-warning{{zero size arrays are an extension}} struct foo d[1] = { { 1, { 2, 3, 4 } } }; // expected-warning{{'struct foo' may not be used as an array element due to flexible array member}} \ - // expected-error{{non-empty initialization of flexible array member inside subobject}} + // expected-error{{initialization of flexible array member is not allowed}} -struct foo desig_foo = { .y = {2, 3, 4} }; +struct foo desig_foo = { .y = {2, 3, 4} }; // expected-warning{{flexible array initialization is a GNU extension}} struct bar desig_bar = { .z.y = { } }; // expected-warning{{use of GNU empty initializer extension}} \ - // expected-warning{{zero size arrays are an extension}} -struct bar desig_bar2 = { .z.y = { 2, 3, 4} }; // expected-error{{non-empty initialization of flexible array member inside subobject}} + // expected-warning{{zero size arrays are an extension}} \ + // expected-warning{{flexible array initialization is a GNU extension}} +struct bar desig_bar2 = { .z.y = { 2, 3, 4} }; // expected-error{{initialization of flexible array member is not allowed}} struct foo design_foo2 = { .y = 2 }; // expected-error{{flexible array requires brace-enclosed initializer}} struct point { @@ -68,13 +67,25 @@ struct Y { // PR8217 struct PR8217a { int i; - char v[]; + char v[]; // expected-note 2 {{initialized flexible array member 'v' is here}} }; void PR8217() { - struct PR8217a foo1 = { .i = 0, .v = "foo" }; // expected-error {{non-static initialization of a variable with flexible array member}} + struct PR8217a foo1 = { .i = 0, .v = "foo" }; // expected-error {{initialization of flexible array member is not allowed}} struct PR8217a foo2 = { .i = 0 }; - struct PR8217a foo3 = { .i = 0, .v = { 'b', 'a', 'r', '\0' } }; // expected-error {{non-static initialization of a variable with flexible array member}} + struct PR8217a foo3 = { .i = 0, .v = { 'b', 'a', 'r', '\0' } }; // expected-error {{initialization of flexible array member is not allowed}} struct PR8217a bar; } +typedef struct PR10648 { + unsigned long n; + int v[]; // expected-note {{initialized flexible array member 'v' is here}} +} PR10648; +int f10648() { + return (PR10648){2, {3, 4}}.v[1]; // expected-error {{initialization of flexible array member is not allowed}} +} + +struct FlexWithUnnamedBitfield { int : 10; int x; int y[]; }; // expected-note {{initialized flexible array member 'y' is here}} +void TestFlexWithUnnamedBitfield() { + struct FlexWithUnnamedBitfield x = {10, {3}}; // expected-error {{initialization of flexible array member is not allowed}} +} diff --git a/test/Sema/format-strings-fixit.c b/test/Sema/format-strings-fixit.c index c2fa2f770745..d03cccb601f3 100644 --- a/test/Sema/format-strings-fixit.c +++ b/test/Sema/format-strings-fixit.c @@ -1,5 +1,5 @@ // RUN: cp %s %t -// RUN: %clang_cc1 -pedantic -Wall -fixit %t || true +// RUN: %clang_cc1 -pedantic -Wall -fixit %t // RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror %t // RUN: %clang_cc1 -E -o - %t | FileCheck %s diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index b47d3ca2616c..6b5f7e2c2662 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -87,7 +87,12 @@ void check_empty_format_string(char* buf, ...) va_list ap; va_start(ap,buf); vprintf("",ap); // expected-warning {{format string is empty}} - sprintf(buf,""); // expected-warning {{format string is empty}} + sprintf(buf, "", 1); // expected-warning {{format string is empty}} + + // Don't warn about empty format strings when there are no data arguments. + // This can arise from macro expansions and non-standard format string + // functions. + sprintf(buf, ""); // no-warning } void check_wide_string(char* b, ...) @@ -372,3 +377,13 @@ void check_char(unsigned char x, signed char y) { printf("%c", x); // no-warning printf("%hhu", y); // no-warning } + +// Test suppression of individual warnings. + +void test_suppress_invalid_specifier() { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-invalid-specifier" + printf("%@", 12); // no-warning +#pragma clang diagnostic pop +} + diff --git a/test/Sema/fp16-sema.c b/test/Sema/fp16-sema.c new file mode 100644 index 000000000000..e678f9a829e4 --- /dev/null +++ b/test/Sema/fp16-sema.c @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// Functions cannot have parameters of type __fp16. +extern void f (__fp16); // expected-error {{parameters cannot have __fp16 type; did you forget * ?}} +extern void g (__fp16 *); + +extern void (*pf) (__fp16); // expected-error {{parameters cannot have __fp16 type; did you forget * ?}} +extern void (*pg) (__fp16*); + +typedef void(*tf) (__fp16); // expected-error {{parameters cannot have __fp16 type; did you forget * ?}} +typedef void(*tg) (__fp16*); + +void kf(a) + __fp16 a; { // expected-error {{parameters cannot have __fp16 type; did you forget * ?}} +} + +void kg(a) + __fp16 *a; { +} + +// Functions cannot return type __fp16. +extern __fp16 f1 (void); // expected-error {{function return value cannot have __fp16 type; did you forget * ?}} +extern __fp16 *g1 (void); + +extern __fp16 (*pf1) (void); // expected-error {{function return value cannot have __fp16 type; did you forget * ?}} +extern __fp16 *(*gf1) (void); + +typedef __fp16 (*tf1) (void); // expected-error {{function return value cannot have __fp16 type; did you forget * ?}} +typedef __fp16 *(*tg1) (void); + diff --git a/test/Sema/fpack-struct.c b/test/Sema/fpack-struct.c new file mode 100644 index 000000000000..37c8444ae9f8 --- /dev/null +++ b/test/Sema/fpack-struct.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=5 -fpack-struct 1 %s +// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=6 -fpack-struct 2 %s + +struct s0 { + int x; + char c; +}; + +int t0[sizeof(struct s0) == EXPECTED_STRUCT_SIZE ?: -1]; diff --git a/test/Sema/i-c-e.c b/test/Sema/i-c-e.c index 1aac51e204f1..9b50916f85ff 100644 --- a/test/Sema/i-c-e.c +++ b/test/Sema/i-c-e.c @@ -53,7 +53,8 @@ char z[__builtin_constant_p(4) ? 1 : -1]; // Comma tests int comma1[0?1,2:3]; // expected-warning {{expression result unused}} int comma2[1||(1,2)]; // expected-warning {{expression result unused}} \ - // expected-warning {{use of logical || with constant operand}} + // expected-warning {{use of logical '||' with constant operand}} \ + // expected-note {{use '|' for a bitwise operation}} int comma3[(1,2)]; // expected-warning {{size of static array must be an integer constant expression}} \ // expected-warning {{expression result unused}} diff --git a/test/Sema/implicit-int.c b/test/Sema/implicit-int.c index 1bb9a8385306..3063db66ed85 100644 --- a/test/Sema/implicit-int.c +++ b/test/Sema/implicit-int.c @@ -24,9 +24,5 @@ h19_insline(n) // expected-warning {{parameter 'n' was not declared, defaulting } struct foo { - __extension__ __attribute__((packed)) x : 4; + __extension__ __attribute__((packed)) x : 4; // expected-warning {{type specifier missing, defaults to 'int'}} }; - - - - diff --git a/test/Sema/init.c b/test/Sema/init.c index f8110079d0eb..2527e14fcbe9 100644 --- a/test/Sema/init.c +++ b/test/Sema/init.c @@ -144,3 +144,7 @@ int PR4386_b = ((void *) PR4386_foo) != 0; // expected-error{{initializer elemen int PR4386_c = ((void *) PR4386_zed) != 0; int PR4386_zed() __attribute((weak)); +// <rdar://problem/10185490> (derived from SPEC vortex benchmark) +typedef char strty[10]; +struct vortexstruct { strty s; }; +struct vortexstruct vortexvar = { "asdf" }; diff --git a/test/Sema/initialize-noreturn.c b/test/Sema/initialize-noreturn.c new file mode 100644 index 000000000000..55578628716b --- /dev/null +++ b/test/Sema/initialize-noreturn.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify +// rdar://10095762 + +typedef void (*Fn_noret)(void) __attribute__((noreturn)); +typedef void (*Fn_ret)(void); + +void foo(void); +void foo_noret(void) __attribute__((noreturn)); + +void test() { + Fn_noret fn2 = &foo; // expected-warning {{incompatible pointer types initializing 'Fn_noret'}} + Fn_noret fn3 = &foo_noret; + Fn_ret fn4 = &foo_noret; + Fn_ret fn5 = &foo; +} + diff --git a/test/Sema/knr-def-call.c b/test/Sema/knr-def-call.c index 6243af619398..f41275d1e618 100644 --- a/test/Sema/knr-def-call.c +++ b/test/Sema/knr-def-call.c @@ -36,8 +36,6 @@ void proto(x) } void use_proto() { - proto(42.0); // expected-warning{{implicit conversion turns literal floating-point number into integer}} \ - // expected-note {{this can be rewritten as an integer literal with the exact same value}} - (&proto)(42.0); // expected-warning{{implicit conversion turns literal floating-point number into integer}} \ - // expected-note {{this can be rewritten as an integer literal with the exact same value}} + proto(42.1); // expected-warning{{implicit conversion turns literal floating-point number into integer}} + (&proto)(42.1); // expected-warning{{implicit conversion turns literal floating-point number into integer}} } diff --git a/test/Sema/many-parameters.c b/test/Sema/many-parameters.c new file mode 100644 index 000000000000..1473c941109a --- /dev/null +++ b/test/Sema/many-parameters.c @@ -0,0 +1,310 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c99 %s + +// This test simply tests that the compiler does not crash. An optimization +// in ParmVarDecls means that functions with fewer than 256 parameters use a fast path, +// while those with >= 256 parameters use a slow path. +// +// Crash was reported in PR 10538. + +void foo( +int x0, +int x1, +int x2, +int x3, +int x4, +int x5, +int x6, +int x7, +int x8, +int x9, +int x10, +int x11, +int x12, +int x13, +int x14, +int x15, +int x16, +int x17, +int x18, +int x19, +int x20, +int x21, +int x22, +int x23, +int x24, +int x25, +int x26, +int x27, +int x28, +int x29, +int x30, +int x31, +int x32, +int x33, +int x34, +int x35, +int x36, +int x37, +int x38, +int x39, +int x40, +int x41, +int x42, +int x43, +int x44, +int x45, +int x46, +int x47, +int x48, +int x49, +int x50, +int x51, +int x52, +int x53, +int x54, +int x55, +int x56, +int x57, +int x58, +int x59, +int x60, +int x61, +int x62, +int x63, +int x64, +int x65, +int x66, +int x67, +int x68, +int x69, +int x70, +int x71, +int x72, +int x73, +int x74, +int x75, +int x76, +int x77, +int x78, +int x79, +int x80, +int x81, +int x82, +int x83, +int x84, +int x85, +int x86, +int x87, +int x88, +int x89, +int x90, +int x91, +int x92, +int x93, +int x94, +int x95, +int x96, +int x97, +int x98, +int x99, +int x100, +int x101, +int x102, +int x103, +int x104, +int x105, +int x106, +int x107, +int x108, +int x109, +int x110, +int x111, +int x112, +int x113, +int x114, +int x115, +int x116, +int x117, +int x118, +int x119, +int x120, +int x121, +int x122, +int x123, +int x124, +int x125, +int x126, +int x127, +int x128, +int x129, +int x130, +int x131, +int x132, +int x133, +int x134, +int x135, +int x136, +int x137, +int x138, +int x139, +int x140, +int x141, +int x142, +int x143, +int x144, +int x145, +int x146, +int x147, +int x148, +int x149, +int x150, +int x151, +int x152, +int x153, +int x154, +int x155, +int x156, +int x157, +int x158, +int x159, +int x160, +int x161, +int x162, +int x163, +int x164, +int x165, +int x166, +int x167, +int x168, +int x169, +int x170, +int x171, +int x172, +int x173, +int x174, +int x175, +int x176, +int x177, +int x178, +int x179, +int x180, +int x181, +int x182, +int x183, +int x184, +int x185, +int x186, +int x187, +int x188, +int x189, +int x190, +int x191, +int x192, +int x193, +int x194, +int x195, +int x196, +int x197, +int x198, +int x199, +int x200, +int x201, +int x202, +int x203, +int x204, +int x205, +int x206, +int x207, +int x208, +int x209, +int x210, +int x211, +int x212, +int x213, +int x214, +int x215, +int x216, +int x217, +int x218, +int x219, +int x220, +int x221, +int x222, +int x223, +int x224, +int x225, +int x226, +int x227, +int x228, +int x229, +int x230, +int x231, +int x232, +int x233, +int x234, +int x235, +int x236, +int x237, +int x238, +int x239, +int x240, +int x241, +int x242, +int x243, +int x244, +int x245, +int x246, +int x247, +int x248, +int x249, +int x250, +int x251, +int x252, +int x253, +int x254, +int x255, +int x256, +int x257, +int x258, +int x259, +int x260, +int x261, +int x262, +int x263, +int x264, +int x265, +int x266, +int x267, +int x268, +int x269, +int x270, +int x271, +int x272, +int x273, +int x274, +int x275, +int x276, +int x277, +int x278, +int x279, +int x280, +int x281, +int x282, +int x283, +int x284, +int x285, +int x286, +int x287, +int x288, +int x289, +int x290, +int x291, +int x292, +int x293, +int x294, +int x295, +int x296, +int x297, +int x298, +int x299 +); diff --git a/test/Sema/ms-fuzzy-asm.c b/test/Sema/ms-fuzzy-asm.c deleted file mode 100644 index 250e3222564d..000000000000 --- a/test/Sema/ms-fuzzy-asm.c +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 %s -verify -fms-extensions - -#define M __asm int 0x2c -#define M2 int - -void t1(void) { M } -void t2(void) { __asm int 0x2c } -void t3(void) { __asm M2 0x2c } -void* t4(void) { __asm mov eax, fs:[0x10] } diff --git a/test/Sema/ms_class_layout.cpp b/test/Sema/ms_class_layout.cpp new file mode 100644 index 000000000000..13c90b0c9ed1 --- /dev/null +++ b/test/Sema/ms_class_layout.cpp @@ -0,0 +1,176 @@ +// RUN: %clang_cc1 -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -cxx-abi microsoft %s 2>&1 \ +// RUN: | FileCheck %s + +#pragma pack(push, 8) + +class B { +public: + virtual void b(){} + int b_field; +protected: +private: +}; + +class A : public B { +public: + int a_field; + virtual void a(){} + char one; +protected: +private: +}; + +class D { +public: + virtual void b(){} + double a; +}; + +class C : public virtual A, + public D, public B { +public: + double c1_field; + int c2_field; + double c3_field; + int c4_field; + virtual void foo(){} + virtual void bar(){} +protected: +private: +}; + +struct BaseStruct +{ + BaseStruct(){} + double v0; + float v1; + C fg; +}; + +struct DerivedStruct : public BaseStruct { + int x; +}; + +struct G +{ + virtual ~G(){} + int a; + double b; +}; + +#pragma pack(pop) + +// This needs only for building layouts. +// Without this clang doesn`t dump record layouts. +int main() { + // This avoid "Can't yet mangle constructors!" for MS ABI. + C* c; + c->foo(); + DerivedStruct* v; + G* g; + BaseStruct* u; + return 0; +} + +// CHECK: 0 | class D +// CHECK-NEXT: 0 | (D vtable pointer) +// CHECK-NEXT: 8 | double a + +// CHECK-NEXT: sizeof=16, dsize=16, align=8 +// CHECK-NEXT: nvsize=16, nvalign=8 + +// CHECK: 0 | class B +// CHECK-NEXT: 0 | (B vtable pointer) +// CHECK-NEXT: 4 | int b_field + +// CHECK-NEXT: sizeof=8, dsize=8, align=4 +// CHECK-NEXT: nvsize=8, nvalign=4 + +// CHECK: 0 | class A +// CHECK-NEXT: 0 | class B (primary base) +// CHECK-NEXT: 0 | (B vtable pointer) +// CHECK-NEXT: 4 | int b_field +// CHECK-NEXT: 8 | int a_field +// CHECK-NEXT: 12 | char one + +// CHECK-NEXT: sizeof=16, dsize=16, align=4 +// CHECK-NEXT: nvsize=16, nvalign=4 + +// CHECK: 0 | class C +// CHECK-NEXT: 0 | class D (primary base) +// CHECK-NEXT: 0 | (D vtable pointer) +// CHECK-NEXT: 8 | double a +// CHECK-NEXT: 16 | class B (base) +// CHECK-NEXT: 16 | (B vtable pointer) +// CHECK-NEXT: 20 | int b_field +// CHECK-NEXT: 24 | (C vbtable pointer) +// CHECK-NEXT: 32 | double c1_field +// CHECK-NEXT: 40 | int c2_field +// CHECK-NEXT: 48 | double c3_field +// CHECK-NEXT: 56 | int c4_field +// CHECK-NEXT: 64 | class A (virtual base) +// CHECK-NEXT: 64 | class B (primary base) +// CHECK-NEXT: 64 | (B vtable pointer) +// CHECK-NEXT: 68 | int b_field +// CHECK-NEXT: 72 | int a_field +// CHECK-NEXT: 76 | char one + +// CHECK-NEXT: sizeof=80, dsize=80, align=8 +// CHECK-NEXT: nvsize=80, nvalign=8 + +// CHECK: 0 | struct BaseStruct +// CHECK-NEXT: 0 | double v0 +// CHECK-NEXT: 8 | float v1 +// CHECK-NEXT: 16 | class C fg +// CHECK-NEXT: 16 | class D (primary base) +// CHECK-NEXT: 16 | (D vtable pointer) +// CHECK-NEXT: 24 | double a +// CHECK-NEXT: 32 | class B (base) +// CHECK-NEXT: 32 | (B vtable pointer) +// CHECK-NEXT: 36 | int b_field +// CHECK-NEXT: 40 | (C vbtable pointer) +// CHECK-NEXT: 48 | double c1_field +// CHECK-NEXT: 56 | int c2_field +// CHECK-NEXT: 64 | double c3_field +// CHECK-NEXT: 72 | int c4_field +// CHECK-NEXT: 80 | class A (virtual base) +// CHECK-NEXT: 80 | class B (primary base) +// CHECK-NEXT: 80 | (B vtable pointer) +// CHECK-NEXT: 84 | int b_field +// CHECK-NEXT: 88 | int a_field +// CHECK-NEXT: 92 | char one + +// CHECK-NEXT: sizeof=80, dsize=80, align=8 +// CHECK-NEXT: nvsize=80, nvalign=8 + +// CHECK: sizeof=96, dsize=96, align=8 +// CHECK-NEXT: nvsize=96, nvalign=8 + +// CHECK: 0 | struct DerivedStruct +// CHECK-NEXT: 0 | struct BaseStruct (base) +// CHECK-NEXT: 0 | double v0 +// CHECK-NEXT: 8 | float v1 +// CHECK-NEXT: 16 | class C fg +// CHECK-NEXT: 16 | class D (primary base) +// CHECK-NEXT: 16 | (D vtable pointer) +// CHECK-NEXT: 24 | double a +// CHECK-NEXT: 32 | class B (base) +// CHECK-NEXT: 32 | (B vtable pointer) +// CHECK-NEXT: 36 | int b_field +// CHECK-NEXT: 40 | (C vbtable pointer) +// CHECK-NEXT: 48 | double c1_field +// CHECK-NEXT: 56 | int c2_field +// CHECK-NEXT: 64 | double c3_field +// CHECK-NEXT: 72 | int c4_field +// CHECK-NEXT: 80 | class A (virtual base) +// CHECK-NEXT: 80 | class B (primary base) +// CHECK-NEXT: 80 | (B vtable pointer) +// CHECK-NEXT: 84 | int b_field +// CHECK-NEXT: 88 | int a_field +// CHECK-NEXT: 92 | char one +// CHECK-NEXT: sizeof=80, dsize=80, align=8 +// CHECK-NEXT: nvsize=80, nvalign=8 + +// CHECK: 96 | int x +// CHECK-NEXT: sizeof=104, dsize=104, align=8 +// CHECK-NEXT: nvsize=104, nvalign=8 diff --git a/test/Sema/parentheses.c b/test/Sema/parentheses.c index 13ea3ecbe16a..9751336018b7 100644 --- a/test/Sema/parentheses.c +++ b/test/Sema/parentheses.c @@ -52,6 +52,8 @@ void conditional_op(int x, int y, _Bool b) { // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ // expected-note {{place parentheses around the '+' expression to silence this warning}} + (void)((x + someConditionFunc()) ? 1 : 2); // no warning + (void)(x - b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '-'}} \ // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ // expected-note {{place parentheses around the '-' expression to silence this warning}} @@ -64,7 +66,6 @@ void conditional_op(int x, int y, _Bool b) { // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ // expected-note {{place parentheses around the '/' expression to silence this warning}} - (void)(x % 2 ? 1 : 2); // no warning } diff --git a/test/Sema/parentheses.cpp b/test/Sema/parentheses.cpp index 252455dcad49..767416677e00 100644 --- a/test/Sema/parentheses.cpp +++ b/test/Sema/parentheses.cpp @@ -40,6 +40,8 @@ void test(S *s, bool (S::*m_ptr)()) { // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ // expected-note {{place parentheses around the '+' expression to silence this warning}} + (void)((*s + true) ? "foo" : "bar"); // No warning. + // Don't crash on unusual member call expressions. (void)((s->*m_ptr)() ? "foo" : "bar"); } diff --git a/test/Sema/pragma-arc-cf-code-audited.c b/test/Sema/pragma-arc-cf-code-audited.c new file mode 100644 index 000000000000..b646e8966c61 --- /dev/null +++ b/test/Sema/pragma-arc-cf-code-audited.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +#pragma clang arc_cf_code_audited foo // expected-error {{expected 'begin' or 'end'}} + +#pragma clang arc_cf_code_audited begin foo // expected-warning {{extra tokens at end of #pragma directive}} + +#pragma clang arc_cf_code_audited end +#pragma clang arc_cf_code_audited end // expected-error {{not currently inside '#pragma clang arc_cf_code_audited'}} + +#pragma clang arc_cf_code_audited begin // expected-note {{#pragma entered here}} +#pragma clang arc_cf_code_audited begin // expected-error {{already inside '#pragma clang arc_cf_code_audited'}} expected-note {{#pragma entered here}} + +#include "Inputs/pragma-arc-cf-code-audited.h" // expected-error {{cannot #include files inside '#pragma clang arc_cf_code_audited'}} + +// This is actually on the #pragma line in the header. +// expected-error {{'#pragma clang arc_cf_code_audited' was not ended within this file}} + +#pragma clang arc_cf_code_audited begin // expected-error {{'#pragma clang arc_cf_code_audited' was not ended within this file}} diff --git a/test/Sema/return-noreturn.c b/test/Sema/return-noreturn.c index ff43754a4299..448fce77cd85 100644 --- a/test/Sema/return-noreturn.c +++ b/test/Sema/return-noreturn.c @@ -1,8 +1,8 @@ // RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wmissing-noreturn -Wno-unreachable-code int j; -void test1() { // expected-warning {{function could be attribute 'noreturn'}} - ^ (void) { while (1) { } }(); // expected-warning {{block could be attribute 'noreturn'}} +void test1() { // expected-warning {{function 'test1' could be declared with attribute 'noreturn'}} + ^ (void) { while (1) { } }(); // expected-warning {{block could be declared with attribute 'noreturn'}} ^ (void) { if (j) while (1) { } }(); while (1) { } } diff --git a/test/Sema/types.c b/test/Sema/types.c index f3244f7799b6..332b525e33a8 100644 --- a/test/Sema/types.c +++ b/test/Sema/types.c @@ -37,3 +37,16 @@ _Decimal32 x; // expected-error {{GNU decimal type extension not supported}} // rdar://6880951 int __attribute__ ((vector_size (8), vector_size (8))) v; // expected-error {{invalid vector element type}} + +void test(int i) { + char c = (char __attribute__((align(8)))) i; // expected-error {{'align' attribute ignored when parsing type}} +} + +// http://llvm.org/PR11082 +// +// FIXME: This may or may not be the correct approach (no warning or error), +// but large amounts of Linux and FreeBSD code need this attribute to not be +// a hard error in order to work correctly. +void test2(int i) { + char c = (char __attribute__((may_alias))) i; +} diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c index 0caab3df18c0..49af4f322629 100644 --- a/test/Sema/uninit-variables.c +++ b/test/Sema/uninit-variables.c @@ -1,7 +1,10 @@ // RUN: %clang_cc1 -fsyntax-only -Wuninitialized -Wconditional-uninitialized -fsyntax-only -fblocks %s -verify +typedef __typeof(sizeof(int)) size_t; +void *malloc(size_t); + int test1() { - int x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + int x; // expected-note{{initialize the variable 'x' to silence this warning}} return x; // expected-warning{{variable 'x' is uninitialized when used here}} } @@ -17,25 +20,25 @@ int test3() { } int test4() { - int x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + int x; // expected-note{{initialize the variable 'x' to silence this warning}} ++x; // expected-warning{{variable 'x' is uninitialized when used here}} return x; } int test5() { - int x, y; // expected-note{{variable 'y' is declared here}} expected-note{{add initialization to silence this warning}} + int x, y; // expected-note{{initialize the variable 'y' to silence this warning}} x = y; // expected-warning{{variable 'y' is uninitialized when used here}} return x; } int test6() { - int x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + int x; // expected-note{{initialize the variable 'x' to silence this warning}} x += 2; // expected-warning{{variable 'x' is uninitialized when used here}} return x; } int test7(int y) { - int x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + int x; // expected-note{{initialize the variable 'x' to silence this warning}} if (y) x = 1; return x; // expected-warning{{variable 'x' may be uninitialized when used here}} @@ -51,7 +54,7 @@ int test8(int y) { } int test9(int n) { - int x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + int x; // expected-note{{initialize the variable 'x' to silence this warning}} for (unsigned i = 0 ; i < n; ++i) { if (i == n - 1) break; @@ -61,7 +64,7 @@ int test9(int n) { } int test10(unsigned n) { - int x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + int x; // expected-note{{initialize the variable 'x' to silence this warning}} for (unsigned i = 0 ; i < n; ++i) { x = 1; } @@ -69,7 +72,7 @@ int test10(unsigned n) { } int test11(unsigned n) { - int x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + int x; // expected-note{{initialize the variable 'x' to silence this warning}} for (unsigned i = 0 ; i <= n; ++i) { x = 1; } @@ -77,7 +80,7 @@ int test11(unsigned n) { } void test12(unsigned n) { - for (unsigned i ; n ; ++i) ; // expected-warning{{variable 'i' may be uninitialized when used here}} expected-note{{variable 'i' is declared here}} expected-note{{add initialization to silence this warning}} + for (unsigned i ; n ; ++i) ; // expected-warning{{variable 'i' is uninitialized when used here}} expected-note{{initialize the variable 'i' to silence this warning}} } int test13() { @@ -91,10 +94,15 @@ void test14() { for (;;) {} } -int test15() { - int x = x; // no-warning: signals intended lack of initialization. \ - // expected-note{{variable 'x' is declared here}} - return x; // expected-warning{{variable 'x' is uninitialized when used here}} +void test15() { + int x = x; // no-warning: signals intended lack of initialization. +} + +int test15b() { + // Warn here with the self-init, since it does result in a use of + // an unintialized variable and this is the root cause. + int x = x; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}} + return x; } // Don't warn in the following example; shows dataflow confluence. @@ -108,7 +116,7 @@ void test16() { void test17() { // Don't warn multiple times about the same uninitialized variable // along the same path. - int *x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + int *x; // expected-note{{initialize the variable 'x' to silence this warning}} *x = 1; // expected-warning{{variable 'x' is uninitialized when used here}} *x = 1; // no-warning } @@ -132,14 +140,14 @@ int test19() { } int test20() { - int z; // expected-note{{variable 'z' is declared here}} expected-note{{add initialization to silence this warning}} + int z; // expected-note{{initialize the variable 'z' to silence this warning}} if ((test19_aux1() + test19_aux2() && test19_aux1()) || test19_aux3(&z)) return z; // expected-warning{{variable 'z' may be uninitialized when used here}} return 0; } int test21(int x, int y) { - int z; // expected-note{{variable 'z' is declared here}} expected-note{{add initialization to silence this warning}} + int z; // expected-note{{initialize the variable 'z' to silence this warning}} if ((x && y) || test19_aux3(&z) || test19_aux2()) return z; // expected-warning{{variable 'z' may be uninitialized when used here}} return 0; @@ -164,7 +172,7 @@ int test23() { // conditionals. This possibly can be handled by making the CFG itself // represent such control-dependencies, but it is a niche case. int test24(int flag) { - unsigned val; // expected-note{{variable 'val' is declared here}} expected-note{{add initialization to silence this warning}} + unsigned val; // expected-note{{initialize the variable 'val' to silence this warning}} if (flag) val = 1; if (!flag) @@ -173,13 +181,13 @@ int test24(int flag) { } float test25() { - float x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + float x; // expected-note{{initialize the variable 'x' to silence this warning}} return x; // expected-warning{{variable 'x' is uninitialized when used here}} } typedef int MyInt; MyInt test26() { - MyInt x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + MyInt x; // expected-note{{initialize the variable 'x' to silence this warning}} return x; // expected-warning{{variable 'x' is uninitialized when used here}} } @@ -190,12 +198,12 @@ int test27() { } int test28() { - int len; // expected-note{{variable 'len' is declared here}} expected-note{{add initialization to silence this warning}} + int len; // expected-note{{initialize the variable 'len' to silence this warning}} return sizeof(int[len]); // expected-warning{{variable 'len' is uninitialized when used here}} } void test29() { - int x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + int x; // expected-note{{initialize the variable 'x' to silence this warning}} (void) ^{ (void) x; }; // expected-warning{{variable 'x' is uninitialized when captured by block}} } @@ -220,7 +228,7 @@ void test_33() { } int test_34() { - int x; // expected-note{{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + int x; // expected-note{{initialize the variable 'x' to silence this warning}} (void) x; return x; // expected-warning{{variable 'x' is uninitialized when used here}} } @@ -234,10 +242,10 @@ void test35(int x) { // Test handling of indirect goto. void test36() { - void **pc; // expected-note{{variable 'pc' is declared here}} expected-note{{add initialization to silence this warning}} + void **pc; // expected-note{{initialize the variable 'pc' to silence this warning}} void *dummy[] = { &&L1, &&L2 }; L1: - goto *pc; // expected-warning{{variable 'pc' may be uninitialized when used here}} + goto *pc; // expected-warning{{variable 'pc' is uninitialized when used here}} L2: goto *pc; } @@ -263,19 +271,19 @@ int test38(int r, int x, int y) } int test39(int x) { - int y; // expected-note {{variable 'y' is declared here}} expected-note{{add initialization to silence this warning}} + int y; // expected-note{{initialize the variable 'y' to silence this warning}} int z = x + y; // expected-warning {{variable 'y' is uninitialized when used here}} return z; } int test40(int x) { - int y; // expected-note {{variable 'y' is declared here}} expected-note{{add initialization to silence this warning}} + int y; // expected-note{{initialize the variable 'y' to silence this warning}} return x ? 1 : y; // expected-warning {{variable 'y' is uninitialized when used here}} } int test41(int x) { - int y; // expected-note {{variable 'y' is declared here}} expected-note{{add initialization to silence this warning}} + int y; // expected-note{{initialize the variable 'y' to silence this warning}} if (x) y = 1; // no-warning return y; // expected-warning {{variable 'y' may be uninitialized when used here}} } @@ -287,17 +295,17 @@ void test42() { void test43_aux(int x); void test43(int i) { - int x; // expected-note {{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}} + int x; // expected-note{{initialize the variable 'x' to silence this warning}} for (i = 0 ; i < 10; i++) - test43_aux(x++); // expected-warning {{variable 'x' may be uninitialized when used here}} + test43_aux(x++); // expected-warning {{variable 'x' is uninitialized when used here}} } void test44(int i) { int x = i; - int y; // expected-note {{variable 'y' is declared here}} expected-note{{add initialization to silence this warning}} + int y; // expected-note{{initialize the variable 'y' to silence this warning}} for (i = 0; i < 10; i++ ) { test43_aux(x++); // no-warning - x += y; // expected-warning {{variable 'y' may be uninitialized when used here}} + x += y; // expected-warning {{variable 'y' is uninitialized when used here}} } } @@ -310,7 +318,7 @@ int test45(int j) { void test46() { - int i; // expected-note {{variable 'i' is declared here}} expected-note{{add initialization to silence this warning}} + int i; // expected-note{{initialize the variable 'i' to silence this warning}} int j = i ? : 1; // expected-warning {{variable 'i' is uninitialized when used here}} } @@ -341,7 +349,7 @@ int test51(void) // FIXME: This is a false positive, but it tests logical operations in switch statements. int test52(int a, int b) { - int x; // expected-note {{variable 'x' is declared here}} expected-note {{add initialization to silence this warning}} + int x; // expected-note {{initialize the variable 'x' to silence this warning}} switch (a || b) { // expected-warning {{switch condition has boolean value}} case 0: x = 1; @@ -353,10 +361,15 @@ int test52(int a, int b) { return x; // expected-warning {{variable 'x' may be uninitialized when used here}} } +void test53() { + int x; // expected-note {{initialize the variable 'x' to silence this warning}} + int y = (x); // expected-warning {{variable 'x' is uninitialized when used here}} +} + // This CFG caused the uninitialized values warning to inf-loop. extern int PR10379_g(); void PR10379_f(int *len) { - int new_len; // expected-note {{variable 'new_len' is declared here}} expected-note{{add initialization to silence this warning}} + int new_len; // expected-note{{initialize the variable 'new_len' to silence this warning}} for (int i = 0; i < 42 && PR10379_g() == 0; i++) { if (PR10379_g() == 1) continue; @@ -367,3 +380,39 @@ void PR10379_f(int *len) { *len += new_len; // expected-warning {{variable 'new_len' may be uninitialized when used here}} } } + +// Test that sizeof(VLA) doesn't trigger a warning. +void test_vla_sizeof(int x) { + double (*memory)[2][x] = malloc(sizeof(*memory)); // no-warning +} + +// Test absurd case of deadcode + use of blocks. This previously was a false positive +// due to an analysis bug. +int test_block_and_dead_code() { + __block int x; + ^{ x = 1; }(); + if (0) + return x; + return x; // no-warning +} + +// This previously triggered an infinite loop in the analysis. +void PR11069(int a, int b) { + unsigned long flags; + for (;;) { + if (a && !b) + break; + } + for (;;) { + // This does not trigger a warning because it isn't a real use. + (void)(flags); // no-warning + } +} + +// Test uninitialized value used in loop condition. +void rdar9432305(float *P) { + int i; // expected-note {{initialize the variable 'i' to silence this warning}} + for (; i < 10000; ++i) // expected-warning {{variable 'i' is uninitialized when used here}} + P[i] = 0.0f; +} + diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c index 9949887b23e7..97611168f1a2 100644 --- a/test/Sema/unused-expr.c +++ b/test/Sema/unused-expr.c @@ -7,11 +7,11 @@ double sqrt(double X); // implicitly const because of no -fmath-errno! void bar(volatile int *VP, int *P, int A, _Complex double C, volatile _Complex double VC) { - VP == P; // expected-warning {{expression result unused}} + VP < P; // expected-warning {{expression result unused}} (void)A; (void)foo(1,2); // no warning. - A == foo(1, 2); // expected-warning {{expression result unused}} + A < foo(1, 2); // expected-warning {{expression result unused}} foo(1,2)+foo(4,3); // expected-warning {{expression result unused}} @@ -54,23 +54,23 @@ void t4(int a) { int b = 0; if (a) - b == 1; // expected-warning{{expression result unused}} + b < 1; // expected-warning{{expression result unused}} else - b == 2; // expected-warning{{expression result unused}} + b < 2; // expected-warning{{expression result unused}} while (1) - b == 3; // expected-warning{{expression result unused}} + b < 3; // expected-warning{{expression result unused}} do - b == 4; // expected-warning{{expression result unused}} + b < 4; // expected-warning{{expression result unused}} while (1); for (;;) - b == 5; // expected-warning{{expression result unused}} + b < 5; // expected-warning{{expression result unused}} - for (b == 1;;) {} // expected-warning{{expression result unused}} - for (;b == 1;) {} - for (;;b == 1) {} // expected-warning{{expression result unused}} + for (b < 1;;) {} // expected-warning{{expression result unused}} + for (;b < 1;) {} + for (;;b < 1) {} // expected-warning{{expression result unused}} } // rdar://7186119 diff --git a/test/Sema/warn-cast-align.c b/test/Sema/warn-cast-align.c index 11e3c4163642..93352c253a2e 100644 --- a/test/Sema/warn-cast-align.c +++ b/test/Sema/warn-cast-align.c @@ -28,7 +28,7 @@ void test1(void *P) { } // Aligned struct. -__attribute__((align(16))) struct A { +__attribute__((aligned(16))) struct A { char buffer[16]; }; void test2(char *P) { diff --git a/test/Sema/warn-strlcpycat-size.c b/test/Sema/warn-strlcpycat-size.c new file mode 100644 index 000000000000..8babdde276fa --- /dev/null +++ b/test/Sema/warn-strlcpycat-size.c @@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -Wstrlcpy-strlcat-size -verify -fsyntax-only %s + +typedef __SIZE_TYPE__ size_t; +size_t strlcpy (char * restrict dst, const char * restrict src, size_t size); +size_t strlcat (char * restrict dst, const char * restrict src, size_t size); +size_t strlen (const char *s); + +char s1[100]; +char s2[200]; +char * s3; + +struct { + char f1[100]; + char f2[100][3]; +} s4, **s5; + +int x; + +void f(void) +{ + strlcpy(s1, s2, sizeof(s1)); // no warning + strlcpy(s1, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}} + strlcpy(s1, s3, strlen(s3)+1); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}} + strlcat(s2, s3, sizeof(s3)); // expected-warning {{size argument in 'strlcat' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}} + strlcpy(s4.f1, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}} + strlcpy((*s5)->f2[x], s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}} + strlcpy(s1+3, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} +} + +// Don't issue FIXIT for flexible arrays. +struct S { + int y; + char x[]; +}; + +void flexible_arrays(struct S *s) { + char str[] = "hi"; + strlcpy(s->x, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} +} + +// Don't issue FIXIT for destinations of size 1. +void size_1() { + char z[1]; + char str[] = "hi"; + + strlcpy(z, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} +} + +// Support VLAs. +void vlas(int size) { + char z[size]; + char str[] = "hi"; + + strlcpy(z, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}} +} diff --git a/test/Sema/warn-unreachable.c b/test/Sema/warn-unreachable.c index 20e0c3172401..8db36b710012 100644 --- a/test/Sema/warn-unreachable.c +++ b/test/Sema/warn-unreachable.c @@ -80,8 +80,8 @@ void test2() { - // expected-warning {{will never be executed}} halt(); case 8: - i - += // expected-warning {{will never be executed}} + i // expected-warning {{will never be executed}} + += halt(); case 9: halt() @@ -93,8 +93,8 @@ void test2() { case 11: { int a[5]; live(), - a[halt() - ]; // expected-warning {{will never be executed}} + a[halt() // expected-warning {{will never be executed}} + ]; } } } @@ -114,3 +114,15 @@ int test_enum_cases(enum Cases C) { } } +// Handle unreachable code triggered by macro expansions. +void __myassert_rtn(const char *, const char *, int, const char *) __attribute__((__noreturn__)); + +#define myassert(e) \ + (__builtin_expect(!(e), 0) ? __myassert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0) + +void test_assert() { + myassert(0 && "unreachable"); + return; // no-warning +} + + diff --git a/test/Sema/warn-unused-parameters.c b/test/Sema/warn-unused-parameters.c index e47ddd5e00d5..af048e77e886 100644 --- a/test/Sema/warn-unused-parameters.c +++ b/test/Sema/warn-unused-parameters.c @@ -19,4 +19,12 @@ static void achor() {}; // CHECK: 5:12: warning: unused parameter 'y' // CHECK: 12:15: warning: unused parameter 'y' -// CHECK-unused: 1 warning generated
\ No newline at end of file +// CHECK-unused: 1 warning generated + +// RUN: %clang_cc1 -fblocks -fsyntax-only -Weverything %s 2>&1 | FileCheck -check-prefix=CHECK-everything %s +// RUN: %clang_cc1 -fblocks -fsyntax-only -Weverything -Werror %s 2>&1 | FileCheck -check-prefix=CHECK-everything-error %s +// RUN: %clang_cc1 -fblocks -fsyntax-only -Weverything -Wno-unused %s 2>&1 | FileCheck -check-prefix=CHECK-everything-no-unused %s +// CHECK-everything: 6 warnings generated +// CHECK-everything-error: 5 errors generated +// CHECK-everything-no-unused: 5 warnings generated + |