diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2010-03-16 16:52:15 +0000 |
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2010-03-16 16:52:15 +0000 |
| commit | 4a37f65f1c1373c9956d118a012943de2f61edb0 (patch) | |
| tree | 52aebaff3a47b97dbac434530524c30967468412 /test/Sema | |
| parent | a16e9ac1f192503038f49e0c52edd7dcb2ce023a (diff) | |
Notes
Diffstat (limited to 'test/Sema')
| -rw-r--r-- | test/Sema/compare.c | 8 | ||||
| -rw-r--r-- | test/Sema/missing-field-initializers.c | 50 | ||||
| -rw-r--r-- | test/Sema/overloadable.c | 11 | ||||
| -rw-r--r-- | test/Sema/return.c | 2 | ||||
| -rw-r--r-- | test/Sema/warn-unused-value.c | 53 | ||||
| -rw-r--r-- | test/Sema/warn-write-strings.c | 4 |
6 files changed, 126 insertions, 2 deletions
diff --git a/test/Sema/compare.c b/test/Sema/compare.c index 2821a935c3c7..7c8c36f0c145 100644 --- a/test/Sema/compare.c +++ b/test/Sema/compare.c @@ -274,3 +274,11 @@ void test4() { if (value < (unsigned long) &ptr4) // expected-warning {{comparison of integers of different signs}} return; } + +// PR4807 +int test5(unsigned int x) { + return (x < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}} + && (0 > x) // expected-warning {{comparison of 0 > unsigned expression is always false}} + && (x >= 0) // expected-warning {{comparison of unsigned expression >= 0 is always true}} + && (0 <= x); // expected-warning {{comparison of 0 <= unsigned expression is always true}} +} diff --git a/test/Sema/missing-field-initializers.c b/test/Sema/missing-field-initializers.c new file mode 100644 index 000000000000..828191462444 --- /dev/null +++ b/test/Sema/missing-field-initializers.c @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-field-initializers %s + +// This was PR4808. + +struct Foo { int a, b; }; + +struct Foo foo0 = { 1 }; // expected-warning {{missing field 'b' initializer}} +struct Foo foo1 = { .a = 1 }; // designator avoids MFI warning +struct Foo foo2 = { .b = 1 }; // designator avoids MFI warning + +struct Foo bar0[] = { + { 1,2 }, + { 1 }, // expected-warning {{missing field 'b' initializer}} + { 1,2 } +}; + +struct Foo bar1[] = { + 1, 2, + 1, 2, + 1 +}; // expected-warning {{missing field 'b' initializer}} + +struct One { int a; int b; }; +struct Two { float c; float d; float e; }; + +struct Three { + union { + struct One one; + struct Two two; + } both; +}; + +struct Three t0 = { + { .one = { 1, 2 } } +}; +struct Three t1 = { + { .two = { 1.0f, 2.0f, 3.0f } } +}; + +struct Three data[] = { + { { .one = { 1, 2 } } }, + { { .one = { 1 } } }, // expected-warning {{missing field 'b' initializer}} + { { .two = { 1.0f, 2.0f, 3.0f } } }, + { { .two = { 1.0f, 2.0f } } } // expected-warning {{missing field 'e' initializer}} +}; + +struct { int:5; int a; int:5; int b; int:5 } noNamedImplicit[] = { + { 1, 2 }, + { 1 } // expected-warning {{missing field 'b' initializer}} +}; diff --git a/test/Sema/overloadable.c b/test/Sema/overloadable.c index ff631ed9c85e..28c3e4cf8c90 100644 --- a/test/Sema/overloadable.c +++ b/test/Sema/overloadable.c @@ -50,4 +50,13 @@ void test_promote(short* sp) { promote(sp); // expected-error{{call to unavailable function 'promote'}} } - +// PR6600 +typedef double Double; +typedef Double DoubleVec __attribute__((vector_size(16))); +typedef int Int; +typedef Int IntVec __attribute__((vector_size(16))); +double magnitude(DoubleVec) __attribute__((__overloadable__)); +double magnitude(IntVec) __attribute__((__overloadable__)); +double test_p6600(DoubleVec d) { + return magnitude(d) * magnitude(d); +} diff --git a/test/Sema/return.c b/test/Sema/return.c index 5d1c97f2a2ef..3ab23f4f8f8e 100644 --- a/test/Sema/return.c +++ b/test/Sema/return.c @@ -1,4 +1,4 @@ -// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wno-unreachable-code +// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value // clang emits the following warning by default. // With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the diff --git a/test/Sema/warn-unused-value.c b/test/Sema/warn-unused-value.c new file mode 100644 index 000000000000..2e0fa54effbf --- /dev/null +++ b/test/Sema/warn-unused-value.c @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s + +int i = 0; +int j = 0; + +void foo(); + +// PR4806 +void pr4806() { + 1,foo(); // expected-warning {{expression result unused}} + + // other + foo(); + i; // expected-warning {{expression result unused}} + + i,foo(); // expected-warning {{expression result unused}} + foo(),i; // expected-warning {{expression result unused}} + + i,j,foo(); // expected-warning {{expression result unused}} + i,foo(),j; // expected-warning {{expression result unused}} + foo(),i,j; // expected-warning {{expression result unused}} + + i++; + + i++,foo(); + foo(),i++; + + i++,j,foo(); // expected-warning {{expression result unused}} + i++,foo(),j; // expected-warning {{expression result unused}} + foo(),i++,j; // expected-warning {{expression result unused}} + + i,j++,foo(); // expected-warning {{expression result unused}} + i,foo(),j++; // expected-warning {{expression result unused}} + foo(),i,j++; // expected-warning {{expression result unused}} + + i++,j++,foo(); + i++,foo(),j++; + foo(),i++,j++; + + {}; + ({}); + ({}),foo(); + foo(),({}); + + (int)1U; // expected-warning {{expression result unused}} + (void)1U; + + // pointer to volatile has side effect (thus no warning) + int* pi = &i; + volatile int* pj = &j; + *pi; // expected-warning {{expression result unused}} + *pj; +} diff --git a/test/Sema/warn-write-strings.c b/test/Sema/warn-write-strings.c new file mode 100644 index 000000000000..938f0be7721f --- /dev/null +++ b/test/Sema/warn-write-strings.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -verify -fsyntax-only -Wwrite-strings %s + +// PR4804 +char* x = "foo"; // expected-warning {{initializing 'char const [4]' discards qualifiers, expected 'char *'}} |
