summaryrefslogtreecommitdiffstats
path: root/test/Sema
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema')
-rw-r--r--test/Sema/128bitint.c14
-rw-r--r--test/Sema/address_spaces.c19
-rw-r--r--test/Sema/alignas.c17
-rw-r--r--test/Sema/alloc_size.c3
-rw-r--r--test/Sema/anonymous-struct-union.c2
-rw-r--r--test/Sema/asm.c7
-rw-r--r--test/Sema/ast-print.c14
-rw-r--r--test/Sema/atomic-ops.c8
-rw-r--r--test/Sema/attr-availability.c13
-rw-r--r--test/Sema/attr-cleanup.c4
-rw-r--r--test/Sema/attr-mode.c2
-rw-r--r--test/Sema/attr-print.c21
-rw-r--r--test/Sema/attr-regparm.c2
-rw-r--r--test/Sema/attr-used.c2
-rw-r--r--test/Sema/attr-visibility.c4
-rw-r--r--test/Sema/attr-weak.c6
-rw-r--r--test/Sema/block-return.c11
-rw-r--r--test/Sema/builtins.c15
-rw-r--r--test/Sema/callingconv.c4
-rw-r--r--test/Sema/compare.c16
-rw-r--r--test/Sema/complex-imag.c4
-rw-r--r--test/Sema/decl-invalid.c4
-rw-r--r--test/Sema/declspec.c2
-rw-r--r--test/Sema/expr-address-of.c12
-rw-r--r--test/Sema/expr-comma-c99.c2
-rw-r--r--test/Sema/expr-comma.c2
-rw-r--r--test/Sema/exprs.c2
-rw-r--r--test/Sema/extern-redecl.c13
-rw-r--r--test/Sema/format-strings-fixit.c8
-rw-r--r--test/Sema/format-strings.c3
-rw-r--r--test/Sema/function-redecl.c2
-rw-r--r--test/Sema/gnu89.c2
-rw-r--r--test/Sema/i-c-e.c2
-rw-r--r--test/Sema/implicit-cast-dump.c15
-rw-r--r--test/Sema/inline.c10
-rw-r--r--test/Sema/invalid-cast.cpp11
-rw-r--r--test/Sema/invalid-decl.c8
-rw-r--r--test/Sema/memset-invalid-1.c15
-rw-r--r--test/Sema/merge-decls.c54
-rw-r--r--test/Sema/mips16_attr_allowed.c27
-rw-r--r--test/Sema/mips16_attr_not_allowed.c7
-rw-r--r--test/Sema/ms-inline-asm-invalid-arch.c5
-rw-r--r--test/Sema/ms-inline-asm.c11
-rw-r--r--test/Sema/nowarn-documentation-property.m15
-rw-r--r--test/Sema/parentheses.cpp12
-rw-r--r--test/Sema/pid_t.c11
-rw-r--r--test/Sema/ppc-bool.c4
-rw-r--r--test/Sema/private-extern.c1
-rw-r--r--test/Sema/return-noreturn.c5
-rw-r--r--test/Sema/return.c5
-rw-r--r--test/Sema/static-assert.c35
-rw-r--r--test/Sema/struct-decl.c2
-rw-r--r--test/Sema/switch-1.c22
-rw-r--r--test/Sema/types.c2
-rw-r--r--test/Sema/ucn-cstring.c2
-rw-r--r--test/Sema/ucn-identifiers.c35
-rw-r--r--test/Sema/uninit-det-order.c13
-rw-r--r--test/Sema/unused-expr-system-header.c6
-rw-r--r--test/Sema/unused-expr.c29
-rw-r--r--test/Sema/varargs.c2
-rw-r--r--test/Sema/varargs_unreachable.c14
-rw-r--r--test/Sema/variadic-promotion.c13
-rw-r--r--test/Sema/warn-documentation-crlf.c13
-rw-r--r--test/Sema/warn-documentation.cpp114
-rw-r--r--test/Sema/warn-documentation.m74
-rw-r--r--test/Sema/warn-duplicate-enum.c92
-rw-r--r--test/Sema/warn-main-return-type.c49
-rw-r--r--test/Sema/warn-main.c33
-rw-r--r--test/Sema/warn-missing-prototypes.c8
-rw-r--r--test/Sema/warn-sizeof-array-decay.c18
-rw-r--r--test/Sema/warn-type-safety-mpi-hdf5.c10
-rw-r--r--test/Sema/warn-unreachable.c8
-rw-r--r--test/Sema/warn-unused-variables-werror.c6
-rw-r--r--test/Sema/warn-vla.c12
-rw-r--r--test/Sema/wchar.c2
75 files changed, 1005 insertions, 67 deletions
diff --git a/test/Sema/128bitint.c b/test/Sema/128bitint.c
index 600c25a..bb8e3d1 100644
--- a/test/Sema/128bitint.c
+++ b/test/Sema/128bitint.c
@@ -1,9 +1,13 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 -fms-extensions %s -DHAVE
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu -fms-extensions %s -DHAVE_NOT
+
+#ifdef HAVE
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];
+int a[__SIZEOF_INT128__ == 16 ? 1 : -1];
// PR5435
__uint128_t b = (__uint128_t)-1;
@@ -36,4 +40,12 @@ void test(int *buf)
{
MPI_Send(buf, 0x10000000000000001i128); // expected-warning {{implicit conversion from '__int128' to 'int' changes value}}
}
+#else
+
+__int128 n; // expected-error {{__int128 is not supported on this target}}
+
+#if defined(__SIZEOF_INT128__)
+#error __SIZEOF_INT128__ should not be defined
+#endif
+#endif
diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c
index 24799da..0ae3230 100644
--- a/test/Sema/address_spaces.c
+++ b/test/Sema/address_spaces.c
@@ -6,7 +6,7 @@
void bar(_AS2 int a); // expected-error {{parameter may not be qualified with an address space}}
-void foo(_AS3 float *a,
+void foo(_AS3 float *a,
_AS1 float b) // expected-error {{parameter may not be qualified with an address space}}
{
_AS2 *x;// expected-warning {{type specifier missing, defaults to 'int'}}
@@ -48,3 +48,20 @@ void test3(void) {
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}}
+
+
+typedef _AS2 int AS2Int;
+
+struct HasASFields
+{
+ _AS2 int as_field; // expected-error {{field may not be qualified with an address space}}
+ AS2Int typedef_as_field; // expected-error {{field may not be qualified with an address space}}
+};
+
+// Assertion failure was when the field was accessed
+void access_as_field()
+{
+ struct HasASFields x;
+ (void) bar.as_field;
+}
+
diff --git a/test/Sema/alignas.c b/test/Sema/alignas.c
index d9a0164..020eff6 100644
--- a/test/Sema/alignas.c
+++ b/test/Sema/alignas.c
@@ -1,20 +1,29 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -Dalignof=__alignof %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -Dalignof=_Alignof %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -Dalignof=_Alignof -DUSING_C11_SYNTAX %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) int align_small; // expected-error {{requested alignment is less than minimum}}
_Alignas(1) unsigned _Alignas(8) int _Alignas(1) align_multiple;
struct align_member {
_Alignas(8) int member;
+ _Alignas(1) char bitfield : 1; // expected-error {{'_Alignas' attribute cannot be applied to a bit-field}}
};
-typedef _Alignas(8) char align_typedef; // FIXME: this should be rejected
+typedef _Alignas(8) char align_typedef; // expected-error {{'_Alignas' attribute only applies to variables and fields}}
+void f(_Alignas(1) char c) { // expected-error {{'_Alignas' attribute cannot be applied to a function parameter}}
+ _Alignas(1) register char k; // expected-error {{'_Alignas' attribute cannot be applied to a variable with 'register' storage class}}
+}
+
+#ifdef USING_C11_SYNTAX
+// expected-warning@+4{{'_Alignof' applied to an expression is a GNU extension}}
+// expected-warning@+4{{'_Alignof' applied to an expression is a GNU extension}}
+// expected-warning@+4{{'_Alignof' applied to an expression is a GNU extension}}
+#endif
_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/alloc_size.c b/test/Sema/alloc_size.c
index e2f5298..84f3932 100644
--- a/test/Sema/alloc_size.c
+++ b/test/Sema/alloc_size.c
@@ -23,4 +23,5 @@ void* fn9(unsigned) __attribute__((alloc_size(12345678901234567890123))); // exp
void* fn10(size_t, size_t) __attribute__((alloc_size(1,2))); // expected-error{{redefinition of parameter}} \
// expected-error{{a parameter list without types is only allowed in a function definition}} \
- // expected-warning{{alloc_size attribute only applies to functions and methods}}
+ // expected-error{{attribute parameter 1 is out of bounds}}
+void* fn11() __attribute__((alloc_size(1))); // expected-error{{attribute parameter 1 is out of bounds}}
diff --git a/test/Sema/anonymous-struct-union.c b/test/Sema/anonymous-struct-union.c
index e082290..35d3175 100644
--- a/test/Sema/anonymous-struct-union.c
+++ b/test/Sema/anonymous-struct-union.c
@@ -78,7 +78,7 @@ void g() {
struct s0 { union { int f0; }; };
// <rdar://problem/6481130>
-typedef struct { }; // expected-warning{{declaration does not declare anything}}
+typedef struct { }; // expected-warning{{typedef requires a name}}
// PR3675
struct s1 {
diff --git a/test/Sema/asm.c b/test/Sema/asm.c
index 155d736..2c60085 100644
--- a/test/Sema/asm.c
+++ b/test/Sema/asm.c
@@ -123,3 +123,10 @@ void test13(void) {
void *esp;
__asm__ volatile ("mov %%esp, %o" : "=r"(esp) : : ); // expected-error {{invalid % escape in inline assembly string}}
}
+
+// <rdar://problem/12700799>
+struct S; // expected-note 2 {{forward declaration of 'struct S'}}
+void test14(struct S *s) {
+ __asm("": : "a"(*s)); // expected-error {{dereference of pointer to incomplete type 'struct S'}}
+ __asm("": "=a" (*s) :); // expected-error {{dereference of pointer to incomplete type 'struct S'}}
+}
diff --git a/test/Sema/ast-print.c b/test/Sema/ast-print.c
index ff66d35..2066e18 100644
--- a/test/Sema/ast-print.c
+++ b/test/Sema/ast-print.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -ast-print
+// RUN: %clang_cc1 %s -ast-print | FileCheck %s
typedef void func_typedef();
func_typedef xxx;
@@ -6,3 +6,15 @@ func_typedef xxx;
typedef void func_t(int x);
func_t a;
+struct blah {
+ struct {
+ struct {
+ int b;
+ };
+ };
+};
+
+int foo(const struct blah *b) {
+ // CHECK: return b->b;
+ return b->b;
+}
diff --git a/test/Sema/atomic-ops.c b/test/Sema/atomic-ops.c
index 2a93591..b3daa07 100644
--- a/test/Sema/atomic-ops.c
+++ b/test/Sema/atomic-ops.c
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=i686-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=aarch64-linux-gnu -std=c11
// Basic parsing/Sema tests for __c11_atomic_*
@@ -17,7 +18,11 @@ _Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2, "");
_Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
_Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
_Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
+#ifdef __i386__
_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
+#else
+_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
+#endif
_Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
_Static_assert(__c11_atomic_is_lock_free(1), "");
@@ -168,3 +173,6 @@ void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d,
__c11_atomic_store(&const_atomic, 0, memory_order_release); // expected-error {{first argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
__c11_atomic_load(&const_atomic, memory_order_acquire); // expected-error {{first argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
}
+
+_Atomic(int*) PR12527_a;
+void PR12527() { int *b = PR12527_a; }
diff --git a/test/Sema/attr-availability.c b/test/Sema/attr-availability.c
index e0c541e..ac6a187 100644
--- a/test/Sema/attr-availability.c
+++ b/test/Sema/attr-availability.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -verify %s
void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in 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}}
@@ -43,3 +43,14 @@ void f7(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warn
#if !__has_feature(attribute_availability_with_message)
# error "Missing __has_feature"
#endif
+
+extern int x __attribute__((availability(macosx,introduced=10.5)));
+extern int x;
+
+void f8() {
+ int (^b)(int);
+ b = ^ (int i) __attribute__((availability(macosx,introduced=10.2))) { return 1; }; // expected-warning {{'availability' attribute ignored}}
+}
+
+extern int x2 __attribute__((availability(macosx,introduced=10.2))); // expected-note {{previous attribute is here}}
+extern int x2 __attribute__((availability(macosx,introduced=10.5))); // expected-warning {{availability does not match previous declaration}}
diff --git a/test/Sema/attr-cleanup.c b/test/Sema/attr-cleanup.c
index 59ebbfc..991822e 100644
--- a/test/Sema/attr-cleanup.c
+++ b/test/Sema/attr-cleanup.c
@@ -38,3 +38,7 @@ void t4() {
__attribute((cleanup(c4))) void* g;
}
+void c5(void*) __attribute__((deprecated)); // expected-note{{'c5' declared here}}
+void t5() {
+ int i __attribute__((cleanup(c5))); // expected-warning {{'c5' is deprecated}}
+}
diff --git a/test/Sema/attr-mode.c b/test/Sema/attr-mode.c
index 0c53362..a89c839 100644
--- a/test/Sema/attr-mode.c
+++ b/test/Sema/attr-mode.c
@@ -17,6 +17,8 @@ typedef int invalid_3 __attribute((mode(II))); // expected-error{{unknown machin
typedef struct {int i,j,k;} invalid_4 __attribute((mode(SI))); // expected-error{{mode attribute only supported for integer and floating-point types}}
typedef float invalid_5 __attribute((mode(SI))); // expected-error{{type of machine mode does not match type of base type}}
+typedef unsigned unwind_word __attribute((mode(unwind_word)));
+
int **__attribute((mode(QI)))* i32; // expected-error{{mode attribute}}
typedef _Complex double c32 __attribute((mode(SC)));
diff --git a/test/Sema/attr-print.c b/test/Sema/attr-print.c
new file mode 100644
index 0000000..2659508
--- /dev/null
+++ b/test/Sema/attr-print.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -ast-print -fms-extensions | FileCheck %s
+
+// CHECK: int x __attribute__((aligned(4)));
+int x __attribute__((aligned(4)));
+
+// FIXME: Print this at a valid location for a __declspec attr.
+// CHECK: int y __declspec(align(4));
+__declspec(align(4)) int y;
+
+// CHECK: void foo() __attribute__((const));
+void foo() __attribute__((const));
+
+// CHECK: void bar() __attribute__((__const));
+void bar() __attribute__((__const));
+
+// FIXME: Print these at a valid location for these attributes.
+// CHECK: int *p32 __ptr32;
+int * __ptr32 p32;
+
+// CHECK: int *p64 __ptr64;
+int * __ptr64 p64;
diff --git a/test/Sema/attr-regparm.c b/test/Sema/attr-regparm.c
index 642c07e..ccd894e 100644
--- a/test/Sema/attr-regparm.c
+++ b/test/Sema/attr-regparm.c
@@ -8,4 +8,4 @@ __attribute((regparm(5,3))) int x4(void); // expected-error{{attribute takes one
void __attribute__((regparm(3))) x5(int);
void x5(int); // expected-note{{previous declaration is here}}
-void __attribute__((regparm(2))) x5(int); // expected-error{{function declared with with regparm(2) attribute was previously declared with the regparm(3) attribute}}
+void __attribute__((regparm(2))) x5(int); // expected-error{{function declared with regparm(2) attribute was previously declared with the regparm(3) attribute}}
diff --git a/test/Sema/attr-used.c b/test/Sema/attr-used.c
index e2dfab1..accc7b6 100644
--- a/test/Sema/attr-used.c
+++ b/test/Sema/attr-used.c
@@ -17,4 +17,4 @@ void f1() {
int b __attribute__((used)); // expected-warning {{used attribute ignored}}
}
-
+static void __attribute__((used)) f0(void);
diff --git a/test/Sema/attr-visibility.c b/test/Sema/attr-visibility.c
index 77bc39c..7f7fd54 100644
--- a/test/Sema/attr-visibility.c
+++ b/test/Sema/attr-visibility.c
@@ -21,4 +21,6 @@ void test6() __attribute__((visibility("hidden"), // expected-note {{previous at
extern int test7 __attribute__((visibility("default"))); // expected-note {{previous attribute is here}}
extern int test7 __attribute__((visibility("hidden"))); // expected-error {{visibility does not match previous declaration}}
-typedef int __attribute__((visibility("default"))) bar; // expected-warning {{visibility attribute ignored}}
+typedef int __attribute__((visibility("default"))) bar; // expected-warning {{'visibility' attribute ignored}}
+
+int x __attribute__((type_visibility("default"))); // expected-error {{'type_visibility' attribute only applies to types and namespaces}}
diff --git a/test/Sema/attr-weak.c b/test/Sema/attr-weak.c
index adedf12..df74554 100644
--- a/test/Sema/attr-weak.c
+++ b/test/Sema/attr-weak.c
@@ -16,3 +16,9 @@ static int x __attribute__((weak)); // expected-error {{weak declaration cannot
// rdar://9538608
int C; // expected-note {{previous definition is here}}
extern int C __attribute__((weak_import)); // expected-warning {{an already-declared variable is made a weak_import declaration}}
+
+static int pr14946_x;
+extern int pr14946_x __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
+
+static void pr14946_f();
+void pr14946_f() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index 2ea4d81..6b4d998 100644
--- a/test/Sema/block-return.c
+++ b/test/Sema/block-return.c
@@ -134,3 +134,14 @@ void foo7()
void (^blk)(void) = ^{
return (void)0; // expected-warning {{void block literal should not return void expression}}
};
+
+// rdar://13463504
+enum Test8 { T8_a, T8_b, T8_c };
+void test8(void) {
+ extern void test8_helper(int (^)(int));
+ test8_helper(^(int flag) { if (flag) return T8_a; return T8_b; });
+}
+void test8b(void) {
+ extern void test8_helper2(char (^)(int)); // expected-note {{here}}
+ test8_helper2(^(int flag) { if (flag) return T8_a; return T8_b; }); // expected-error {{passing 'enum Test8 (^)(int)' to parameter of type 'char (^)(int)'}}
+}
diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c
index e3b3b7e..d525ac0 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -176,3 +176,18 @@ void test17() {
#undef T
#undef F
}
+
+void test18() {
+ char src[1024];
+ char dst[2048];
+ size_t result;
+ void *ptr;
+
+ ptr = __builtin___memccpy_chk(dst, src, '\037', sizeof(src), sizeof(dst));
+ result = __builtin___strlcpy_chk(dst, src, sizeof(src), sizeof(dst));
+ result = __builtin___strlcat_chk(dst, src, sizeof(src), sizeof(dst));
+
+ ptr = __builtin___memccpy_chk(dst, src, '\037', sizeof(src)); // expected-error {{too few arguments to function call}}
+ ptr = __builtin___strlcpy_chk(dst, src, sizeof(src), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
+ ptr = __builtin___strlcat_chk(dst, src, sizeof(src), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
+}
diff --git a/test/Sema/callingconv.c b/test/Sema/callingconv.c
index 266242d..e487020 100644
--- a/test/Sema/callingconv.c
+++ b/test/Sema/callingconv.c
@@ -43,7 +43,7 @@ int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requ
/* These are ignored because the target is i386 and not ARM */
int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
-int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{Invalid PCS type}}
+int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
// PR6361
void ctest3();
@@ -54,3 +54,5 @@ typedef __attribute__((stdcall)) void (*PROC)();
PROC __attribute__((cdecl)) ctest4(const char *x) {}
void __attribute__((pnaclcall)) pnaclfunc(float *a) {} // expected-warning {{calling convention 'pnaclcall' ignored for this target}}
+
+void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {}
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index b5d4ef5..887bce0 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -93,8 +93,8 @@ int ints(long a, unsigned long b) {
// (C,b)
(C == (unsigned long) b) +
(C == (unsigned int) b) +
- (C == (unsigned short) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned short' is always false}}
- (C == (unsigned char) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned char' is always false}}
+ (C == (unsigned short) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned short' is always false}}
+ (C == (unsigned char) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned char' is always false}}
((long) C == b) +
((int) C == b) +
((short) C == b) +
@@ -105,8 +105,8 @@ int ints(long a, unsigned long b) {
((signed char) C == (unsigned char) b) +
(C < (unsigned long) b) +
(C < (unsigned int) b) +
- (C < (unsigned short) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned short' is always false}}
- (C < (unsigned char) b) + // expected-warning {{comparison of constant 65536 with expression of type 'unsigned char' is always false}}
+ (C < (unsigned short) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned short' is always false}}
+ (C < (unsigned char) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned char' is always false}}
((long) C < b) +
((int) C < b) +
((short) C < b) +
@@ -123,8 +123,8 @@ int ints(long a, unsigned long b) {
(a == (unsigned char) C) +
((long) a == C) +
((int) a == C) +
- ((short) a == C) + // expected-warning {{comparison of constant 65536 with expression of type 'short' is always false}}
- ((signed char) a == C) + // expected-warning {{comparison of constant 65536 with expression of type 'signed char' is always false}}
+ ((short) a == C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'short' is always false}}
+ ((signed char) a == C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'signed char' is always false}}
((long) a == (unsigned long) C) +
((int) a == (unsigned int) C) +
((short) a == (unsigned short) C) +
@@ -135,8 +135,8 @@ int ints(long a, unsigned long b) {
(a < (unsigned char) C) +
((long) a < C) +
((int) a < C) +
- ((short) a < C) + // expected-warning {{comparison of constant 65536 with expression of type 'short' is always true}}
- ((signed char) a < C) + // expected-warning {{comparison of constant 65536 with expression of type 'signed char' is always true}}
+ ((short) a < C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'short' is always true}}
+ ((signed char) a < C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'signed char' is always true}}
((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) +
diff --git a/test/Sema/complex-imag.c b/test/Sema/complex-imag.c
index 1c6fb15..deaf627 100644
--- a/test/Sema/complex-imag.c
+++ b/test/Sema/complex-imag.c
@@ -4,7 +4,7 @@ void f1() {
int a = 1;
int b = __imag a;
int *c = &__real a;
- int *d = &__imag a; // expected-error {{must be an lvalue}}
+ int *d = &__imag a; // expected-error {{cannot take the address of an rvalue of type 'int'}}
}
void f2() {
@@ -18,7 +18,7 @@ void f3() {
double a = 1;
double b = __imag a;
double *c = &__real a;
- double *d = &__imag a; // expected-error {{must be an lvalue}}
+ double *d = &__imag a; // expected-error {{cannot take the address of an rvalue of type 'double'}}
}
void f4() {
diff --git a/test/Sema/decl-invalid.c b/test/Sema/decl-invalid.c
index f6fed3c..0544304 100644
--- a/test/Sema/decl-invalid.c
+++ b/test/Sema/decl-invalid.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify
// See Sema::ParsedFreeStandingDeclSpec about the double diagnostic
-typedef union <anonymous> __mbstate_t; // expected-error {{declaration of anonymous union must be a definition}} expected-warning {{declaration does not declare anything}}
+typedef union <anonymous> __mbstate_t; // expected-error {{declaration of anonymous union must be a definition}} expected-warning {{typedef requires a name}}
// PR2017
@@ -14,7 +14,7 @@ int a() {
}
int; // expected-warning {{declaration does not declare anything}}
-typedef int; // expected-warning {{declaration does not declare anything}}
+typedef int; // expected-warning {{typedef requires a name}}
const int; // expected-warning {{declaration does not declare anything}}
struct; // expected-error {{declaration of anonymous struct must be a definition}} // expected-warning {{declaration does not declare anything}}
typedef int I;
diff --git a/test/Sema/declspec.c b/test/Sema/declspec.c
index 7354028..30c0092 100644
--- a/test/Sema/declspec.c
+++ b/test/Sema/declspec.c
@@ -10,7 +10,7 @@ int typedef validTypeDecl() { } // expected-error {{function definition declared
struct _zend_module_entry { } // expected-error {{expected ';' after struct}}
int gv1;
typedef struct _zend_function_entry { } // expected-error {{expected ';' after struct}} \
- // expected-warning {{declaration does not declare anything}}
+ // expected-warning {{typedef requires a name}}
int gv2;
static void buggy(int *x) { }
diff --git a/test/Sema/expr-address-of.c b/test/Sema/expr-address-of.c
index 2b8cfbf..32bd0df 100644
--- a/test/Sema/expr-address-of.c
+++ b/test/Sema/expr-address-of.c
@@ -90,8 +90,8 @@ void f5() {
lvalue we would need to give a warning. Note that gcc warns about
this as a register before it warns about it as an invalid
lvalue. */
- int *_dummy0 = &(int*) arr; // expected-error {{address expression must be an lvalue or a function designator}}
- int *_dummy1 = &(arr + 1); // expected-error {{address expression must be an lvalue or a function designator}}
+ int *_dummy0 = &(int*) arr; // expected-error {{cannot take the address of an rvalue}}
+ int *_dummy1 = &(arr + 1); // expected-error {{cannot take the address of an rvalue}}
}
void f6(register int x) {
@@ -109,12 +109,12 @@ char* f7() {
}
void f8() {
- void *dummy0 = &f8(); // expected-error {{address expression must be an lvalue or a function designator}}
+ void *dummy0 = &f8(); // expected-error {{cannot take the address of an rvalue of type 'void'}}
extern void v;
- void *dummy1 = &(1 ? v : f8()); // expected-error {{address expression must be an lvalue or a function designator}}
+ void *dummy1 = &(1 ? v : f8()); // expected-error {{cannot take the address of an rvalue of type 'void'}}
- void *dummy2 = &(f8(), v); // expected-error {{address expression must be an lvalue or a function designator}}
+ void *dummy2 = &(f8(), v); // expected-error {{cannot take the address of an rvalue of type 'void'}}
- void *dummy3 = &({ ; }); // expected-error {{address expression must be an lvalue or a function designator}}
+ void *dummy3 = &({ ; }); // expected-error {{cannot take the address of an rvalue of type 'void'}}
}
diff --git a/test/Sema/expr-comma-c99.c b/test/Sema/expr-comma-c99.c
index 6e97a4f..02886bf 100644
--- a/test/Sema/expr-comma-c99.c
+++ b/test/Sema/expr-comma-c99.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c99
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c99 -Wno-sizeof-array-decay
// expected-no-diagnostics
// rdar://6095180
diff --git a/test/Sema/expr-comma.c b/test/Sema/expr-comma.c
index 7902715..e2beafe 100644
--- a/test/Sema/expr-comma.c
+++ b/test/Sema/expr-comma.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c89
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c89 -Wno-sizeof-array-decay
// expected-no-diagnostics
// rdar://6095180
diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c
index df3e258..2fb17e4 100644
--- a/test/Sema/exprs.c
+++ b/test/Sema/exprs.c
@@ -94,7 +94,7 @@ int test8(void) {
struct f { int x : 4; float y[]; };
int test9(struct f *P) {
int R;
- R = __alignof(P->x); // expected-error {{invalid application of '__alignof' to bit-field}}
+ R = __alignof(P->x); // expected-error {{invalid application of 'alignof' to bit-field}}
R = __alignof(P->y); // ok.
R = sizeof(P->x); // expected-error {{invalid application of 'sizeof' to bit-field}}
return R;
diff --git a/test/Sema/extern-redecl.c b/test/Sema/extern-redecl.c
index c176725..9a085de 100644
--- a/test/Sema/extern-redecl.c
+++ b/test/Sema/extern-redecl.c
@@ -20,3 +20,16 @@ int PR10013(void) {
return PR10013_x; // expected-warning{{incompatible pointer to integer conversion}}
}
+static int test1_a[]; // expected-warning {{tentative array definition assumed to have one element}}
+extern int test1_a[];
+
+// rdar://13535367
+void test2declarer() { extern int test2_array[100]; }
+extern int test2_array[];
+int test2v = sizeof(test2_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
+
+void test3declarer() {
+ { extern int test3_array[100]; }
+ extern int test3_array[];
+ int x = sizeof(test3_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
+}
diff --git a/test/Sema/format-strings-fixit.c b/test/Sema/format-strings-fixit.c
index 15ac713..3127418 100644
--- a/test/Sema/format-strings-fixit.c
+++ b/test/Sema/format-strings-fixit.c
@@ -165,7 +165,7 @@ void test2() {
// Validate the fixes.
// CHECK: printf("%d", (int) 123);
// CHECK: printf("abc%s", "testing testing 123");
-// CHECK: printf("%lu", (long) -12);
+// CHECK: printf("%ld", (long) -12);
// CHECK: printf("%d", 123);
// CHECK: printf("%s\n", "x");
// CHECK: printf("%f\n", 1.23);
@@ -193,11 +193,11 @@ void test2() {
// CHECK: printf("%d", (my_int_type) 42);
// CHECK: printf("%s", "foo");
// CHECK: printf("%lo", (long) 42);
-// CHECK: printf("%lu", (long) 42);
+// CHECK: printf("%ld", (long) 42);
// CHECK: printf("%lx", (long) 42);
// CHECK: printf("%lX", (long) 42);
-// CHECK: printf("%li", (unsigned long) 42);
-// CHECK: printf("%ld", (unsigned long) 42);
+// CHECK: printf("%lu", (unsigned long) 42);
+// CHECK: printf("%lu", (unsigned long) 42);
// CHECK: printf("%LF", (long double) 42);
// CHECK: printf("%Le", (long double) 42);
// CHECK: printf("%LE", (long double) 42);
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index 8fb1218..ba12721 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -58,6 +58,9 @@ def"
printf("%*d", (unsigned) 1, 1); // no-warning
}
+// When calling a non-variadic format function (vprintf, vscanf, NSLogv, ...),
+// warn only if the format string argument is a parameter that is not itself
+// declared as a format string with compatible format.
__attribute__((__format__ (__printf__, 2, 4)))
void check_string_literal2( FILE* fp, const char* s, char *buf, ... ) {
char * b;
diff --git a/test/Sema/function-redecl.c b/test/Sema/function-redecl.c
index ff8e003..3ee8763 100644
--- a/test/Sema/function-redecl.c
+++ b/test/Sema/function-redecl.c
@@ -92,8 +92,6 @@ void outer_test3() {
int *(*fp)(int) = outer8; // expected-error{{use of undeclared identifier 'outer8'}}
}
-static float outer8(float); // okay
-
enum e { e1, e2 };
// GNU extension: prototypes and K&R function definitions
diff --git a/test/Sema/gnu89.c b/test/Sema/gnu89.c
index 189e6b0..1b7f10f 100644
--- a/test/Sema/gnu89.c
+++ b/test/Sema/gnu89.c
@@ -2,4 +2,4 @@
int f(int restrict);
-void main() {} // expected-warning {{return type of 'main' is not 'int'}}
+void main() {} // expected-warning {{return type of 'main' is not 'int'}} expected-note {{change return type to 'int'}}
diff --git a/test/Sema/i-c-e.c b/test/Sema/i-c-e.c
index e7b42c4..7749b6c 100644
--- a/test/Sema/i-c-e.c
+++ b/test/Sema/i-c-e.c
@@ -73,3 +73,5 @@ int illegaldiv4[0 / (1 / 0)]; // expected-error {{variable length array declarat
int chooseexpr[__builtin_choose_expr(1, 1, expr)];
int realop[(__real__ 4) == 4 ? 1 : -1];
int imagop[(__imag__ 4) == 0 ? 1 : -1];
+
+int *PR14729 = 0 ?: 1/0; // expected-error {{not a compile-time constant}} expected-warning 3{{}}
diff --git a/test/Sema/implicit-cast-dump.c b/test/Sema/implicit-cast-dump.c
new file mode 100644
index 0000000..87f15d0
--- /dev/null
+++ b/test/Sema/implicit-cast-dump.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -ast-dump %s | FileCheck %s
+
+void foo1(void*);
+void foo2(void* const);
+
+
+void bar() {
+ // CHECK: FunctionDecl {{.*}} <line:{{.*}}, line:{{.*}}> bar 'void ()'
+
+ foo1(0);
+ // CHECK: ImplicitCastExpr {{.*}} <col:{{.*}}> 'void *' <NullToPointer>
+
+ foo2(0);
+ // CHECK: ImplicitCastExpr {{.*}} <col:{{.*}}> 'void *' <NullToPointer>
+}
diff --git a/test/Sema/inline.c b/test/Sema/inline.c
index c27c00e..496e282 100644
--- a/test/Sema/inline.c
+++ b/test/Sema/inline.c
@@ -73,6 +73,16 @@ inline int useStaticAgain () { // expected-note 2 {{use 'static' to give inline
#pragma clang diagnostic pop
+inline void defineStaticVar() { // expected-note {{use 'static' to give inline function 'defineStaticVar' internal linkage}}
+ static const int x = 0; // ok
+ static int y = 0; // expected-warning {{non-constant static local variable in inline function may be different in different files}}
+}
+
+extern inline void defineStaticVarInExtern() {
+ static const int x = 0; // ok
+ static int y = 0; // ok
+}
+
#endif
diff --git a/test/Sema/invalid-cast.cpp b/test/Sema/invalid-cast.cpp
new file mode 100644
index 0000000..2183352
--- /dev/null
+++ b/test/Sema/invalid-cast.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// expected-no-diagnostics
+// <rdar://problem/13153516> - This previously triggered an assertion failure.
+template<class T>
+struct X {
+ T array;
+};
+
+int foo(X<int[1]> x0) {
+ return x0.array[17];
+}
diff --git a/test/Sema/invalid-decl.c b/test/Sema/invalid-decl.c
index b2c2aaf..950d51d 100644
--- a/test/Sema/invalid-decl.c
+++ b/test/Sema/invalid-decl.c
@@ -38,3 +38,11 @@ static void bar(hid_t p, char); // expected-error {{unknown type name 'hid_t'}}
void foo() {
(void)bar;
}
+
+void test2();
+void test2(undef); // expected-error {{a parameter list without types is only allowed in a function definition}}
+void test2() { }
+
+void test3();
+void test3; // expected-error {{incomplete type}}
+void test3() { }
diff --git a/test/Sema/memset-invalid-1.c b/test/Sema/memset-invalid-1.c
new file mode 100644
index 0000000..f4fba20
--- /dev/null
+++ b/test/Sema/memset-invalid-1.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+// rdar://13081751
+
+typedef __SIZE_TYPE__ size_t;
+void *memset(void*, int, size_t);
+
+typedef struct __incomplete *incomplete;
+
+void mt_query_for_domain(const char *domain)
+{
+ incomplete query = 0;
+ memset(query, 0, sizeof(query)); // expected-warning {{'memset' call operates on objects of type 'struct __incomplete' while the size is based on a different type 'incomplete'}} \
+ // expected-note {{did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?}}
+}
+
diff --git a/test/Sema/merge-decls.c b/test/Sema/merge-decls.c
index 1a84d33..29707d2 100644
--- a/test/Sema/merge-decls.c
+++ b/test/Sema/merge-decls.c
@@ -37,3 +37,57 @@ void foo6096412(void) {
int x = sizeof(i6096412);
}
+
+typedef int test1_IA[];
+typedef int test1_A10[10];
+static test1_A10 *test1_f(void);
+void test1_g(void)
+{
+ {
+ extern test1_IA *test1_f(void);
+ }
+ (void)sizeof(*test1_f());
+}
+
+typedef int test2_IA[];
+typedef int test2_A10[10];
+
+static test2_A10 *test2_f(void);
+static test2_IA *test2_f(void);
+
+void test2_g(void)
+{
+ (void)sizeof(*test2_f());
+}
+
+int (*test3_f())[10];
+int (*test3_f())[];
+int test3_k = sizeof(*test3_f());
+
+void test4_f(int);
+void test4_f(a)
+ char a;
+{
+ int v[sizeof(a) == 1 ? 1 : -1];
+}
+
+int test5_f(int (*)[10]);
+int test5_f(int (*x)[]) {
+ return sizeof(*x); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
+}
+
+void test6_f(int (*a)[11]);
+void test6_f(a)
+ int (*a)[];
+{}
+void test6_g() {
+ int arr[10];
+ test6_f(&arr); // expected-warning {{incompatible pointer types passing 'int (*)[10]' to parameter of type 'int (*)[11]}}
+}
+
+void test7_f(int (*)[10]);
+void test7_f(int (*)[]); // expected-note {{passing argument to parameter here}}
+void test7_g() {
+ int x[5];
+ test7_f(&x); // expected-warning {{incompatible pointer types passing 'int (*)[5]' to parameter of type 'int (*)[10]}}
+}
diff --git a/test/Sema/mips16_attr_allowed.c b/test/Sema/mips16_attr_allowed.c
new file mode 100644
index 0000000..21a94e7
--- /dev/null
+++ b/test/Sema/mips16_attr_allowed.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple mipsel-linux-gnu -fsyntax-only -verify %s
+
+void foo32();
+void foo16();
+void __attribute__((nomips16)) foo32();
+void __attribute__((mips16)) foo16();
+
+void __attribute__((nomips16)) foo32_();
+void __attribute__((mips16)) foo16_();
+void foo32_();
+void foo16_();
+
+void foo32__() __attribute__((nomips16));
+void foo32__() __attribute__((mips16));
+
+void foo32a() __attribute__((nomips16(xyz))) ; // expected-error {{attribute takes no arguments}}
+void __attribute__((mips16(xyz))) foo16a(); // expected-error {{attribute takes no arguments}}
+
+void __attribute__((nomips16(1, 2))) foo32b(); // expected-error {{attribute takes no arguments}}
+void __attribute__((mips16(1, 2))) foo16b(); // expected-error {{attribute takes no arguments}}
+
+
+__attribute((nomips16)) int a; // expected-error {{attribute only applies to functions}}
+
+__attribute((mips16)) int b; // expected-error {{attribute only applies to functions}}
+
+
diff --git a/test/Sema/mips16_attr_not_allowed.c b/test/Sema/mips16_attr_not_allowed.c
new file mode 100644
index 0000000..54f27d6
--- /dev/null
+++ b/test/Sema/mips16_attr_not_allowed.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+
+void __attribute__((nomips16)) foo32(); // expected-warning {{unknown attribute 'nomips16' ignored}}
+void __attribute__((mips16)) foo16(); // expected-warning {{unknown attribute 'mips16' ignored}}
+
+
+
diff --git a/test/Sema/ms-inline-asm-invalid-arch.c b/test/Sema/ms-inline-asm-invalid-arch.c
new file mode 100644
index 0000000..0870fcb
--- /dev/null
+++ b/test/Sema/ms-inline-asm-invalid-arch.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -triple powerpc64-unknown-linux-gnu -fasm-blocks -verify -fsyntax-only
+
+void f() {
+ __asm nop // expected-error {{Unsupported architecture 'powerpc64' for MS-style inline assembly}}
+}
diff --git a/test/Sema/ms-inline-asm.c b/test/Sema/ms-inline-asm.c
index f6a0fdc..1916d34 100644
--- a/test/Sema/ms-inline-asm.c
+++ b/test/Sema/ms-inline-asm.c
@@ -1,5 +1,5 @@
-// REQUIRES: x86-64-registered-target
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fms-extensions -fenable-experimental-ms-inline-asm -Wno-microsoft -verify -fsyntax-only
+// REQUIRES: disabled
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -Wno-microsoft -verify -fsyntax-only
void t1(void) {
__asm __asm // expected-error {{__asm used with no assembly instructions}}
@@ -21,15 +21,14 @@ void f() {
}
f();
__asm {
- mov eax, TYPE cat // expected-error {{Unable to lookup TYPE of expr!}}
+ mov eax, LENGTH bar // expected-error {{Unable to lookup expr!}}
}
f();
__asm {
- mov eax, SIZE foo // expected-error {{Unsupported directive!}}
+ mov eax, SIZE bar // expected-error {{Unable to lookup expr!}}
}
f();
__asm {
- mov eax, LENGTH foo // expected-error {{Unsupported directive!}}
+ mov eax, TYPE bar // expected-error {{Unable to lookup expr!}}
}
-
}
diff --git a/test/Sema/nowarn-documentation-property.m b/test/Sema/nowarn-documentation-property.m
new file mode 100644
index 0000000..af2b062
--- /dev/null
+++ b/test/Sema/nowarn-documentation-property.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-objc-root-class -Wdocumentation -verify %s
+// expected-no-diagnostics
+// rdar://13189938
+
+@interface NSPredicate
+/// The full predicate to be used for drawing objects from the store.
+/// It is an AND of the parent's `prefixPredicate` (e.g., the selection for
+/// volume number) and the `filterPredicate` (selection by matching the name).
+/// @return `nil` if there is no search string, and no prefix.
+
+@property(readonly) NSPredicate *andPredicate;
+/// The predicate that matches the string to be searched for. This
+/// @return `nil` if there is no search string.
+@property(readonly) NSPredicate *filterPredicate;
+@end
diff --git a/test/Sema/parentheses.cpp b/test/Sema/parentheses.cpp
index 8f5f246..da37dd3 100644
--- a/test/Sema/parentheses.cpp
+++ b/test/Sema/parentheses.cpp
@@ -57,3 +57,15 @@ void test(int a, int b, int c) {
Stream() >> b + c; // expected-warning {{operator '>>' has lower precedence than '+'; '+' will be evaluated first}} \
expected-note {{place parentheses around the '+' expression to silence this warning}}
}
+
+namespace PR15628 {
+ struct BlockInputIter {
+ void* operator++(int);
+ void* operator--(int);
+ };
+
+ void test(BlockInputIter i) {
+ (void)(i++ ? true : false); // no-warning
+ (void)(i-- ? true : false); // no-warning
+ }
+}
diff --git a/test/Sema/pid_t.c b/test/Sema/pid_t.c
new file mode 100644
index 0000000..7021e37
--- /dev/null
+++ b/test/Sema/pid_t.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple i586-pc-haiku -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-pc-linux -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#ifdef __HAIKU__
+typedef signed long pid_t;
+#else
+typedef signed int pid_t;
+#endif
+pid_t vfork(void); \ No newline at end of file
diff --git a/test/Sema/ppc-bool.c b/test/Sema/ppc-bool.c
new file mode 100644
index 0000000..2a4303e
--- /dev/null
+++ b/test/Sema/ppc-bool.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple powerpc-apple-macosx10.4.0 -verify -fsyntax-only %s
+// expected-no-diagnostics
+extern __typeof(+(_Bool)0) should_be_int;
+extern int should_be_int;
diff --git a/test/Sema/private-extern.c b/test/Sema/private-extern.c
index e480f3f..e9b67d5 100644
--- a/test/Sema/private-extern.c
+++ b/test/Sema/private-extern.c
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern -fmodules %s
static int g0; // expected-note{{previous definition}}
int g0; // expected-error{{non-static declaration of 'g0' follows static declaration}}
diff --git a/test/Sema/return-noreturn.c b/test/Sema/return-noreturn.c
index 448fce7..6d521eb 100644
--- a/test/Sema/return-noreturn.c
+++ b/test/Sema/return-noreturn.c
@@ -35,3 +35,8 @@ void __attribute__((noreturn))
test4() {
test2_positive();
}
+
+// Do not warn here.
+_Noreturn void test5() {
+ test2_positive();
+}
diff --git a/test/Sema/return.c b/test/Sema/return.c
index 77bd3f6..e231e81 100644
--- a/test/Sema/return.c
+++ b/test/Sema/return.c
@@ -244,6 +244,11 @@ const int ignored_c_quals(); // expected-warning{{'const' type qualifier on retu
const volatile int ignored_cv_quals(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
char* const volatile restrict ignored_cvr_quals(); // expected-warning{{'const volatile restrict' type qualifiers on return type have no effect}}
+typedef const int CI;
+CI ignored_quals_typedef();
+
+const CI ignored_quals_typedef_2(); // expected-warning{{'const' type qualifier}}
+
// Test that for switch(enum) that if the switch statement covers all the cases
// that we don't consider that for -Wreturn-type.
enum Cases { C1, C2, C3, C4 };
diff --git a/test/Sema/static-assert.c b/test/Sema/static-assert.c
index 13d7070..87fa050 100644
--- a/test/Sema/static-assert.c
+++ b/test/Sema/static-assert.c
@@ -1,6 +1,10 @@
-// RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -xc++ -std=c++11 -fsyntax-only -verify %s
-_Static_assert("foo", "string is nonzero"); // expected-error {{static_assert expression is not an integral constant expression}}
+_Static_assert("foo", "string is nonzero");
+#ifndef __cplusplus
+// expected-error@-2 {{static_assert expression is not an integral constant expression}}
+#endif
_Static_assert(1, "1 is nonzero");
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}}
@@ -9,3 +13,30 @@ void foo(void) {
_Static_assert(1, "1 is nonzero");
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}}
}
+
+_Static_assert(1, invalid); // expected-error {{expected string literal for diagnostic message in static_assert}}
+
+struct A {
+ int a;
+ _Static_assert(1, "1 is nonzero");
+ _Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}}
+};
+
+#ifdef __cplusplus
+#define ASSERT_IS_TYPE(T) __is_same(T, T)
+#else
+#define ASSERT_IS_TYPE(T) __builtin_types_compatible_p(T, T)
+#endif
+
+#define UNION(T1, T2) union { \
+ __typeof__(T1) one; \
+ __typeof__(T2) two; \
+ _Static_assert(ASSERT_IS_TYPE(T1), "T1 is not a type"); \
+ _Static_assert(ASSERT_IS_TYPE(T2), "T2 is not a type"); \
+ _Static_assert(sizeof(T1) == sizeof(T2), "type size mismatch"); \
+ }
+
+typedef UNION(unsigned, struct A) U1;
+UNION(char[2], short) u2 = { .one = { 'a', 'b' } };
+typedef UNION(char, short) U3; // expected-error {{static_assert failed "type size mismatch"}}
+typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}}
diff --git a/test/Sema/struct-decl.c b/test/Sema/struct-decl.c
index 6070e87..819e856 100644
--- a/test/Sema/struct-decl.c
+++ b/test/Sema/struct-decl.c
@@ -54,6 +54,6 @@ static struct test1 { // expected-warning {{'static' ignored on this declaration
const struct test2 { // expected-warning {{'const' ignored on this declaration}}
int x;
};
-inline struct test3 { // expected-warning {{'inline' ignored on this declaration}}
+inline struct test3 { // expected-error {{'inline' can only appear on functions}}
int x;
};
diff --git a/test/Sema/switch-1.c b/test/Sema/switch-1.c
new file mode 100644
index 0000000..ce1e7dc
--- /dev/null
+++ b/test/Sema/switch-1.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
+// rdar://11577384
+// rdar://13423975
+
+int f(int i) {
+ switch (i) {
+ case 2147483647 + 2: // expected-warning {{overflow in expression; result is -2147483647 with type 'int'}}
+ return 1;
+ case 9223372036854775807L * 4: // expected-warning {{overflow in expression; result is -4 with type 'long'}}
+ return 2;
+ case (123456 *789012) + 1: // expected-warning {{overflow in expression; result is -1375982336 with type 'int'}}
+ return 3;
+ case (2147483647*4)/4: // expected-warning {{overflow in expression; result is -4 with type 'int'}}
+ case (2147483647*4)%4: // expected-warning {{overflow in expression; result is -4 with type 'int'}}
+ return 4;
+ case 2147483647:
+ return 0;
+ }
+ return (i, 65537) * 65537; // expected-warning {{overflow in expression; result is 131073 with type 'int'}} \
+ // expected-warning {{expression result unused}}
+}
diff --git a/test/Sema/types.c b/test/Sema/types.c
index 6ae1a92..d0637cc 100644
--- a/test/Sema/types.c
+++ b/test/Sema/types.c
@@ -53,7 +53,7 @@ _Decimal32 x; // expected-error {{GNU decimal type extension not supported}}
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}}
+ char c = (char __attribute__((align(8)))) i; // expected-warning {{'align' attribute ignored when parsing type}}
}
// http://llvm.org/PR11082
diff --git a/test/Sema/ucn-cstring.c b/test/Sema/ucn-cstring.c
index 5d3e85d..382e555 100644
--- a/test/Sema/ucn-cstring.c
+++ b/test/Sema/ucn-cstring.c
@@ -8,7 +8,7 @@ int main(void) {
printf("%s (%zd)\n", "hello \u2192 \u2603 \u2190 world", sizeof("hello \u2192 \u2603 \u2190 world"));
printf("%s (%zd)\n", "\U00010400\U0001D12B", sizeof("\U00010400\U0001D12B"));
// Some error conditions...
- printf("%s\n", "\U"); // expected-error{{\u used with no following hex digits}}
+ printf("%s\n", "\U"); // expected-error{{\U used with no following hex digits}}
printf("%s\n", "\U00"); // expected-error{{incomplete universal character name}}
printf("%s\n", "\U0001"); // expected-error{{incomplete universal character name}}
printf("%s\n", "\u0001"); // expected-error{{universal character name refers to a control character}}
diff --git a/test/Sema/ucn-identifiers.c b/test/Sema/ucn-identifiers.c
new file mode 100644
index 0000000..6b26365
--- /dev/null
+++ b/test/Sema/ucn-identifiers.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
+// RUN: %clang_cc1 %s -verify -fsyntax-only -x c++ -pedantic
+
+// This file contains UTF-8; please do not fix!
+
+
+extern void \u00FCber(int);
+extern void \U000000FCber(int); // redeclaration, no warning
+#ifdef __cplusplus
+// expected-note@-2 + {{candidate function not viable}}
+#else
+// expected-note@-4 + {{declared here}}
+#endif
+
+void goodCalls() {
+ \u00FCber(0);
+ \u00fcber(1);
+ über(2);
+ \U000000FCber(3);
+}
+
+void badCalls() {
+ \u00FCber(0.5); // expected-warning{{implicit conversion from 'double' to 'int'}}
+ \u00fcber = 0; // expected-error{{non-object type 'void (int)' is not assignable}}
+
+ über(1, 2);
+ \U000000FCber();
+#ifdef __cplusplus
+ // expected-error@-3 {{no matching function}}
+ // expected-error@-3 {{no matching function}}
+#else
+ // expected-error@-6 {{too many arguments to function call, expected 1, have 2}}
+ // expected-error@-6 {{too few arguments to function call, expected 1, have 0}}
+#endif
+}
diff --git a/test/Sema/uninit-det-order.c b/test/Sema/uninit-det-order.c
new file mode 100644
index 0000000..041c4b0
--- /dev/null
+++ b/test/Sema/uninit-det-order.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -Wuninitialized -fsyntax-only %s 2>&1 | FileCheck %s
+
+void pr14901(int a) {
+ int b, c;
+ a = b;
+ a = c;
+}
+
+// CHECK: 5:8: warning: variable 'b' is uninitialized when used here
+// CHECK: 4:9: note: initialize the variable 'b' to silence this warning
+// CHECK: 6:8: warning: variable 'c' is uninitialized when used here
+// CHECK: 4:12: note: initialize the variable 'c' to silence this warning
+
diff --git a/test/Sema/unused-expr-system-header.c b/test/Sema/unused-expr-system-header.c
index dcc8918..68c7e99 100644
--- a/test/Sema/unused-expr-system-header.c
+++ b/test/Sema/unused-expr-system-header.c
@@ -3,8 +3,10 @@
void f(int i1, int i2) {
POSSIBLY_BAD_MACRO(5);
STATEMENT_EXPR_MACRO(5);
- COMMA_MACRO_1(i1 == i2, f(i1, i2)); // expected-warning {{expression result unused}}
+ COMMA_MACRO_1(i1 == i2, f(i1, i2)); // expected-warning {{comparison result unused}} \
+ // expected-note {{equality comparison}}
COMMA_MACRO_2(i1 == i2, f(i1, i2));
- COMMA_MACRO_3(i1 == i2, f(i1, i2)); // expected-warning {{expression result unused}}
+ COMMA_MACRO_3(i1 == i2, f(i1, i2)); // expected-warning {{comparison result unused}} \
+ // expected-note {{equality comparison}}
COMMA_MACRO_4(i1 == i2, f(i1, i2));
}
diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c
index aa81febd..ea08631 100644
--- a/test/Sema/unused-expr.c
+++ b/test/Sema/unused-expr.c
@@ -123,13 +123,36 @@ void f(int i, ...) {
// PR8371
int fn5() __attribute__ ((__const));
-// OpenSSL has some macros like this; we shouldn't warn on the cast.
+// Don't warn for unused expressions in macro bodies; however, do warn for
+// unused expressions in macro arguments. Macros below are reduced from code
+// found in the wild.
+#define NOP(a) (a)
#define M1(a, b) (long)foo((a), (b))
-// But, we should still warn on other subexpressions of casts in macros.
#define M2 (long)0;
+#define M3(a) (t3(a), fn2())
+#define M4(a, b) (foo((a), (b)) ? 0 : t3(a), 1)
+#define M5(a, b) (foo((a), (b)), 1)
+#define M6() fn1()
+#define M7() fn2()
void t11(int i, int j) {
M1(i, j); // no warning
- M2; // expected-warning {{expression result unused}}
+ NOP((long)foo(i, j)); // expected-warning {{expression result unused}}
+ M2; // no warning
+ NOP((long)0); // expected-warning {{expression result unused}}
+ M3(i); // no warning
+ NOP((t3(i), fn2())); // expected-warning {{ignoring return value}}
+ M4(i, j); // no warning
+ NOP((foo(i, j) ? 0 : t3(i), 1)); // expected-warning {{expression result unused}}
+ M5(i, j); // no warning
+ NOP((foo(i, j), 1)); // expected-warning {{expression result unused}}
+ M6(); // expected-warning {{ignoring return value}}
+ M7(); // no warning
}
+#undef NOP
#undef M1
#undef M2
+#undef M3
+#undef M4
+#undef M5
+#undef M6
+#undef M7
diff --git a/test/Sema/varargs.c b/test/Sema/varargs.c
index 07081ed..663d3d5 100644
--- a/test/Sema/varargs.c
+++ b/test/Sema/varargs.c
@@ -57,7 +57,7 @@ void f7(int a, ...) {
__builtin_va_start(ap, a);
// FIXME: This error message is sub-par.
__builtin_va_arg(ap, int) = 1; // expected-error {{expression is not assignable}}
- int *x = &__builtin_va_arg(ap, int); // expected-error {{address expression must be an lvalue or a function designator}}
+ int *x = &__builtin_va_arg(ap, int); // expected-error {{cannot take the address of an rvalue}}
__builtin_va_end(ap);
}
diff --git a/test/Sema/varargs_unreachable.c b/test/Sema/varargs_unreachable.c
new file mode 100644
index 0000000..866bd8f
--- /dev/null
+++ b/test/Sema/varargs_unreachable.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-apple-darwin9
+// expected-no-diagnostics
+
+// From <rdar://problem/12322000>. Do not warn about undefined behavior of parameter
+// argument types in unreachable code in a macro.
+#define VA_ARG_RDAR12322000(Marker, TYPE) ((sizeof (TYPE) < sizeof (UINTN_RDAR12322000)) ? (TYPE)(__builtin_va_arg (Marker, UINTN_RDAR12322000)) : (TYPE)(__builtin_va_arg (Marker, TYPE)))
+
+// 64-bit system
+typedef unsigned long long UINTN_RDAR12322000;
+
+int test_VA_ARG_RDAR12322000 (__builtin_va_list Marker)
+{
+ return VA_ARG_RDAR12322000 (Marker, short); // no-warning
+} \ No newline at end of file
diff --git a/test/Sema/variadic-promotion.c b/test/Sema/variadic-promotion.c
new file mode 100644
index 0000000..b248774
--- /dev/null
+++ b/test/Sema/variadic-promotion.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -ast-dump %s | FileCheck %s
+
+void variadic(int, ...);
+
+void test_floating_promotion(__fp16 *f16, float f32, double f64) {
+ variadic(3, *f16, f32, f64);
+
+// CHECK: ImplicitCastExpr {{.*}} 'double' <FloatingCast>
+// CHECK-NEXT: 'half'
+
+// CHECK: ImplicitCastExpr {{.*}} 'double' <FloatingCast>
+// CHECK-NEXT: 'float'
+}
diff --git a/test/Sema/warn-documentation-crlf.c b/test/Sema/warn-documentation-crlf.c
new file mode 100644
index 0000000..99c0714
--- /dev/null
+++ b/test/Sema/warn-documentation-crlf.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdocumentation %s
+// The run line does not have '-verify' because we were crashing while printing
+// the diagnostic.
+
+// This file has DOS-style line endings (CR LF). Please don't change it to
+// Unix-style LF!
+
+// PR14591. Check that we don't crash on this.
+/**
+ * @param abc
+ */
+void nocrash1(int qwerty);
+
diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp
index 5678fd9..0132ef2 100644
--- a/test/Sema/warn-documentation.cpp
+++ b/test/Sema/warn-documentation.cpp
@@ -303,6 +303,11 @@ typedef int (*test_param27)(int aaa);
/// \param aaa Meow.
typedef test_param27 test_param28;
+// rdar://13066276
+// expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
+/// @param aaa Meow.
+typedef unsigned int test_param29;
+
// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
/// \tparam T Aaa
@@ -377,6 +382,35 @@ using test_tparam14 = test_tparam13<T, int>;
template<typename T>
using test_tparam15 = test_tparam13<T, int>;
+// ----
+
+/// \tparam T Aaa
+template<typename T>
+class test_tparam16 { };
+
+typedef test_tparam16<int> test_tparam17;
+typedef test_tparam16<double> test_tparam18;
+
+// ----
+
+template<typename T>
+class test_tparam19;
+
+typedef test_tparam19<int> test_tparam20;
+typedef test_tparam19<double> test_tparam21;
+
+/// \tparam T Aaa
+template<typename T>
+class test_tparam19 { };
+
+// ----
+
+// expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}}
+/// @tparam T Aaa
+int test_tparam22;
+
+// ----
+
/// Aaa
/// \deprecated Bbb
@@ -415,6 +449,14 @@ template<typename T>
void test_deprecated_7(T aaa);
+// rdar://12397511
+// expected-note@+2 {{previous command '\headerfile' here}}
+// expected-warning@+2 {{duplicated command '\headerfile'}}
+/// \headerfile ""
+/// \headerfile foo.h
+int test__headerfile_1(int a);
+
+
/// \invariant aaa
void test_invariant_1(int a);
@@ -501,6 +543,23 @@ enum test_returns_wrong_decl_8 {
/// \returns Aaa
namespace test_returns_wrong_decl_10 { };
+// rdar://13066276
+// expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
+/// @returns Aaa
+typedef unsigned int test_returns_wrong_decl_11;
+
+// rdar://13094352
+// expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}
+/*! @function test_function
+*/
+typedef unsigned int Base64Flags;
+unsigned test_function(Base64Flags inFlags);
+
+// expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}}
+/*! @callback test_callback
+*/
+typedef unsigned int BaseFlags;
+unsigned (*test_callback)(BaseFlags inFlags);
// expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
/// \endverbatim
@@ -836,3 +895,58 @@ typedef const struct test_nocrash7 * test_nocrash8;
/// aaa \unknown aaa \unknown aaa
int test_nocrash9;
+
+// We used to crash on this. PR15068
+
+// expected-warning@+2 {{empty paragraph passed to '@param' command}}
+// expected-warning@+2 {{empty paragraph passed to '@param' command}}
+///@param x
+///@param y
+int test_nocrash10(int x, int y);
+
+// expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}}
+// expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}}
+///@param x
+///@param y
+int test_nocrash11();
+
+// expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}}
+// expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}}
+/**
+@param x
+@param y
+**/
+int test_nocrash12();
+
+// expected-warning@+2 {{empty paragraph passed to '@param' command}}
+// expected-warning@+1 {{empty paragraph passed to '@param' command}}
+///@param x@param y
+int test_nocrash13(int x, int y);
+
+// rdar://12379114
+// expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}}
+/*!
+ @union U This is new
+*/
+struct U { int iS; };
+
+/*!
+ @union U1
+*/
+union U1 {int i; };
+
+// expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}
+/*!
+ @struct S2
+*/
+union S2 {};
+
+/*!
+ @class C1
+*/
+class C1;
+
+/*!
+ @struct S3;
+*/
+class S3;
diff --git a/test/Sema/warn-documentation.m b/test/Sema/warn-documentation.m
index 8a894dc..1e3acf1 100644
--- a/test/Sema/warn-documentation.m
+++ b/test/Sema/warn-documentation.m
@@ -97,3 +97,77 @@ int b;
/// \returns aaa.
typedef int (^test_param1)(int aaa, int ccc);
+// rdar://13094352
+// expected-warning@+2 {{'@method' command should be used in a comment attached to an Objective-C method declaration}}
+@interface I
+/*! @method Base64EncodeEx
+*/
+typedef id ID;
+- (unsigned) Base64EncodeEx : (ID)Arg;
+@end
+
+// rdar://12379114
+// expected-warning@+5 {{'@interface' command should not be used in a comment attached to a non-interface declaration}}
+// expected-warning@+5 {{'@classdesign' command should not be used in a comment attached to a non-container declaration}}
+// expected-warning@+5 {{'@coclass' command should not be used in a comment attached to a non-container declaration}}
+@interface NSObject @end
+/*!
+@interface IOCommandGate
+@classdesign Multiple paragraphs go here.
+@coclass myCoClass
+*/
+
+typedef id OBJ;
+@interface IOCommandGate : NSObject {
+ OBJ iv;
+}
+@end
+
+// rdar://12379114
+// expected-warning@+4 {{'@methodgroup' command should be used in a comment attached to an Objective-C method declaration}}
+// expected-warning@+6 {{'@method' command should be used in a comment attached to an Objective-C method declaratio}}
+@interface rdar12379114
+/*!
+ @methodgroup Creating a request
+*/
+/*!
+ @method initWithTimeout is the 2nd method
+*/
+typedef unsigned int NSTimeInterval;
+- (id)initWithTimeout:(NSTimeInterval)timeout;
+@end
+
+// expected-warning@+2 {{'@protocol' command should not be used in a comment attached to a non-protocol declaration}}
+/*!
+@protocol PROTO
+*/
+struct S;
+
+/*!
+ @interface NSArray This is an array
+*/
+@class NSArray;
+@interface NSArray @end
+
+/*!
+@interface NSMutableArray
+@super NSArray
+*/
+@interface NSMutableArray : NSArray @end
+
+/*!
+ @protocol MyProto
+*/
+@protocol MyProto @end
+
+// expected-warning@+2 {{'@protocol' command should not be used in a comment attached to a non-protocol declaration}}
+/*!
+ @protocol MyProto
+*/
+@interface INTF <MyProto> @end
+
+// expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}
+/*!
+ @struct S1 THIS IS IT
+*/
+@interface S1 @end
diff --git a/test/Sema/warn-duplicate-enum.c b/test/Sema/warn-duplicate-enum.c
new file mode 100644
index 0000000..239f6f1
--- /dev/null
+++ b/test/Sema/warn-duplicate-enum.c
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -Wduplicate-enum
+// RUN: %clang_cc1 %s -x c++ -fsyntax-only -verify -Wduplicate-enum
+enum A {
+ A1 = 0, // expected-note {{element A1 also has value 0}}
+ A2 = -1,
+ A3, // expected-warning {{element A3 has been implicitly assigned 0 which another element has been assigned}}
+ A4};
+
+enum B {
+ B1 = -1, // expected-note {{element B1 also has value -1}}
+ B2, // expected-warning {{element B2 has been implicitly assigned 0 which another element has been assigned}}
+ B3,
+ B4 = -2,
+ B5, // expected-warning {{element B5 has been implicitly assigned -1 which another element has been assigned}}
+ B6 // expected-note {{element B6 also has value 0}}
+};
+
+enum C { C1, C2 = -1, C3 }; // expected-warning{{element C1 has been implicitly assigned 0 which another element has been assigned}} \
+ // expected-note {{element C3 also has value 0}}
+
+enum D {
+ D1,
+ D2,
+ D3, // expected-warning{{element D3 has been implicitly assigned 2 which another element has been assigned}}
+ D4 = D2, // no warning
+ D5 = 2 // expected-note {{element D5 also has value 2}}
+};
+
+enum E {
+ E1,
+ E2 = E1,
+ E3 = E2
+};
+
+enum F {
+ F1,
+ F2,
+ FCount,
+ FMax = FCount - 1
+};
+
+enum G {
+ G1,
+ G2,
+ GMax = G2,
+ GCount = GMax + 1
+};
+
+enum {
+ H1 = 0,
+ H2 = -1,
+ H3,
+ H4};
+
+enum {
+ I1 = -1,
+ I2,
+ I3,
+ I4 = -2,
+ I5,
+ I6
+};
+
+enum { J1, J2 = -1, J3 };
+
+enum {
+ K1,
+ K2,
+ K3,
+ K4 = K2,
+ K5 = 2
+};
+
+enum {
+ L1,
+ L2 = L1,
+ L3 = L2
+};
+
+enum {
+ M1,
+ M2,
+ MCount,
+ MMax = MCount - 1
+};
+
+enum {
+ N1,
+ N2,
+ NMax = N2,
+ NCount = NMax + 1
+};
diff --git a/test/Sema/warn-main-return-type.c b/test/Sema/warn-main-return-type.c
new file mode 100644
index 0000000..bd7c59f
--- /dev/null
+++ b/test/Sema/warn-main-return-type.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
+
+// expected-note@+1 5{{previous definition is here}}
+int main() {
+ return 0;
+}
+
+// expected-error@+3 {{conflicting types for 'main}}
+// expected-warning@+2 {{return type of 'main' is not 'int'}}
+// expected-note@+1 {{change return type to 'int'}}
+void main() {
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:5}:"int"
+}
+
+// expected-error@+3 {{conflicting types for 'main}}
+// expected-warning@+2 {{return type of 'main' is not 'int'}}
+// expected-note@+1 {{change return type to 'int'}}
+double main() {
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:7}:"int"
+ return 0.0;
+}
+
+// Currently we suggest to replace only 'float' here because we don't store
+// enough source locations.
+//
+// expected-error@+3 {{conflicting types for 'main}}
+// expected-warning@+2 {{return type of 'main' is not 'int'}}
+// expected-note@+1 {{change return type to 'int'}}
+const float main() {
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:12}:"int"
+ return 0.0f;
+}
+
+typedef void *(*fptr)(int a);
+
+// expected-error@+2 {{conflicting types for 'main}}
+// expected-warning@+1 {{return type of 'main' is not 'int'}}
+fptr main() {
+ return (fptr) 0;
+}
+
+// expected-error@+2 {{conflicting types for 'main}}
+// expected-warning@+1 {{return type of 'main' is not 'int'}}
+void *(*main())(int a) {
+ return (fptr) 0;
+}
+
diff --git a/test/Sema/warn-main.c b/test/Sema/warn-main.c
new file mode 100644
index 0000000..8a4eafc
--- /dev/null
+++ b/test/Sema/warn-main.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
+
+// expected-note@+1 2{{previous definition is here}}
+int main() {
+ return 0;
+}
+
+// expected-error@+2 {{static declaration of 'main' follows non-static declaration}}
+// expected-warning@+1 {{'main' should not be declared static}}
+static int main() {
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:8}:""
+ return 0;
+}
+
+// expected-error@+3 {{redefinition of 'main'}}
+// expected-error@+2 {{'main' is not allowed to be declared inline}}
+// expected-note@+1 {{previous definition is here}}
+inline int main() {
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:8}:""
+ return 0;
+}
+
+// expected-warning@+6 {{function 'main' declared 'noreturn' should not return}}
+// expected-error@+3 {{redefinition of 'main'}}
+// expected-warning@+2 {{'main' is not allowed to be declared _Noreturn}}
+// expected-note@+1 {{remove '_Noreturn'}}
+_Noreturn int main() {
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:11}:""
+ return 0;
+}
+
diff --git a/test/Sema/warn-missing-prototypes.c b/test/Sema/warn-missing-prototypes.c
index bfd1459..10018b6 100644
--- a/test/Sema/warn-missing-prototypes.c
+++ b/test/Sema/warn-missing-prototypes.c
@@ -1,4 +1,5 @@
-// RUN: %clang -Wmissing-prototypes -fsyntax-only -Xclang -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wmissing-prototypes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wmissing-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
int f();
@@ -35,3 +36,8 @@ int f2(int x) { return x; }
// rdar://6759522
int main(void) { return 0; }
+
+void not_a_prototype_test(); // expected-note{{this declaration is not a prototype; add 'void' to make it a prototype for a zero-parameter function}}
+void not_a_prototype_test() { } // expected-warning{{no previous prototype for function 'not_a_prototype_test'}}
+
+// CHECK: fix-it:"{{.*}}":{40:27-40:27}:"void"
diff --git a/test/Sema/warn-sizeof-array-decay.c b/test/Sema/warn-sizeof-array-decay.c
new file mode 100644
index 0000000..cc3ee1d
--- /dev/null
+++ b/test/Sema/warn-sizeof-array-decay.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f(int x) {
+ char foo[10];
+ int bar[20];
+ char qux[30];
+
+ (void)sizeof(bar + 10); // expected-warning{{sizeof on pointer operation will return size of 'int *' instead of 'int [20]'}}
+ (void)sizeof(foo - 20); // expected-warning{{sizeof on pointer operation will return size of 'char *' instead of 'char [10]'}}
+ (void)sizeof(bar - x); // expected-warning{{sizeof on pointer operation will return size of 'int *' instead of 'int [20]'}}
+ (void)sizeof(foo + x); // expected-warning{{sizeof on pointer operation will return size of 'char *' instead of 'char [10]'}}
+
+ // This is ptrdiff_t.
+ (void)sizeof(foo - qux); // no-warning
+
+ (void)sizeof(foo, x); // no-warning
+ (void)sizeof(x, foo); // expected-warning{{sizeof on pointer operation will return size of 'char *' instead of 'char [10]'}}
+}
diff --git a/test/Sema/warn-type-safety-mpi-hdf5.c b/test/Sema/warn-type-safety-mpi-hdf5.c
index 8c50cb2..1a9c5b0 100644
--- a/test/Sema/warn-type-safety-mpi-hdf5.c
+++ b/test/Sema/warn-type-safety-mpi-hdf5.c
@@ -201,10 +201,14 @@ MPI_Datatype my_s1_datatype __attribute__(( type_tag_for_datatype(mpi,struct S1)
struct S2 { int a; int b; };
MPI_Datatype my_s2_datatype __attribute__(( type_tag_for_datatype(mpi,struct S2) ));
+enum E1 { Foo };
+MPI_Datatype my_e1_datatype __attribute__(( type_tag_for_datatype(mpi,enum E1) ));
+
void test_user_types(int *int_buf,
long *long_buf,
struct S1 *s1_buf,
- struct S2 *s2_buf)
+ struct S2 *s2_buf,
+ enum E1 *e1_buf)
{
MPI_Send(int_buf, 1, my_int_datatype); // no-warning
MPI_Send(long_buf, 1, my_int_datatype); // expected-warning {{argument type 'long *' doesn't match specified 'mpi' type tag that requires 'int *'}}
@@ -214,6 +218,10 @@ void test_user_types(int *int_buf,
MPI_Send(long_buf, 1, my_s1_datatype); // expected-warning {{argument type 'long *' doesn't match specified 'mpi' type tag that requires 'struct S1 *'}}
MPI_Send(s1_buf, 1, MPI_INT); // expected-warning {{argument type 'struct S1 *' doesn't match specified 'mpi' type tag that requires 'int *'}}
+
+ MPI_Send(e1_buf, 1, my_e1_datatype); // no-warning
+ MPI_Send(e1_buf, 1, MPI_INT); // expected-warning {{argument type 'enum E1 *' doesn't match specified 'mpi' type tag that requires 'int *'}}
+ MPI_Send(int_buf, 1, my_e1_datatype); // expected-warning {{argument type 'int *' doesn't match specified 'mpi' type tag that requires 'enum E1 *'}}
}
MPI_Datatype my_unknown_datatype;
diff --git a/test/Sema/warn-unreachable.c b/test/Sema/warn-unreachable.c
index 2fbe1c7..fd74b5c 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}}
}
}
}
diff --git a/test/Sema/warn-unused-variables-werror.c b/test/Sema/warn-unused-variables-werror.c
new file mode 100644
index 0000000..ceaff1b
--- /dev/null
+++ b/test/Sema/warn-unused-variables-werror.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Werror -verify %s
+
+void f() {
+ int i; // expected-error{{unused}}
+ int j; // expected-error{{unused}}
+}
diff --git a/test/Sema/warn-vla.c b/test/Sema/warn-vla.c
new file mode 100644
index 0000000..01fe451
--- /dev/null
+++ b/test/Sema/warn-vla.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify -Wvla %s
+// RUN: %clang_cc1 -std=c89 -fsyntax-only -verify -Wvla %s
+
+void test1(int n) {
+ int v[n]; // expected-warning {{variable length array used}}
+}
+
+void test2(int n, int v[n]) { // expected-warning {{variable length array used}}
+}
+
+void test3(int n, int v[n]); // expected-warning {{variable length array used}}
+
diff --git a/test/Sema/wchar.c b/test/Sema/wchar.c
index 8708aa0..816245f 100644
--- a/test/Sema/wchar.c
+++ b/test/Sema/wchar.c
@@ -6,7 +6,7 @@ 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
-#elif defined(__arm)
+#elif defined(__arm) || defined(__aarch64__)
#define WCHAR_T_TYPE unsigned int
#elif defined(__sun) || defined(__AuroraUX__)
#define WCHAR_T_TYPE long
OpenPOWER on IntegriCloud