summaryrefslogtreecommitdiffstats
path: root/test/Sema
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-11-18 14:59:57 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-11-18 14:59:57 +0000
commit741c13ecc20fb35b836ad690aeecd402f002d654 (patch)
tree60a1694bec5a44d15456acc880cb2f91619f66aa /test/Sema
parentb3a51061b1b9c4add078237850649f7c9efb13ab (diff)
downloadFreeBSD-src-741c13ecc20fb35b836ad690aeecd402f002d654.zip
FreeBSD-src-741c13ecc20fb35b836ad690aeecd402f002d654.tar.gz
Update clang to r89205.
Diffstat (limited to 'test/Sema')
-rw-r--r--test/Sema/128bitint.c5
-rw-r--r--test/Sema/PR2727.c2
-rw-r--r--test/Sema/PR2728.c2
-rw-r--r--test/Sema/attr-format_arg.c2
-rw-r--r--test/Sema/attr-malloc.c6
-rw-r--r--test/Sema/block-byref-args.c2
-rw-r--r--test/Sema/block-storageclass.c2
-rw-r--r--test/Sema/builtin-object-size.c2
-rw-r--r--test/Sema/callingconv.c4
-rw-r--r--test/Sema/check-increment.c2
-rw-r--r--test/Sema/compare.c207
-rw-r--r--test/Sema/conditional-expr.c2
-rw-r--r--test/Sema/const-eval.c7
-rw-r--r--test/Sema/conversion-64-32.c5
-rw-r--r--test/Sema/conversion.c237
-rw-r--r--test/Sema/expr-comma-c89.c1
-rw-r--r--test/Sema/expr-comma.c1
-rw-r--r--test/Sema/format-attr-pr4470.c2
-rw-r--r--test/Sema/format-strings.c19
-rw-r--r--test/Sema/i-c-e.c2
-rw-r--r--test/Sema/implicit-builtin-redecl.c2
-rw-r--r--test/Sema/implicit-def.c2
-rw-r--r--test/Sema/parentheses.c2
-rw-r--r--test/Sema/pointer-conversion.c10
-rw-r--r--test/Sema/pragma-pack-4.c2
-rw-r--r--test/Sema/return.c2
-rw-r--r--test/Sema/shift.c2
-rw-r--r--test/Sema/ucn-cstring.c2
-rw-r--r--test/Sema/varargs.c2
-rw-r--r--test/Sema/wchar.c20
-rw-r--r--test/Sema/x86-intrinsics-headers.c4
31 files changed, 504 insertions, 58 deletions
diff --git a/test/Sema/128bitint.c b/test/Sema/128bitint.c
index 2a18d90..a068d81 100644
--- a/test/Sema/128bitint.c
+++ b/test/Sema/128bitint.c
@@ -1,6 +1,9 @@
-// RUN: clang-cc -fsyntax-only -verify %s
+// RUN: clang-cc -fsyntax-only -verify -triple x86_64-apple-darwin9 %s
typedef int i128 __attribute__((__mode__(TI)));
typedef unsigned u128 __attribute__((__mode__(TI)));
int a[((i128)-1 ^ (i128)-2) == 1 ? 1 : -1];
int a[(u128)-1 > 1LL ? 1 : -1];
+
+// PR5435
+__uint128_t b = (__uint128_t)-1;
diff --git a/test/Sema/PR2727.c b/test/Sema/PR2727.c
index 52d8392..0829dc2 100644
--- a/test/Sema/PR2727.c
+++ b/test/Sema/PR2727.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -verify -fsyntax-only -std=c90 %s &&
+// RUN: clang-cc -verify -fsyntax-only -std=c90 %s
// RUN: clang-cc -verify -fsyntax-only -std=c99 %s
int f (int x)
diff --git a/test/Sema/PR2728.c b/test/Sema/PR2728.c
index 26c96fe..e8c2e26 100644
--- a/test/Sema/PR2728.c
+++ b/test/Sema/PR2728.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -verify -fsyntax-only -std=c90 %s &&
+// RUN: clang-cc -verify -fsyntax-only -std=c90 %s
// RUN: clang-cc -verify -fsyntax-only -std=c99 %s
struct s
diff --git a/test/Sema/attr-format_arg.c b/test/Sema/attr-format_arg.c
index 0830951..5f06f4b 100644
--- a/test/Sema/attr-format_arg.c
+++ b/test/Sema/attr-format_arg.c
@@ -1,6 +1,6 @@
// RUN: clang-cc -fsyntax-only -verify %s
-#include <stdio.h>
+int printf(const char *, ...);
const char* f(const char *s) __attribute__((format_arg(1)));
diff --git a/test/Sema/attr-malloc.c b/test/Sema/attr-malloc.c
index 1adcf07..6483ffc 100644
--- a/test/Sema/attr-malloc.c
+++ b/test/Sema/attr-malloc.c
@@ -1,5 +1,5 @@
-// RUN: clang-cc -verify -fsyntax-only %s &&
-// RUN: clang-cc -emit-llvm -o %t %s &&
+// RUN: clang -Xclang -verify -fsyntax-only %s
+// RUN: clang -emit-llvm -S -o %t %s
#include <stdlib.h>
@@ -16,7 +16,7 @@ __attribute((malloc)) int (*g)(); // expected-warning{{'malloc' attribute only a
__attribute((malloc))
void * xalloc(unsigned n) { return malloc(n); } // no-warning
-// RUN: grep 'define noalias .* @xalloc(' %t &&
+// RUN: grep 'define noalias .* @xalloc(' %t
#define malloc_like __attribute((__malloc__))
void * xalloc2(unsigned) malloc_like;
diff --git a/test/Sema/block-byref-args.c b/test/Sema/block-byref-args.c
index 39745d5..06bab12 100644
--- a/test/Sema/block-byref-args.c
+++ b/test/Sema/block-byref-args.c
@@ -1,6 +1,6 @@
// RUN: clang-cc %s -fsyntax-only -verify -fblocks
-#include <stdio.h>
+int printf(const char *, ...);
int main(int argc, char **argv) {
__block void(*bobTheFunction)(void);
diff --git a/test/Sema/block-storageclass.c b/test/Sema/block-storageclass.c
index 3d2527b..aacf8be 100644
--- a/test/Sema/block-storageclass.c
+++ b/test/Sema/block-storageclass.c
@@ -1,6 +1,6 @@
// RUN: clang-cc %s -fsyntax-only -verify -fblocks
-#include <stdio.h>
+int printf(const char *, ...);
void _Block_byref_release(void*src){}
int main() {
diff --git a/test/Sema/builtin-object-size.c b/test/Sema/builtin-object-size.c
index 4b15cb1..0c6d288 100644
--- a/test/Sema/builtin-object-size.c
+++ b/test/Sema/builtin-object-size.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -verify %s &&
+// RUN: clang-cc -fsyntax-only -verify %s
// RUN: clang-cc -fsyntax-only -triple x86_64-apple-darwin9 -verify %s
int a[10];
diff --git a/test/Sema/callingconv.c b/test/Sema/callingconv.c
index 102115b..f65aab4 100644
--- a/test/Sema/callingconv.c
+++ b/test/Sema/callingconv.c
@@ -17,3 +17,7 @@ void __attribute__((fastcall)) test1(void) {
void __attribute__((fastcall)) test2(int a, ...) { // expected-error {{variadic function cannot use 'fastcall' calling convention}}
}
+
+void __attribute__((cdecl)) ctest0() {}
+
+void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{attribute requires 0 argument(s)}}
diff --git a/test/Sema/check-increment.c b/test/Sema/check-increment.c
index 9809544..72eae06 100644
--- a/test/Sema/check-increment.c
+++ b/test/Sema/check-increment.c
@@ -1,6 +1,6 @@
// RUN: clang-cc -fsyntax-only -verify %s
-#include <stdio.h>
+int printf(const char *, ...);
typedef int *pint;
int main() {
int a[5] = {0};
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index 9cbbfba..01a216f 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -pedantic -verify %s
+// RUN: clang-cc -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare %s
int test(char *C) { // nothing here should warn.
return C != ((void*)0);
@@ -8,23 +8,194 @@ int test(char *C) { // nothing here should warn.
}
int ints(long a, unsigned long b) {
- return (a == b) + // expected-warning {{comparison of integers of different signs}}
- ((int)a == b) + // expected-warning {{comparison of integers of different signs}}
- ((short)a == b) + // expected-warning {{comparison of integers of different signs}}
- (a == (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
- (a == (unsigned short) b); // expected-warning {{comparison of integers of different signs}}
-
- enum Enum {B};
- return (a == B) +
- ((int)a == B) +
- ((short)a == B) +
- (a == (unsigned int) B) + // expected-warning {{comparison of integers of different signs}}
- (a == (unsigned short) B); // expected-warning {{comparison of integers of different signs}}
-
- // Should be able to prove all of these are non-negative.
- return (b == (long) B) +
- (b == (int) B) +
- (b == (short) B);
+ enum EnumA {A};
+ enum EnumB {B};
+ enum EnumC {C = 0x10000};
+ return
+ // (a,b)
+ (a == (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ (a == (unsigned int) b) +
+ (a == (unsigned short) b) +
+ (a == (unsigned char) b) +
+ ((long) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((signed char) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((long) a == (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a == (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a == (unsigned short) b) + // expected-warning {{comparison of integers of different signs}}
+ ((signed char) a == (unsigned char) b) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) b) +
+ (a < (unsigned short) b) +
+ (a < (unsigned char) b) +
+ ((long) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((signed char) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((long) a < (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) b) + // expected-warning {{comparison of integers of different signs}}
+ ((signed char) a < (unsigned char) b) + // expected-warning {{comparison of integers of different signs}}
+
+ // (A,b)
+ (A == (unsigned long) b) +
+ (A == (unsigned int) b) +
+ (A == (unsigned short) b) +
+ (A == (unsigned char) b) +
+ ((long) A == b) +
+ ((int) A == b) +
+ ((short) A == b) +
+ ((signed char) A == b) +
+ ((long) A == (unsigned long) b) +
+ ((int) A == (unsigned int) b) +
+ ((short) A == (unsigned short) b) +
+ ((signed char) A == (unsigned char) b) +
+ (A < (unsigned long) b) +
+ (A < (unsigned int) b) +
+ (A < (unsigned short) b) +
+ (A < (unsigned char) b) +
+ ((long) A < b) +
+ ((int) A < b) +
+ ((short) A < b) +
+ ((signed char) A < b) +
+ ((long) A < (unsigned long) b) +
+ ((int) A < (unsigned int) b) +
+ ((short) A < (unsigned short) b) +
+ ((signed char) A < (unsigned char) b) +
+
+ // (a,B)
+ (a == (unsigned long) B) +
+ (a == (unsigned int) B) +
+ (a == (unsigned short) B) +
+ (a == (unsigned char) B) +
+ ((long) a == B) +
+ ((int) a == B) +
+ ((short) a == B) +
+ ((signed char) a == B) +
+ ((long) a == (unsigned long) B) +
+ ((int) a == (unsigned int) B) +
+ ((short) a == (unsigned short) B) +
+ ((signed char) a == (unsigned char) B) +
+ (a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) B) +
+ (a < (unsigned short) B) +
+ (a < (unsigned char) B) +
+ ((long) a < B) +
+ ((int) a < B) +
+ ((short) a < B) +
+ ((signed char) a < B) +
+ ((long) a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) B) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) B) + // expected-warning {{comparison of integers of different signs}}
+ ((signed char) a < (unsigned char) B) + // expected-warning {{comparison of integers of different signs}}
+
+ // (C,b)
+ (C == (unsigned long) b) +
+ (C == (unsigned int) b) +
+ (C == (unsigned short) b) +
+ (C == (unsigned char) b) +
+ ((long) C == b) +
+ ((int) C == b) +
+ ((short) C == b) +
+ ((signed char) C == b) +
+ ((long) C == (unsigned long) b) +
+ ((int) C == (unsigned int) b) +
+ ((short) C == (unsigned short) b) +
+ ((signed char) C == (unsigned char) b) +
+ (C < (unsigned long) b) +
+ (C < (unsigned int) b) +
+ (C < (unsigned short) b) +
+ (C < (unsigned char) b) +
+ ((long) C < b) +
+ ((int) C < b) +
+ ((short) C < b) +
+ ((signed char) C < b) +
+ ((long) C < (unsigned long) b) +
+ ((int) C < (unsigned int) b) +
+ ((short) C < (unsigned short) b) +
+ ((signed char) C < (unsigned char) b) +
+
+ // (a,C)
+ (a == (unsigned long) C) +
+ (a == (unsigned int) C) +
+ (a == (unsigned short) C) +
+ (a == (unsigned char) C) +
+ ((long) a == C) +
+ ((int) a == C) +
+ ((short) a == C) +
+ ((signed char) a == C) +
+ ((long) a == (unsigned long) C) +
+ ((int) a == (unsigned int) C) +
+ ((short) a == (unsigned short) C) +
+ ((signed char) a == (unsigned char) C) +
+ (a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) C) +
+ (a < (unsigned short) C) +
+ (a < (unsigned char) C) +
+ ((long) a < C) +
+ ((int) a < C) +
+ ((short) a < C) +
+ ((signed char) a < C) +
+ ((long) a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) C) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) C) + // expected-warning {{comparison of integers of different signs}}
+ ((signed char) a < (unsigned char) C) + // expected-warning {{comparison of integers of different signs}}
+
+ // (0x80000,b)
+ (0x80000 == (unsigned long) b) +
+ (0x80000 == (unsigned int) b) +
+ (0x80000 == (unsigned short) b) +
+ (0x80000 == (unsigned char) b) +
+ ((long) 0x80000 == b) +
+ ((int) 0x80000 == b) +
+ ((short) 0x80000 == b) +
+ ((signed char) 0x80000 == b) +
+ ((long) 0x80000 == (unsigned long) b) +
+ ((int) 0x80000 == (unsigned int) b) +
+ ((short) 0x80000 == (unsigned short) b) +
+ ((signed char) 0x80000 == (unsigned char) b) +
+ (0x80000 < (unsigned long) b) +
+ (0x80000 < (unsigned int) b) +
+ (0x80000 < (unsigned short) b) +
+ (0x80000 < (unsigned char) b) +
+ ((long) 0x80000 < b) +
+ ((int) 0x80000 < b) +
+ ((short) 0x80000 < b) +
+ ((signed char) 0x80000 < b) +
+ ((long) 0x80000 < (unsigned long) b) +
+ ((int) 0x80000 < (unsigned int) b) +
+ ((short) 0x80000 < (unsigned short) b) +
+ ((signed char) 0x80000 < (unsigned char) b) +
+
+ // (a,0x80000)
+ (a == (unsigned long) 0x80000) +
+ (a == (unsigned int) 0x80000) +
+ (a == (unsigned short) 0x80000) +
+ (a == (unsigned char) 0x80000) +
+ ((long) a == 0x80000) +
+ ((int) a == 0x80000) +
+ ((short) a == 0x80000) +
+ ((signed char) a == 0x80000) +
+ ((long) a == (unsigned long) 0x80000) +
+ ((int) a == (unsigned int) 0x80000) +
+ ((short) a == (unsigned short) 0x80000) +
+ ((signed char) a == (unsigned char) 0x80000) +
+ (a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) 0x80000) +
+ (a < (unsigned short) 0x80000) +
+ (a < (unsigned char) 0x80000) +
+ ((long) a < 0x80000) +
+ ((int) a < 0x80000) +
+ ((short) a < 0x80000) +
+ ((signed char) a < 0x80000) +
+ ((long) a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) 0x80000) + // expected-warning {{comparison of integers of different signs}}
+ ((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}}
+
+ 10
+ ;
}
int equal(char *a, const char *b) {
diff --git a/test/Sema/conditional-expr.c b/test/Sema/conditional-expr.c
index 3bfeae5d..8cac32c 100644
--- a/test/Sema/conditional-expr.c
+++ b/test/Sema/conditional-expr.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -verify -pedantic %s
+// RUN: clang-cc -fsyntax-only -verify -pedantic -Wsign-compare %s
void foo() {
*(0 ? (double *)0 : (void *)0) = 0;
// FIXME: GCC doesn't consider the the following two statements to be errors.
diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c
index 72db14c..39a24b3 100644
--- a/test/Sema/const-eval.c
+++ b/test/Sema/const-eval.c
@@ -68,3 +68,10 @@ EVAL_EXPR(32, (int*)0 != (int*)0 ? -1 : 1)
EVAL_EXPR(33, (void*)0 - (void*)0 == 0 ? 1 : -1)
void foo(void) {}
EVAL_EXPR(34, (foo == (void *)0) ? -1 : 1)
+
+// No PR. Mismatched bitwidths lead to a crash on second evaluation.
+const _Bool constbool = 0;
+EVAL_EXPR(35, constbool)
+EVAL_EXPR(36, constbool)
+
+EVAL_EXPR(37, (1,2.0) == 2.0)
diff --git a/test/Sema/conversion-64-32.c b/test/Sema/conversion-64-32.c
new file mode 100644
index 0000000..53830fd
--- /dev/null
+++ b/test/Sema/conversion-64-32.c
@@ -0,0 +1,5 @@
+// RUN: clang-cc -fsyntax-only -verify -Wshorten-64-to-32 -triple x86_64-apple-darwin %s
+
+int test0(long v) {
+ return v; // expected-warning {{implicit cast loses integer precision}}
+}
diff --git a/test/Sema/conversion.c b/test/Sema/conversion.c
new file mode 100644
index 0000000..bca23f8
--- /dev/null
+++ b/test/Sema/conversion.c
@@ -0,0 +1,237 @@
+// RUN: clang-cc -fsyntax-only -verify -Wconversion -triple x86_64-apple-darwin %s
+
+#define BIG 0x7f7f7f7f7f7f7f7fL
+
+void test0(char c, short s, int i, long l, long long ll) {
+ c = c;
+ c = s; // expected-warning {{implicit cast loses integer precision}}
+ c = i; // expected-warning {{implicit cast loses integer precision}}
+ c = l; // expected-warning {{implicit cast loses integer precision}}
+ s = c;
+ s = s;
+ s = i; // expected-warning {{implicit cast loses integer precision}}
+ s = l; // expected-warning {{implicit cast loses integer precision}}
+ i = c;
+ i = s;
+ i = i;
+ i = l; // expected-warning {{implicit cast loses integer precision}}
+ l = c;
+ l = s;
+ l = i;
+ l = l;
+
+ c = (char) 0;
+ c = (short) 0;
+ c = (int) 0;
+ c = (long) 0;
+ s = (char) 0;
+ s = (short) 0;
+ s = (int) 0;
+ s = (long) 0;
+ i = (char) 0;
+ i = (short) 0;
+ i = (int) 0;
+ i = (long) 0;
+ l = (char) 0;
+ l = (short) 0;
+ l = (int) 0;
+ l = (long) 0;
+
+ c = (char) BIG;
+ c = (short) BIG; // expected-warning {{implicit cast loses integer precision}}
+ c = (int) BIG; // expected-warning {{implicit cast loses integer precision}}
+ c = (long) BIG; // expected-warning {{implicit cast loses integer precision}}
+ s = (char) BIG;
+ s = (short) BIG;
+ s = (int) BIG; // expected-warning {{implicit cast loses integer precision}}
+ s = (long) BIG; // expected-warning {{implicit cast loses integer precision}}
+ i = (char) BIG;
+ i = (short) BIG;
+ i = (int) BIG;
+ i = (long) BIG; // expected-warning {{implicit cast loses integer precision}}
+ l = (char) BIG;
+ l = (short) BIG;
+ l = (int) BIG;
+ l = (long) BIG;
+}
+
+char test1(long long ll) {
+ return (long long) ll; // expected-warning {{implicit cast loses integer precision}}
+ return (long) ll; // expected-warning {{implicit cast loses integer precision}}
+ return (int) ll; // expected-warning {{implicit cast loses integer precision}}
+ return (short) ll; // expected-warning {{implicit cast loses integer precision}}
+ return (char) ll;
+ return (long long) BIG; // expected-warning {{implicit cast loses integer precision}}
+ return (long) BIG; // expected-warning {{implicit cast loses integer precision}}
+ return (int) BIG; // expected-warning {{implicit cast loses integer precision}}
+ return (short) BIG; // expected-warning {{implicit cast loses integer precision}}
+ return (char) BIG;
+}
+
+short test2(long long ll) {
+ return (long long) ll; // expected-warning {{implicit cast loses integer precision}}
+ return (long) ll; // expected-warning {{implicit cast loses integer precision}}
+ return (int) ll; // expected-warning {{implicit cast loses integer precision}}
+ return (short) ll;
+ return (char) ll;
+ return (long long) BIG; // expected-warning {{implicit cast loses integer precision}}
+ return (long) BIG; // expected-warning {{implicit cast loses integer precision}}
+ return (int) BIG; // expected-warning {{implicit cast loses integer precision}}
+ return (short) BIG;
+ return (char) BIG;
+}
+
+int test3(long long ll) {
+ return (long long) ll; // expected-warning {{implicit cast loses integer precision}}
+ return (long) ll; // expected-warning {{implicit cast loses integer precision}}
+ return (int) ll;
+ return (short) ll;
+ return (char) ll;
+ return (long long) BIG; // expected-warning {{implicit cast loses integer precision}}
+ return (long) BIG; // expected-warning {{implicit cast loses integer precision}}
+ return (int) BIG;
+ return (short) BIG;
+ return (char) BIG;
+}
+
+long test4(long long ll) {
+ return (long long) ll;
+ return (long) ll;
+ return (int) ll;
+ return (short) ll;
+ return (char) ll;
+ return (long long) BIG;
+ return (long) BIG;
+ return (int) BIG;
+ return (short) BIG;
+ return (char) BIG;
+}
+
+long long test5(long long ll) {
+ return (long long) ll;
+ return (long) ll;
+ return (int) ll;
+ return (short) ll;
+ return (char) ll;
+ return (long long) BIG;
+ return (long) BIG;
+ return (int) BIG;
+ return (short) BIG;
+ return (char) BIG;
+}
+
+void takes_char(char);
+void takes_short(short);
+void takes_int(int);
+void takes_long(long);
+void takes_longlong(long long);
+void takes_float(float);
+void takes_double(double);
+void takes_longdouble(long double);
+
+void test6(char v) {
+ takes_char(v);
+ takes_short(v);
+ takes_int(v);
+ takes_long(v);
+ takes_longlong(v);
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test7(short v) {
+ takes_char(v); // expected-warning {{implicit cast loses integer precision}}
+ takes_short(v);
+ takes_int(v);
+ takes_long(v);
+ takes_longlong(v);
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test8(int v) {
+ takes_char(v); // expected-warning {{implicit cast loses integer precision}}
+ takes_short(v); // expected-warning {{implicit cast loses integer precision}}
+ takes_int(v);
+ takes_long(v);
+ takes_longlong(v);
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test9(long v) {
+ takes_char(v); // expected-warning {{implicit cast loses integer precision}}
+ takes_short(v); // expected-warning {{implicit cast loses integer precision}}
+ takes_int(v); // expected-warning {{implicit cast loses integer precision}}
+ takes_long(v);
+ takes_longlong(v);
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test10(long long v) {
+ takes_char(v); // expected-warning {{implicit cast loses integer precision}}
+ takes_short(v); // expected-warning {{implicit cast loses integer precision}}
+ takes_int(v); // expected-warning {{implicit cast loses integer precision}}
+ takes_long(v);
+ takes_longlong(v);
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test11(float v) {
+ takes_char(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_short(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_int(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_long(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_longlong(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test12(double v) {
+ takes_char(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_short(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_int(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_long(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_longlong(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_float(v); // expected-warning {{implicit cast loses floating-point precision}}
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test13(long double v) {
+ takes_char(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_short(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_int(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_long(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_longlong(v); // expected-warning {{implicit cast turns floating-point number into integer}}
+ takes_float(v); // expected-warning {{implicit cast loses floating-point precision}}
+ takes_double(v); // expected-warning {{implicit cast loses floating-point precision}}
+ takes_longdouble(v);
+}
+
+void test14(long l) {
+ // Fine because of the boolean whitelist.
+ char c;
+ c = (l == 4);
+ c = ((l <= 4) && (l >= 0));
+ c = ((l <= 4) && (l >= 0)) || (l > 20);
+}
+
+void test15(char c) {
+ c = c + 1 + c * 2;
+ c = (short) c + 1 + c * 2; // expected-warning {{implicit cast loses integer precision}}
+}
+
+// PR 5422
+extern void *test16_external;
+void test16(void) {
+ int a = (unsigned long) &test16_external; // expected-warning {{implicit cast loses integer precision}}
+}
diff --git a/test/Sema/expr-comma-c89.c b/test/Sema/expr-comma-c89.c
index b2b17dc..ffe8b69 100644
--- a/test/Sema/expr-comma-c89.c
+++ b/test/Sema/expr-comma-c89.c
@@ -1,7 +1,6 @@
// RUN: clang-cc %s -fsyntax-only -verify -std=c99
// rdar://6095180
-#include <assert.h>
struct s { char c[17]; };
extern struct s foo(void);
diff --git a/test/Sema/expr-comma.c b/test/Sema/expr-comma.c
index 6407986..3a05130 100644
--- a/test/Sema/expr-comma.c
+++ b/test/Sema/expr-comma.c
@@ -1,7 +1,6 @@
// RUN: clang-cc %s -fsyntax-only -verify -std=c89
// rdar://6095180
-#include <assert.h>
struct s { char c[17]; };
extern struct s foo(void);
diff --git a/test/Sema/format-attr-pr4470.c b/test/Sema/format-attr-pr4470.c
index c03c573..24eece8 100644
--- a/test/Sema/format-attr-pr4470.c
+++ b/test/Sema/format-attr-pr4470.c
@@ -1,7 +1,7 @@
// RUN: clang-cc -fsyntax-only -verify -Wformat=2 %s
-#include <stdio.h>
#include <stdarg.h>
+int vprintf(const char *, va_list);
const char *foo(const char *format) __attribute__((format_arg(1)));
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index 797e53c..0a9fcce 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -1,17 +1,20 @@
// RUN: clang-cc -fsyntax-only -verify -Wformat-nonliteral %s
-// Define this to get vasprintf on Linux
-#define _GNU_SOURCE
-
-#include <stdio.h>
#include <stdarg.h>
+typedef __typeof(sizeof(int)) size_t;
+typedef struct _FILE FILE;
+int fprintf(FILE *, const char *restrict, ...);
+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 vfprintf(FILE *, const char *restrict, va_list);
+int vprintf(const char *restrict, va_list);
+int vsnprintf(char *, size_t, const char *, va_list);
+int vsprintf(char *restrict, const char *restrict, va_list);
char * global_fmt;
-#if defined(_WIN32) || defined(_WIN64)
-extern int snprintf(char*, size_t, const char*, ...);
-#endif
-
void check_string_literal( FILE* fp, const char* s, char *buf, ... ) {
char * b;
diff --git a/test/Sema/i-c-e.c b/test/Sema/i-c-e.c
index de27966..6e14833 100644
--- a/test/Sema/i-c-e.c
+++ b/test/Sema/i-c-e.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc %s -fsyntax-only -verify -pedantic -fpascal-strings
+// RUN: clang %s -fsyntax-only -Xclang -verify -pedantic -fpascal-strings
#include <stdint.h>
#include <limits.h>
diff --git a/test/Sema/implicit-builtin-redecl.c b/test/Sema/implicit-builtin-redecl.c
index 36513ba..fc51312 100644
--- a/test/Sema/implicit-builtin-redecl.c
+++ b/test/Sema/implicit-builtin-redecl.c
@@ -23,4 +23,4 @@ int f3() {
return index << 2;
}
-typedef int rindex; \ No newline at end of file
+typedef int rindex;
diff --git a/test/Sema/implicit-def.c b/test/Sema/implicit-def.c
index 2c25946..3b31b99 100644
--- a/test/Sema/implicit-def.c
+++ b/test/Sema/implicit-def.c
@@ -1,4 +1,4 @@
-/* RUN: clang-cc -fsyntax-only %s -std=c89 &&
+/* RUN: clang-cc -fsyntax-only %s -std=c89
* RUN: not clang-cc -fsyntax-only %s -std=c99 -pedantic-errors
*/
diff --git a/test/Sema/parentheses.c b/test/Sema/parentheses.c
index a8ad260..f9f647c 100644
--- a/test/Sema/parentheses.c
+++ b/test/Sema/parentheses.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -Wparentheses -fsyntax-only -verify %s &&
+// RUN: clang-cc -Wparentheses -fsyntax-only -verify %s
// RUN: clang-cc -Wparentheses -fixit %s -o - | clang-cc -Wparentheses -Werror -
// Test the various warnings under -Wparentheses
diff --git a/test/Sema/pointer-conversion.c b/test/Sema/pointer-conversion.c
new file mode 100644
index 0000000..5f41ff6
--- /dev/null
+++ b/test/Sema/pointer-conversion.c
@@ -0,0 +1,10 @@
+//RUN: clang-cc -fsyntax-only -verify %s
+
+char * c;
+char const ** c2 = &c; // expected-warning {{initializing, 'char const **' and 'char **' have different qualifiers in nested pointer types}}
+
+typedef char dchar;
+dchar *** c3 = &c2; // expected-warning {{initializing, 'dchar ***' and 'char const ***' have different qualifiers in nested pointer types}}
+
+volatile char * c4;
+char ** c5 = &c4; // expected-warning {{initializing, 'char **' and 'char volatile **' have different qualifiers in nested pointer types}}
diff --git a/test/Sema/pragma-pack-4.c b/test/Sema/pragma-pack-4.c
index f6f107d..3ccaf7e 100644
--- a/test/Sema/pragma-pack-4.c
+++ b/test/Sema/pragma-pack-4.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -triple i686-apple-darwin9 %s -fsyntax-only -verify &&
+// RUN: clang-cc -triple i686-apple-darwin9 %s -fsyntax-only -verify
// RUN: clang-cc -triple x86_64-apple-darwin9 %s -fsyntax-only -verify
// rdar://problem/7095436
diff --git a/test/Sema/return.c b/test/Sema/return.c
index cdd3105..ad75cf1 100644
--- a/test/Sema/return.c
+++ b/test/Sema/return.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc %s -fsyntax-only -verify -fblocks
+// RUN: clang %s -fsyntax-only -Xclang -verify -fblocks
// clang emits the following warning by default.
// With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the
diff --git a/test/Sema/shift.c b/test/Sema/shift.c
index 2516d1b..fdfebc5 100644
--- a/test/Sema/shift.c
+++ b/test/Sema/shift.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -Wall -fsyntax-only -verify %s
+// RUN: clang -Wall -fsyntax-only -Xclang -verify %s
#include <limits.h>
diff --git a/test/Sema/ucn-cstring.c b/test/Sema/ucn-cstring.c
index 6d021fd..fb9a3b6 100644
--- a/test/Sema/ucn-cstring.c
+++ b/test/Sema/ucn-cstring.c
@@ -1,6 +1,6 @@
// RUN: clang-cc %s -verify -fsyntax-only -pedantic
-#include <stdio.h>
+int printf(const char *, ...);
int main(void) {
int a[sizeof("hello \u2192 \u2603 \u2190 world") == 24 ? 1 : -1];
diff --git a/test/Sema/varargs.c b/test/Sema/varargs.c
index 8d2f0b1..e928997 100644
--- a/test/Sema/varargs.c
+++ b/test/Sema/varargs.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -verify %s &&
+// RUN: clang-cc -fsyntax-only -verify %s
// RUN: clang-cc -fsyntax-only -verify %s -triple x86_64-apple-darwin9
void f1(int a)
diff --git a/test/Sema/wchar.c b/test/Sema/wchar.c
index 1637600..e201c7e 100644
--- a/test/Sema/wchar.c
+++ b/test/Sema/wchar.c
@@ -1,12 +1,20 @@
-// RUN: clang-cc %s -fsyntax-only -verify
-#include <wchar.h>
+// RUN: clang %s -fsyntax-only -Xclang -verify
+// RUN: clang %s -fsyntax-only -fshort-wchar -Xclang -verify -DSHORT_WCHAR
-int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];
+typedef __WCHAR_TYPE__ wchar_t;
+#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
+ || defined(_M_X64) || defined(SHORT_WCHAR)
+ #define WCHAR_T_TYPE unsigned short
+#else
+ #define WCHAR_T_TYPE int
+#endif
+
+int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];
+
void foo() {
- int t1[] = L"x";
+ WCHAR_T_TYPE t1[] = L"x";
wchar_t tab[] = L"x";
-
- int t2[] = "x"; // expected-error {{initialization}}
+ WCHAR_T_TYPE t2[] = "x"; // expected-error {{initialization}}
char t3[] = L"x"; // expected-error {{initialization}}
}
diff --git a/test/Sema/x86-intrinsics-headers.c b/test/Sema/x86-intrinsics-headers.c
index dd7dd5c..5b43e2b 100644
--- a/test/Sema/x86-intrinsics-headers.c
+++ b/test/Sema/x86-intrinsics-headers.c
@@ -1,5 +1,5 @@
-// RUN: clang -fsyntax-only %s &&
-// RUN: clang -fsyntax-only -fno-lax-vector-conversions %s &&
+// RUN: clang -fsyntax-only %s
+// RUN: clang -fsyntax-only -fno-lax-vector-conversions %s
// RUN: clang -fsyntax-only -x c++ %s
#if defined(i386) || defined(__x86_64__)
OpenPOWER on IntegriCloud