diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-01-15 15:39:40 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-01-15 15:39:40 +0000 |
commit | a3fa5c7f1b5e2ba4d6ec033dc0e2376326b05824 (patch) | |
tree | a6082d4d1d1e9ddaea09a6a04bb4a47da95d642d /test/Sema | |
parent | bb1e3bc1e0be2b8f891db46457a8943451bf4d8b (diff) | |
download | FreeBSD-src-a3fa5c7f1b5e2ba4d6ec033dc0e2376326b05824.zip FreeBSD-src-a3fa5c7f1b5e2ba4d6ec033dc0e2376326b05824.tar.gz |
Update clang to r93512.
Diffstat (limited to 'test/Sema')
-rw-r--r-- | test/Sema/anonymous-struct-union.c | 6 | ||||
-rw-r--r-- | test/Sema/attr-noreturn.c | 2 | ||||
-rw-r--r-- | test/Sema/attr-section.c | 5 | ||||
-rw-r--r-- | test/Sema/block-labels.c | 2 | ||||
-rw-r--r-- | test/Sema/block-misc.c | 22 | ||||
-rw-r--r-- | test/Sema/block-return.c | 1 | ||||
-rw-r--r-- | test/Sema/compare.c | 44 | ||||
-rw-r--r-- | test/Sema/complex-int.c | 4 | ||||
-rw-r--r-- | test/Sema/conditional.c | 1 | ||||
-rw-r--r-- | test/Sema/conversion.c | 36 | ||||
-rw-r--r-- | test/Sema/declspec.c | 2 | ||||
-rw-r--r-- | test/Sema/enum.c | 8 | ||||
-rw-r--r-- | test/Sema/exprs.c | 14 | ||||
-rw-r--r-- | test/Sema/format-strings.c | 1 | ||||
-rw-r--r-- | test/Sema/i-c-e.c | 5 | ||||
-rw-r--r-- | test/Sema/implicit-builtin-decl.c | 3 | ||||
-rw-r--r-- | test/Sema/implicit-decl.c | 3 | ||||
-rw-r--r-- | test/Sema/invalid-decl.c | 2 | ||||
-rw-r--r-- | test/Sema/ms-fuzzy-asm.c | 1 | ||||
-rw-r--r-- | test/Sema/overloadable.c | 6 | ||||
-rw-r--r-- | test/Sema/parentheses.c | 12 | ||||
-rw-r--r-- | test/Sema/self-comparison.c | 5 | ||||
-rw-r--r-- | test/Sema/switch.c | 2 | ||||
-rw-r--r-- | test/Sema/unused-expr.c | 6 | ||||
-rw-r--r-- | test/Sema/var-redecl.c | 2 | ||||
-rw-r--r-- | test/Sema/warn-unreachable.c | 20 |
26 files changed, 196 insertions, 19 deletions
diff --git a/test/Sema/anonymous-struct-union.c b/test/Sema/anonymous-struct-union.c index 47fb2b6..78995a9 100644 --- a/test/Sema/anonymous-struct-union.c +++ b/test/Sema/anonymous-struct-union.c @@ -96,3 +96,9 @@ struct s2 { int a; } }; // expected-error{{expected member name or ';' after declaration specifiers}} + +// Make sure we don't a.k.a. anonymous structs. +typedef struct { + int x; +} a_struct; +int tmp = (a_struct) { .x = 0 }; // expected-error {{incompatible type initializing 'a_struct', expected 'int'}} diff --git a/test/Sema/attr-noreturn.c b/test/Sema/attr-noreturn.c index 0966989..3f064a0 100644 --- a/test/Sema/attr-noreturn.c +++ b/test/Sema/attr-noreturn.c @@ -2,6 +2,8 @@ static void (*fp0)(void) __attribute__((noreturn)); +void fatal(); + static void __attribute__((noreturn)) f0(void) { fatal(); } // expected-warning {{function declared 'noreturn' should not return}} diff --git a/test/Sema/attr-section.c b/test/Sema/attr-section.c index 20ae2e3..614f294 100644 --- a/test/Sema/attr-section.c +++ b/test/Sema/attr-section.c @@ -8,3 +8,8 @@ int x __attribute__((section( int y __attribute__((section( "sadf"))); // expected-error {{mach-o section specifier requires a segment and section separated by a comma}} +// PR6007 +void test() { + __attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute is not valid on local variables}} + __attribute__((section("NEAR,x"))) static int n2; // ok. +}
\ No newline at end of file diff --git a/test/Sema/block-labels.c b/test/Sema/block-labels.c index af364b4..353a570 100644 --- a/test/Sema/block-labels.c +++ b/test/Sema/block-labels.c @@ -1,5 +1,7 @@ // RUN: %clang_cc1 %s -verify -fblocks -fsyntax-only +void xx(); + int a() { A:if (1) xx(); return ^{A:return 1;}(); diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c index 9f1bc40..52cebfe 100644 --- a/test/Sema/block-misc.c +++ b/test/Sema/block-misc.c @@ -64,6 +64,7 @@ int test4(int argc) { // rdar://6251437 } +void bar(void*); // rdar://6257721 - reference to static/global is byref by default. static int test5g; void test5() { @@ -157,6 +158,8 @@ void test16(__block int i) { // expected-error {{__block attribute not allowed, __block int (*ap)[size]; // expected-error {{__block attribute not allowed on declaration with a variably modified type}} } +void f(); + void test17() { void (^bp)(int); void (*rp)(int); @@ -197,4 +200,23 @@ L0: return x; } +// radr://7438948 +void test20() { + int n = 7; + int vla[n]; // expected-note {{declared at}} + int (*vm)[n] = 0; // expected-note {{declared at}} + vla[1] = 4341; + ^{ + (void)vla[1]; // expected-error {{cannot refer to declaration with a variably modified type inside block}} + (void)(vm+1); // expected-error {{cannot refer to declaration with a variably modified type inside block}} + }(); +} +// radr://7438948 +void test21() { + int a[7]; // expected-note {{declared at}} + a[1] = 1; + ^{ + (void)a[1]; // expected-error {{cannot refer to declaration with an array type inside block}} + }(); +} diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c index 4240b09..6416545 100644 --- a/test/Sema/block-return.c +++ b/test/Sema/block-return.c @@ -76,6 +76,7 @@ static int funk(char *s) { else return 0; } +void next(); void foo4() { int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(char *)', expected 'int (^)(char const *)'}} int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (char *)', expected 'int (*)(char const *)'}} diff --git a/test/Sema/compare.c b/test/Sema/compare.c index 75a3cf1..579c3e5 100644 --- a/test/Sema/compare.c +++ b/test/Sema/compare.c @@ -194,6 +194,9 @@ int ints(long a, unsigned long b) { ((short) a < (unsigned short) 0x80000) + // expected-warning {{comparison of integers of different signs}} ((signed char) a < (unsigned char) 0x80000) + // expected-warning {{comparison of integers of different signs}} + // We should be able to avoid warning about this. + (b != (a < 4 ? 1 : 2)) + + 10 ; } @@ -230,3 +233,44 @@ int test1(int i) { enum en { zero }; return i > zero; } + +// PR5937 +int test2(int i32) { + struct foo { + unsigned int u8 : 8; + unsigned long long u31 : 31; + unsigned long long u32 : 32; + unsigned long long u63 : 63; + unsigned long long u64 : 64; + } *x; + + if (x->u8 == i32) { // comparison in int32, exact + return 0; + } else if (x->u31 == i32) { // comparison in int32, exact + return 1; + } else if (x->u32 == i32) { // expected-warning {{comparison of integers of different signs}} + return 2; + } else if (x->u63 == i32) { // comparison in uint64, exact because == + return 3; + } else if (x->u64 == i32) { // expected-warning {{comparison of integers of different signs}} + return 4; + } else { + return 5; + } +} + +// PR5887 +void test3() { + unsigned short x, y; + unsigned int z; + if ((x > y ? x : y) > z) + (void) 0; +} + +// PR5961 +extern char *ptr4; +void test4() { + long value; + if (value < (unsigned long) &ptr4) // expected-warning {{comparison of integers of different signs}} + return; +} diff --git a/test/Sema/complex-int.c b/test/Sema/complex-int.c index 2bd0374..cb76a34 100644 --- a/test/Sema/complex-int.c +++ b/test/Sema/complex-int.c @@ -49,3 +49,7 @@ void test3(_Complex int *x) { void test4(_Complex float *x) { *x = ~*x; } + +void test5(_Complex int *x) { + (*x)++; +} diff --git a/test/Sema/conditional.c b/test/Sema/conditional.c index e67580a..c3dbe13 100644 --- a/test/Sema/conditional.c +++ b/test/Sema/conditional.c @@ -3,6 +3,7 @@ const char* test1 = 1 ? "i" : 1 == 1 ? "v" : "r"; void _efree(void *ptr); +void free(void *ptr); int _php_stream_free1() { return (1 ? free(0) : _efree(0)); // expected-error {{incompatible type returning 'void', expected 'int'}} diff --git a/test/Sema/conversion.c b/test/Sema/conversion.c index 264e043..298bf75 100644 --- a/test/Sema/conversion.c +++ b/test/Sema/conversion.c @@ -235,3 +235,39 @@ extern void *test16_external; void test16(void) { int a = (unsigned long) &test16_external; // expected-warning {{implicit cast loses integer precision}} } + +// PR 5938 +void test17() { + union { + unsigned long long a : 8; + unsigned long long b : 32; + unsigned long long c; + } U; + + unsigned int x; + x = U.a; + x = U.b; + x = U.c; // expected-warning {{implicit cast loses integer precision}} +} + +// PR 5939 +void test18() { + union { + unsigned long long a : 1; + unsigned long long b; + } U; + + int x; + x = (U.a ? 0 : 1); + x = (U.b ? 0 : 1); +} + +// None of these should warn. +unsigned char test19(unsigned long u64) { + unsigned char x1 = u64 & 0xff; + unsigned char x2 = u64 >> 56; + + unsigned char mask = 0xee; + unsigned char x3 = u64 & mask; + return x1 + x2 + x3; +} diff --git a/test/Sema/declspec.c b/test/Sema/declspec.c index 2cf49aa..5b11960 100644 --- a/test/Sema/declspec.c +++ b/test/Sema/declspec.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only typedef char T[4]; -T foo(int n, int m) { } // expected-error {{cannot return array or function}} +T foo(int n, int m) { } // expected-error {{cannot return array type}} void foof(const char *, ...) __attribute__((__format__(__printf__, 1, 2))), barf (void); diff --git a/test/Sema/enum.c b/test/Sema/enum.c index 262cab5..916de41 100644 --- a/test/Sema/enum.c +++ b/test/Sema/enum.c @@ -84,3 +84,11 @@ enum e1 { YES, NO }; static enum e1 badfunc(struct s1 *q) { return q->bar(); } + + +// Make sure we don't a.k.a. anonymous enums. +typedef enum { + an_enumerator = 20 +} an_enum; +// FIXME: why is this only a warning? +char * s = (an_enum) an_enumerator; // expected-warning {{incompatible integer to pointer conversion initializing 'an_enum', expected 'char *'}} diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c index e6cfa5f..9acc63f 100644 --- a/test/Sema/exprs.c +++ b/test/Sema/exprs.c @@ -87,6 +87,10 @@ int test12(const char *X) { return X == "foo"; // expected-warning {{comparison against a string literal is unspecified}} } +int test12b(const char *X) { + return sizeof(X == "foo"); // no-warning +} + // rdar://6719156 void test13( void (^P)()) { // expected-error {{blocks support disabled - compile with -fblocks}} @@ -114,3 +118,13 @@ test15_t test15(void) { // rdar://7446395 void test16(float x) { x == ((void*) 0); } // expected-error {{invalid operands to binary expression}} +// PR6004 +void test17(int x) { + x = x / 0; // expected-warning {{division by zero is undefined}} + x = x % 0; // expected-warning {{remainder by zero is undefined}} + x /= 0; // expected-warning {{division by zero is undefined}} + x %= 0; // expected-warning {{remainder by zero is undefined}} + + x = sizeof(x/0); // no warning. +} + diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index 67081b5..20e4dcd 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -8,6 +8,7 @@ int printf(const char *restrict, ...); int snprintf(char *restrict, size_t, const char *restrict, ...); int sprintf(char *restrict, const char *restrict, ...); int vasprintf(char **, const char *, va_list); +int asprintf(char **, const char *, ...); int vfprintf(FILE *, const char *restrict, va_list); int vprintf(const char *restrict, va_list); int vsnprintf(char *, size_t, const char *, va_list); diff --git a/test/Sema/i-c-e.c b/test/Sema/i-c-e.c index c561fe0..97d9f43 100644 --- a/test/Sema/i-c-e.c +++ b/test/Sema/i-c-e.c @@ -57,8 +57,9 @@ int comma3[(1,2)]; // expected-warning {{size of static array must be an integer // Pointer + __builtin_constant_p char pbcp[__builtin_constant_p(4) ? (intptr_t)&expr : 0]; // expected-error {{variable length array declaration not allowed at file scope}} -int illegaldiv1[1 || 1/0]; -int illegaldiv2[1/0]; // expected-error {{variable length array declaration not allowed at file scope}} +int illegaldiv1[1 || 1/0]; // expected-warning {{division by zero is undefined}} +int illegaldiv2[1/0]; // expected-error {{variable length array declaration not allowed at file scope}} \ + // expected-warning {{division by zero is undefined}} int illegaldiv3[INT_MIN / -1]; // expected-error {{variable length array declaration not allowed at file scope}} int chooseexpr[__builtin_choose_expr(1, 1, expr)]; diff --git a/test/Sema/implicit-builtin-decl.c b/test/Sema/implicit-builtin-decl.c index 09ecd23..3d92038 100644 --- a/test/Sema/implicit-builtin-decl.c +++ b/test/Sema/implicit-builtin-decl.c @@ -22,7 +22,8 @@ void h() { } void f2() { - fprintf(0, "foo"); // expected-error{{implicit declaration of 'fprintf' requires inclusion of the header <stdio.h>}} + fprintf(0, "foo"); // expected-error{{implicit declaration of 'fprintf' requires inclusion of the header <stdio.h>}} \ + expected-warning {{implicit declaration of function 'fprintf' is invalid in C99}} } // PR2892 diff --git a/test/Sema/implicit-decl.c b/test/Sema/implicit-decl.c index fc48895..830cde9 100644 --- a/test/Sema/implicit-decl.c +++ b/test/Sema/implicit-decl.c @@ -7,7 +7,8 @@ void func() { int32_t *vector[16]; const char compDesc[16 + 1]; int32_t compCount = 0; - if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} + if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} \ + expected-warning {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}} } return ((void *)0); // expected-warning {{void function 'func' should not return a value}} } diff --git a/test/Sema/invalid-decl.c b/test/Sema/invalid-decl.c index 7f471a1..a5e7ad3 100644 --- a/test/Sema/invalid-decl.c +++ b/test/Sema/invalid-decl.c @@ -6,7 +6,7 @@ void test() { // PR2400 -typedef xtype (*x)(void* handle); // expected-error {{function cannot return array or function type}} expected-warning {{type specifier missing, defaults to 'int'}} expected-warning {{type specifier missing, defaults to 'int'}} +typedef xtype (*x)(void* handle); // expected-error {{function cannot return function type}} expected-warning {{type specifier missing, defaults to 'int'}} expected-warning {{type specifier missing, defaults to 'int'}} typedef void ytype(); diff --git a/test/Sema/ms-fuzzy-asm.c b/test/Sema/ms-fuzzy-asm.c index 9ace656..250e322 100644 --- a/test/Sema/ms-fuzzy-asm.c +++ b/test/Sema/ms-fuzzy-asm.c @@ -1,5 +1,4 @@ // RUN: %clang_cc1 %s -verify -fms-extensions -// XFAIL: * #define M __asm int 0x2c #define M2 int diff --git a/test/Sema/overloadable.c b/test/Sema/overloadable.c index 72d3673..ff631ed 100644 --- a/test/Sema/overloadable.c +++ b/test/Sema/overloadable.c @@ -37,9 +37,9 @@ void test_struct(struct X x, struct Y y) { double *f(int) __attribute__((overloadable)); // expected-error{{conflicting types for 'f'}} -double promote(float) __attribute__((__overloadable__)); -double promote(double) __attribute__((__overloadable__)); -long double promote(long double) __attribute__((__overloadable__)); +double promote(float) __attribute__((__overloadable__)); // expected-note {{candidate}} +double promote(double) __attribute__((__overloadable__)); // expected-note {{candidate}} +long double promote(long double) __attribute__((__overloadable__)); // expected-note {{candidate}} void promote() __attribute__((__overloadable__)); // expected-error{{'overloadable' function 'promote' must have a prototype}} void promote(...) __attribute__((__overloadable__, __unavailable__)); // \ diff --git a/test/Sema/parentheses.c b/test/Sema/parentheses.c index f7a7fbd..69c91cb 100644 --- a/test/Sema/parentheses.c +++ b/test/Sema/parentheses.c @@ -4,14 +4,18 @@ // Test the various warnings under -Wparentheses void if_assign(void) { int i; - if (i = 4) {} // expected-warning {{assignment as a condition}} + if (i = 4) {} // expected-warning {{assignment as a condition}} \ + // expected-note{{use '==' to turn this assignment into an equality comparison}} if ((i = 4)) {} } void bitwise_rel(unsigned i) { - (void)(i & 0x2 == 0); // expected-warning {{& has lower precedence than ==}} - (void)(0 == i & 0x2); // expected-warning {{& has lower precedence than ==}} - (void)(i & 0xff < 30); // expected-warning {{& has lower precedence than <}} + (void)(i & 0x2 == 0); // expected-warning {{& has lower precedence than ==}} \ + // expected-note{{place parentheses around the & expression to evaluate it first}} + (void)(0 == i & 0x2); // expected-warning {{& has lower precedence than ==}} \ + // expected-note{{place parentheses around the & expression to evaluate it first}} + (void)(i & 0xff < 30); // expected-warning {{& has lower precedence than <}} \ + // expected-note{{place parentheses around the & expression to evaluate it first}} (void)((i & 0x2) == 0); (void)(i & (0x2 == 0)); // Eager logical op diff --git a/test/Sema/self-comparison.c b/test/Sema/self-comparison.c index b2b06c2..1baba27 100644 --- a/test/Sema/self-comparison.c +++ b/test/Sema/self-comparison.c @@ -31,3 +31,8 @@ int compare_enum() { enum { A }; return A == A; // no-warning } + +// Don't complain in unevaluated contexts. +int compare_sizeof(int x) { + return sizeof(x == x); // no-warning +} diff --git a/test/Sema/switch.c b/test/Sema/switch.c index f815ba4..08ab0e0 100644 --- a/test/Sema/switch.c +++ b/test/Sema/switch.c @@ -76,7 +76,7 @@ void test6() { } // PR5606 -int f0(int var) { +int f0(int var) { // expected-note{{'var' declared here}} switch (va) { // expected-error{{use of undeclared identifier 'va'}} case 1: break; diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c index f5c64e6..68503bd 100644 --- a/test/Sema/unused-expr.c +++ b/test/Sema/unused-expr.c @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fno-math-errno %s +// RUN: %clang_cc1 -fsyntax-only -verify %s int foo(int X, int Y); -double sqrt(double X); // implicitly const because of -fno-math-errno! +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) { @@ -24,7 +24,7 @@ void bar(volatile int *VP, int *P, int A, __real__ C; // expected-warning {{expression result unused}} __real__ VC; - // We know this can't change errno because of -fno-math-errno. + // We know this can't change errno because of no -fmath-errno. sqrt(A); // expected-warning {{ignoring return value of function declared with const attribute}} } diff --git a/test/Sema/var-redecl.c b/test/Sema/var-redecl.c index e67499b..71d7ea1 100644 --- a/test/Sema/var-redecl.c +++ b/test/Sema/var-redecl.c @@ -50,7 +50,7 @@ void outer_shadowing_test() { } } -void g18(void) { +void g18(void) { // expected-note{{'g18' declared here}} extern int g19; } int *p=&g19; // expected-error{{use of undeclared identifier 'g19'}} \ diff --git a/test/Sema/warn-unreachable.c b/test/Sema/warn-unreachable.c new file mode 100644 index 0000000..2c123d0 --- /dev/null +++ b/test/Sema/warn-unreachable.c @@ -0,0 +1,20 @@ +// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code + +void test1() { + goto c; + d: + goto e; // expected-warning {{will never be executed}} + c: ; + int i; + return; + goto b; // expected-warning {{will never be executed}} + goto a; // expected-warning {{will never be executed}} + b: + i = 1; + a: + i = 2; + goto f; + e: + goto d; + f: ; +} |