aboutsummaryrefslogtreecommitdiff
path: root/test/Sema
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema')
-rw-r--r--test/Sema/MicrosoftCompatibility.cpp4
-rw-r--r--test/Sema/anonymous-struct-union.c2
-rw-r--r--test/Sema/arm-neon-types.c12
-rw-r--r--test/Sema/array-init.c2
-rw-r--r--test/Sema/asm.c23
-rw-r--r--test/Sema/atomic-expr.c47
-rw-r--r--test/Sema/atomic-ops.c3
-rw-r--r--test/Sema/bitfield.c15
-rw-r--r--test/Sema/block-return.c11
-rw-r--r--test/Sema/builtins-aarch64.c16
-rw-r--r--test/Sema/captured-statements.c78
-rw-r--r--test/Sema/compare.c16
-rw-r--r--test/Sema/crash-invalid-array.c7
-rw-r--r--test/Sema/decl-invalid.c4
-rw-r--r--test/Sema/declspec.c2
-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.c40
-rw-r--r--test/Sema/function-redecl.c4
-rw-r--r--test/Sema/function.c11
-rw-r--r--test/Sema/inline.c10
-rw-r--r--test/Sema/no-documentation-warn-tagdecl-specifier.c85
-rw-r--r--test/Sema/parentheses.c89
-rw-r--r--test/Sema/parentheses.cpp78
-rw-r--r--test/Sema/pragma-arc-cf-code-audited.c2
-rw-r--r--test/Sema/private-extern.c1
-rw-r--r--test/Sema/return.c13
-rw-r--r--test/Sema/static-assert.c33
-rw-r--r--test/Sema/struct-decl.c2
-rw-r--r--test/Sema/switch-1.c4
-rw-r--r--test/Sema/thread-specifier.c108
-rw-r--r--test/Sema/var-redecl.c4
-rw-r--r--test/Sema/warn-documentation.cpp2
-rw-r--r--test/Sema/warn-documentation.m15
-rw-r--r--test/Sema/warn-duplicate-enum.c9
-rw-r--r--test/Sema/warn-sizeof-array-decay.c18
-rw-r--r--test/Sema/warn-unused-variables-werror.c6
38 files changed, 711 insertions, 71 deletions
diff --git a/test/Sema/MicrosoftCompatibility.cpp b/test/Sema/MicrosoftCompatibility.cpp
new file mode 100644
index 0000000000..15c25586c4
--- /dev/null
+++ b/test/Sema/MicrosoftCompatibility.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility
+
+// PR15845
+int foo(xxx); // expected-error{{unknown type name}}
diff --git a/test/Sema/anonymous-struct-union.c b/test/Sema/anonymous-struct-union.c
index e0822901b0..35d3175416 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/arm-neon-types.c b/test/Sema/arm-neon-types.c
index 1a170dbb7e..a49de12d44 100644
--- a/test/Sema/arm-neon-types.c
+++ b/test/Sema/arm-neon-types.c
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversion -ffreestanding -verify %s
+#ifndef INCLUDE
#include <arm_neon.h>
@@ -33,3 +34,14 @@ int16x8_t test5(int *p) {
void test6(float *p, int32x2_t v) {
return vst1_s32(p, v); // expected-warning {{incompatible pointer types}}
}
+
+#define INCLUDE
+#include "arm-neon-types.c"
+#else
+
+// Make sure we don't get a warning about using a static function in an
+// extern inline function from a header.
+extern inline uint8x8_t test7(uint8x8_t a, uint8x8_t b) {
+ return vadd_u8(a, b);
+}
+#endif
diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c
index b3cae60495..f92852f341 100644
--- a/test/Sema/array-init.c
+++ b/test/Sema/array-init.c
@@ -187,7 +187,7 @@ char r6[sizeof r5 == 15 ? 1 : -1];
const char r7[] = "zxcv";
char r8[5] = "5char";
char r9[5] = "6chars"; //expected-warning{{initializer-string for char array is too long}}
-
+unsigned char r10[] = __extension__ (_Generic(0, int: (__extension__ "foo" )));
int r11[0] = {}; //expected-warning{{zero size arrays are an extension}} expected-warning{{use of GNU empty initializer extension}}
// Some struct tests
diff --git a/test/Sema/asm.c b/test/Sema/asm.c
index 155d736b99..c81f16a387 100644
--- a/test/Sema/asm.c
+++ b/test/Sema/asm.c
@@ -123,3 +123,26 @@ 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'}}
+}
+
+// PR15759.
+double test15() {
+ double ret = 0;
+ __asm("0.0":"="(ret)); // expected-error {{invalid output constraint '=' in asm}}
+ __asm("0.0":"=&"(ret)); // expected-error {{invalid output constraint '=&' in asm}}
+ __asm("0.0":"+?"(ret)); // expected-error {{invalid output constraint '+?' in asm}}
+ __asm("0.0":"+!"(ret)); // expected-error {{invalid output constraint '+!' in asm}}
+ __asm("0.0":"+#"(ret)); // expected-error {{invalid output constraint '+#' in asm}}
+ __asm("0.0":"+*"(ret)); // expected-error {{invalid output constraint '+*' in asm}}
+ __asm("0.0":"=%"(ret)); // expected-error {{invalid output constraint '=%' in asm}}
+ __asm("0.0":"=,="(ret)); // expected-error {{invalid output constraint '=,=' in asm}}
+ __asm("0.0":"=,g"(ret)); // no-error
+ __asm("0.0":"=g"(ret)); // no-error
+ return ret;
+}
diff --git a/test/Sema/atomic-expr.c b/test/Sema/atomic-expr.c
new file mode 100644
index 0000000000..ecc04c4c68
--- /dev/null
+++ b/test/Sema/atomic-expr.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// expected-no-diagnostics
+
+_Atomic(unsigned int) data1;
+int _Atomic data2;
+
+// Shift operations
+
+int func_01 (int x) {
+ return data1 << x;
+}
+
+int func_02 (int x) {
+ return x << data1;
+}
+
+int func_03 (int x) {
+ return data2 << x;
+}
+
+int func_04 (int x) {
+ return x << data2;
+}
+
+int func_05 () {
+ return data2 << data1;
+}
+
+int func_06 () {
+ return data1 << data2;
+}
+
+void func_07 (int x) {
+ data1 <<= x;
+}
+
+void func_08 (int x) {
+ data2 <<= x;
+}
+
+void func_09 (int* xp) {
+ *xp <<= data1;
+}
+
+void func_10 (int* xp) {
+ *xp <<= data2;
+}
diff --git a/test/Sema/atomic-ops.c b/test/Sema/atomic-ops.c
index a33ff2b19c..b3daa0704d 100644
--- a/test/Sema/atomic-ops.c
+++ b/test/Sema/atomic-ops.c
@@ -173,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/bitfield.c b/test/Sema/bitfield.c
index a1ce894037..ab05a7773d 100644
--- a/test/Sema/bitfield.c
+++ b/test/Sema/bitfield.c
@@ -39,3 +39,18 @@ int y;
struct PR8025 {
double : 2; // expected-error{{anonymous bit-field has non-integral type 'double'}}
};
+
+struct Test4 {
+ unsigned bitX : 4;
+ unsigned bitY : 4;
+ unsigned var;
+};
+void test4(struct Test4 *t) {
+ (void) sizeof(t->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}}
+ (void) sizeof((t->bitY)); // expected-error {{invalid application of 'sizeof' to bit-field}}
+ (void) sizeof(t->bitX = 4); // not a bitfield designator in C
+ (void) sizeof(t->bitX += 4); // not a bitfield designator in C
+ (void) sizeof((void) 0, t->bitX); // not a bitfield designator in C
+ (void) sizeof(t->var ? t->bitX : t->bitY); // not a bitfield designator in C
+ (void) sizeof(t->var ? t->bitX : t->bitX); // not a bitfield designator in C
+}
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index 2ea4d813ab..6b4d99830c 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-aarch64.c b/test/Sema/builtins-aarch64.c
new file mode 100644
index 0000000000..03e03343eb
--- /dev/null
+++ b/test/Sema/builtins-aarch64.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -fsyntax-only -verify %s
+
+void test_clear_cache_chars(char *start, char *end) {
+ __clear_cache(start, end);
+}
+
+void test_clear_cache_voids(void *start, void *end) {
+ __clear_cache(start, end);
+}
+
+void test_clear_cache_no_args() {
+ // AArch32 version of this is variadic (at least syntactically).
+ // However, on AArch64 GCC does not permit this call and the
+ // implementation I've seen would go disastrously wrong.
+ __clear_cache(); // expected-error {{too few arguments to function call}}
+}
diff --git a/test/Sema/captured-statements.c b/test/Sema/captured-statements.c
new file mode 100644
index 0000000000..9285a7802d
--- /dev/null
+++ b/test/Sema/captured-statements.c
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
+
+void test_gotos() {
+ goto L1; // expected-error {{use of undeclared label 'L1'}}
+ goto L3; // OK
+ #pragma clang __debug captured
+ {
+L1:
+ goto L2; // OK
+L2:
+ goto L3; // expected-error {{use of undeclared label 'L3'}}
+ }
+L3: ;
+}
+
+void test_break_continue() {
+ while (1) {
+ #pragma clang __debug captured
+ {
+ break; // expected-error {{'break' statement not in loop or switch statement}}
+ continue; // expected-error {{'continue' statement not in loop statement}}
+ }
+ }
+}
+
+void test_return() {
+ while (1) {
+ #pragma clang __debug captured
+ {
+ return; // expected-error {{cannot return from default captured statement}}
+ }
+ }
+}
+
+void test_nest() {
+ int x;
+ #pragma clang __debug captured
+ {
+ int y;
+ #pragma clang __debug captured
+ {
+ int z;
+ #pragma clang __debug captured
+ {
+ x = z = y; // OK
+ }
+ }
+ }
+}
+
+void test_nest_block() {
+ __block int x;
+ int y;
+ ^{
+ int z;
+ #pragma clang __debug captured
+ {
+ x = y; // OK
+ y = z; // expected-error{{variable is not assignable (missing __block type specifier)}}
+ z = y; // OK
+ }
+ }();
+
+ __block int a;
+ int b;
+ #pragma clang __debug captured
+ {
+ __block int c;
+ int d;
+ ^{
+ a = b; // OK
+ a = c; // OK
+ b = d; // OK - Consistent with block inside a lambda
+ c = a; // OK
+ d = b; // expected-error{{variable is not assignable (missing __block type specifier)}}
+ }();
+ }
+}
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index b5d4ef5d12..887bce0630 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/crash-invalid-array.c b/test/Sema/crash-invalid-array.c
index a3bc03b70b..eeac39148c 100644
--- a/test/Sema/crash-invalid-array.c
+++ b/test/Sema/crash-invalid-array.c
@@ -15,3 +15,10 @@ int main()
p[i][i] = i;
}
}
+
+// rdar://13705391
+void foo(int a[*][2]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
+void foo1(int a[2][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
+void foo2(int a[*][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
+void foo3(int a[2][*][2]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
+void foo4(int a[2][*][*]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
diff --git a/test/Sema/decl-invalid.c b/test/Sema/decl-invalid.c
index f6fed3c92d..0544304c20 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 7354028cba..30c009201c 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-comma-c99.c b/test/Sema/expr-comma-c99.c
index 6e97a4fc49..02886bff05 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 7902715915..e2beafe236 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 df3e25857c..2fb17e4880 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 ae4386eaae..e9a4c571bd 100644
--- a/test/Sema/extern-redecl.c
+++ b/test/Sema/extern-redecl.c
@@ -22,3 +22,43 @@ int PR10013(void) {
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 []'}}
+}
+
+void test4() {
+ extern int test4_array[];
+ {
+ extern int test4_array[100];
+ int x = sizeof(test4_array); // fine
+ }
+ int x = sizeof(test4_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
+}
+
+// Test that invalid local extern declarations of library
+// builtins behave reasonably.
+extern void abort(void); // expected-note 2 {{previous declaration is here}}
+extern float *calloc(); // expected-warning {{incompatible redeclaration of library function}} expected-note {{is a builtin}} expected-note 2 {{previous declaration is here}}
+void test5a() {
+ int abort(); // expected-error {{conflicting types}}
+ float *malloc(); // expected-warning {{incompatible redeclaration of library function}} expected-note 2 {{is a builtin}}
+ int *calloc(); // expected-error {{conflicting types}}
+}
+void test5b() {
+ int abort(); // expected-error {{conflicting types}}
+ float *malloc(); // expected-warning {{incompatible redeclaration of library function}}
+ int *calloc(); // expected-error {{conflicting types}}
+}
+void test5c() {
+ void (*_abort)(void) = &abort;
+ void *(*_malloc)() = &malloc;
+ float *(*_calloc)() = &calloc;
+}
diff --git a/test/Sema/function-redecl.c b/test/Sema/function-redecl.c
index 3ee8763a56..561f7fae6b 100644
--- a/test/Sema/function-redecl.c
+++ b/test/Sema/function-redecl.c
@@ -62,7 +62,7 @@ void test2() {
// <rdar://problem/6127293>
int outer1(int); // expected-note{{previous declaration is here}}
struct outer3 { };
-int outer4(int);
+int outer4(int); // expected-note{{previous declaration is here}}
int outer5; // expected-note{{previous definition is here}}
int *outer7(int);
@@ -70,7 +70,7 @@ void outer_test() {
int outer1(float); // expected-error{{conflicting types for 'outer1'}}
int outer2(int); // expected-note{{previous declaration is here}}
int outer3(int); // expected-note{{previous declaration is here}}
- int outer4(int); // expected-note{{previous declaration is here}}
+ int outer4(int);
int outer5(int); // expected-error{{redefinition of 'outer5' as different kind of symbol}}
int* outer6(int); // expected-note{{previous declaration is here}}
int *outer7(int);
diff --git a/test/Sema/function.c b/test/Sema/function.c
index 1b0dc2adeb..bbf81a56cb 100644
--- a/test/Sema/function.c
+++ b/test/Sema/function.c
@@ -92,3 +92,14 @@ void t20(int i...) { } // expected-error {{requires a comma}}
int n;
void t21(int n, int (*array)[n]);
+
+int func_e(int x) {
+ int func_n(int y) { // expected-error {{function definition is not allowed here}}
+ if (y > 22) {
+ return y+2;
+ } else {
+ return y-2;
+ }
+ }
+ return x + 3;
+}
diff --git a/test/Sema/inline.c b/test/Sema/inline.c
index c27c00efaa..496e282eca 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/no-documentation-warn-tagdecl-specifier.c b/test/Sema/no-documentation-warn-tagdecl-specifier.c
new file mode 100644
index 0000000000..a0702ad7df
--- /dev/null
+++ b/test/Sema/no-documentation-warn-tagdecl-specifier.c
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -verify %s
+// rdar://12390371
+
+/** @return s Test*/
+struct s* f(void);
+struct s;
+
+struct s1;
+/** @return s1 Test 1*/
+struct s1* f1(void);
+
+struct s2;
+/** @return s2 Test 2*/
+struct s2* f2(void);
+struct s2;
+
+// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}}
+/** @return s3 Test 3 - expected warning here */
+struct s3;
+struct s3* f3(void);
+
+/** @return s4 Test 4 */
+struct s4* f4(void);
+struct s4 { int is; };
+
+// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}}
+/** @return s5 Test 5 - expected warning here */
+struct s5 { int is; };
+struct s5* f5(void);
+
+// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}}
+/** @return s6 Test 6 - expected warning here */
+struct s6 *ps6;
+struct s6* f6(void);
+
+// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}}
+/** @return s7 Test 7 - expected warning here */
+struct s7;
+struct s7* f7(void);
+
+struct s8 { int is8; };
+/** @return s8 Test 8 */
+struct s4 *f8(struct s8 *p);
+
+
+/** @return e Test*/
+enum e* g(void);
+enum e;
+
+enum e1;
+/** @return e1 Test 1*/
+enum e1* g1(void);
+
+enum e2;
+/** @return e2 Test 2*/
+enum e2* g2(void);
+enum e2;
+
+// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}}
+/** @return e3 Test 3 - expected warning here */
+enum e3;
+enum e3* g3(void);
+
+/** @return e4 Test 4 */
+enum e4* g4(void);
+enum e4 { one };
+
+// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}}
+/** @return e5 Test 5 - expected warning here */
+enum e5 { two };
+enum e5* g5(void);
+
+// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}}
+/** @return e6 Test 6 - expected warning here */
+enum e6 *pe6;
+enum e6* g6(void);
+
+// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}}
+/** @return e7 Test 7 - expected warning here */
+enum e7;
+enum e7* g7(void);
+
+enum e8 { three };
+/** @return e8 Test 8 */
+enum e4 *g8(enum e8 *p);
diff --git a/test/Sema/parentheses.c b/test/Sema/parentheses.c
index c3b3aa77c5..300e585588 100644
--- a/test/Sema/parentheses.c
+++ b/test/Sema/parentheses.c
@@ -1,25 +1,44 @@
// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
-// RUN: %clang_cc1 -Wparentheses -fixit %s -o - | %clang_cc1 -Wparentheses -Werror -
+// RUN: %clang_cc1 -Wparentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
// Test the various warnings under -Wparentheses
void if_assign(void) {
int i;
if (i = 4) {} // expected-warning {{assignment as a condition}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}} \
- // expected-note{{place parentheses around the assignment to silence this warning}}
+ // expected-note{{place parentheses around the assignment to silence this warning}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:7-[[@LINE-3]]:7}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:12-[[@LINE-4]]:12}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:9-[[@LINE-5]]:10}:"=="
+
if ((i = 4)) {}
}
void bitwise_rel(unsigned i) {
(void)(i & 0x2 == 0); // expected-warning {{& has lower precedence than ==}} \
- // expected-note{{place parentheses around the & expression to evaluate it first}} \
- // expected-note{{place parentheses around the '==' expression to silence this warning}}
+ // expected-note{{place parentheses around the '==' expression to silence this warning}} \
+ // expected-note{{place parentheses around the & expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:14-[[@LINE-3]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:22-[[@LINE-4]]:22}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:17-[[@LINE-6]]:17}:")"
+
(void)(0 == i & 0x2); // expected-warning {{& has lower precedence than ==}} \
- // expected-note{{place parentheses around the & expression to evaluate it first}} \
- // expected-note{{place parentheses around the '==' expression to silence this warning}}
+ // expected-note{{place parentheses around the '==' expression to silence this warning}} \
+ // expected-note{{place parentheses around the & expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:22-[[@LINE-6]]:22}:")"
+
(void)(i & 0xff < 30); // expected-warning {{& has lower precedence than <}} \
- // expected-note{{place parentheses around the & expression to evaluate it first}} \
- // expected-note{{place parentheses around the '<' expression to silence this warning}}
+ // expected-note{{place parentheses around the '<' expression to silence this warning}} \
+ // expected-note{{place parentheses around the & expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:14-[[@LINE-3]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:23-[[@LINE-4]]:23}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:18-[[@LINE-6]]:18}:")"
+
(void)((i & 0x2) == 0);
(void)(i & (0x2 == 0));
// Eager logical op
@@ -28,19 +47,33 @@ void bitwise_rel(unsigned i) {
(void)(i & i | i); // expected-warning {{'&' within '|'}} \
// expected-note {{place parentheses around the '&' expression to silence this warning}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
(void)(i | i & i); // expected-warning {{'&' within '|'}} \
// expected-note {{place parentheses around the '&' expression to silence this warning}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:14-[[@LINE-2]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:19-[[@LINE-3]]:19}:")"
(void)(i ||
i && i); // expected-warning {{'&&' within '||'}} \
- // expected-note {{place parentheses around the '&&' expression to silence this warning}}
+ // expected-note {{place parentheses around the '&&' expression to silence this warning}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:14-[[@LINE-2]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")"
+
(void)(i || i && "w00t"); // no warning.
(void)("w00t" && i || i); // no warning.
+
(void)(i || i && "w00t" || i); // expected-warning {{'&&' within '||'}} \
// expected-note {{place parentheses around the '&&' expression to silence this warning}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:26-[[@LINE-3]]:26}:")"
+
(void)(i || "w00t" && i || i); // expected-warning {{'&&' within '||'}} \
// expected-note {{place parentheses around the '&&' expression to silence this warning}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:26-[[@LINE-3]]:26}:")"
+
(void)(i && i || 0); // no warning.
(void)(0 || i && i); // no warning.
}
@@ -49,25 +82,41 @@ _Bool someConditionFunc();
void conditional_op(int x, int y, _Bool b) {
(void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \
- // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
- // expected-note {{place parentheses around the '+' expression to silence this warning}}
+ // expected-note {{place parentheses around the '+' expression to silence this warning}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:33-[[@LINE-4]]:33}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:41-[[@LINE-6]]:41}:")"
(void)((x + someConditionFunc()) ? 1 : 2); // no warning
(void)(x - b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '-'}} \
- // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
- // expected-note {{place parentheses around the '-' expression to silence this warning}}
+ // expected-note {{place parentheses around the '-' expression to silence this warning}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:15-[[@LINE-4]]:15}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:23-[[@LINE-6]]:23}:")"
(void)(x * (x == y) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '*'}} \
- // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
- // expected-note {{place parentheses around the '*' expression to silence this warning}}
+ // expected-note {{place parentheses around the '*' expression to silence this warning}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:22-[[@LINE-4]]:22}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:30-[[@LINE-6]]:30}:")"
(void)(x / !x ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '/'}} \
- // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
- // expected-note {{place parentheses around the '/' expression to silence this warning}}
+ // expected-note {{place parentheses around the '/' expression to silence this warning}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:24-[[@LINE-6]]:24}:")"
(void)(x % 2 ? 1 : 2); // no warning
}
-// RUN: %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s
-// CHECK: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses]
+// RUN: %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s -check-prefix=CHECK-FLAG
+// CHECK-FLAG: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses]
diff --git a/test/Sema/parentheses.cpp b/test/Sema/parentheses.cpp
index 8f5f24652d..ac2694f72e 100644
--- a/test/Sema/parentheses.cpp
+++ b/test/Sema/parentheses.cpp
@@ -1,20 +1,32 @@
// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
-// RUN: %clang_cc1 -Wparentheses -fixit %s -o - | %clang_cc1 -Wparentheses -Werror -
+// RUN: %clang_cc1 -Wparentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
bool someConditionFunc();
void conditional_op(int x, int y, bool b) {
(void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \
- // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
- // expected-note {{place parentheses around the '+' expression to silence this warning}}
+ // expected-note {{place parentheses around the '+' expression to silence this warning}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:33-[[@LINE-4]]:33}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:41-[[@LINE-6]]:41}:")"
(void)(x - b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '-'}} \
- // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
- // expected-note {{place parentheses around the '-' expression to silence this warning}}
+ // expected-note {{place parentheses around the '-' expression to silence this warning}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:15-[[@LINE-4]]:15}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:23-[[@LINE-6]]:23}:")"
(void)(x * (x == y) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '*'}} \
- // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
- // expected-note {{place parentheses around the '*' expression to silence this warning}}
+ // expected-note {{place parentheses around the '*' expression to silence this warning}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:22-[[@LINE-4]]:22}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:30-[[@LINE-6]]:30}:")"
}
class Stream {
@@ -28,8 +40,28 @@ public:
void f(Stream& s, bool b) {
(void)(s << b ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '<<'}} \
- // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
- // expected-note {{place parentheses around the '<<' expression to silence this warning}}
+ // expected-note {{place parentheses around the '<<' expression to silence this warning}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:32-[[@LINE-6]]:32}:")"
+
+ (void)(s << 5 == 1); // expected-warning {{overloaded operator << has lower precedence than comparison operator}} \
+ // expected-note {{place parentheses around the '<<' expression to silence this warning}} \
+ // expected-note {{place parentheses around comparison expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"
+
+ (void)(s >> 5 == 1); // expected-warning {{overloaded operator >> has lower precedence than comparison operator}} \
+ // expected-note {{place parentheses around the '>>' expression to silence this warning}} \
+ // expected-note {{place parentheses around comparison expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"
}
struct S {
@@ -39,8 +71,12 @@ struct S {
void test(S *s, bool (S::*m_ptr)()) {
(void)(*s + true ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '+'}} \
- // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
- // expected-note {{place parentheses around the '+' expression to silence this warning}}
+ // expected-note {{place parentheses around the '+' expression to silence this warning}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:19-[[@LINE-4]]:19}:")"
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:35-[[@LINE-6]]:35}:")"
(void)((*s + true) ? "foo" : "bar"); // No warning.
@@ -51,9 +87,29 @@ void test(S *s, bool (S::*m_ptr)()) {
void test(int a, int b, int c) {
(void)(a >> b + c); // expected-warning {{operator '>>' has lower precedence than '+'; '+' will be evaluated first}} \
expected-note {{place parentheses around the '+' expression to silence this warning}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")"
+
(void)(a - b << c); // expected-warning {{operator '<<' has lower precedence than '-'; '-' will be evaluated first}} \
expected-note {{place parentheses around the '-' expression to silence this warning}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
+
Stream() << b + 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}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"("
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")"
+}
+
+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/pragma-arc-cf-code-audited.c b/test/Sema/pragma-arc-cf-code-audited.c
index b646e8966c..c1aa804557 100644
--- a/test/Sema/pragma-arc-cf-code-audited.c
+++ b/test/Sema/pragma-arc-cf-code-audited.c
@@ -13,6 +13,6 @@
#include "Inputs/pragma-arc-cf-code-audited.h" // expected-error {{cannot #include files inside '#pragma clang arc_cf_code_audited'}}
// This is actually on the #pragma line in the header.
-// expected-error {{'#pragma clang arc_cf_code_audited' was not ended within this file}}
+// expected-error@Inputs/pragma-arc-cf-code-audited.h:16 {{'#pragma clang arc_cf_code_audited' was not ended within this file}}
#pragma clang arc_cf_code_audited begin // expected-error {{'#pragma clang arc_cf_code_audited' was not ended within this file}}
diff --git a/test/Sema/private-extern.c b/test/Sema/private-extern.c
index e480f3f224..e9b67d5070 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.c b/test/Sema/return.c
index 77bd3f688e..7e7c8b7b84 100644
--- a/test/Sema/return.c
+++ b/test/Sema/return.c
@@ -197,8 +197,14 @@ int test29() {
exit(1);
}
-#include <setjmp.h>
+// Include these declarations here explicitly so we don't depend on system headers.
+typedef struct __jmp_buf_tag{} jmp_buf[1];
+
+extern void longjmp (struct __jmp_buf_tag __env[1], int __val) __attribute__ ((noreturn));
+extern void _longjmp (struct __jmp_buf_tag __env[1], int __val) __attribute__ ((noreturn));
+
jmp_buf test30_j;
+
int test30() {
if (j)
longjmp(test30_j, 1);
@@ -244,6 +250,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 9309987431..87fa0504b2 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"}}
@@ -11,3 +15,28 @@ void foo(void) {
}
_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 6070e875f5..819e856ac8 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
index 82ce6747a3..ce1e7dc943 100644
--- a/test/Sema/switch-1.c
+++ b/test/Sema/switch-1.c
@@ -1,6 +1,7 @@
// 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) {
@@ -10,6 +11,9 @@ int f(int i) {
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;
}
diff --git a/test/Sema/thread-specifier.c b/test/Sema/thread-specifier.c
index 8c40fcd0a6..9d516e8f14 100644
--- a/test/Sema/thread-specifier.c
+++ b/test/Sema/thread-specifier.c
@@ -1,30 +1,110 @@
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -DGNU
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DGNU
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -DC11 -D__thread=_Thread_local
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DCXX11 -D__thread=thread_local -std=c++11
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++11
+
+#ifdef __cplusplus
+// In C++, we define __private_extern__ to extern.
+#undef __private_extern__
+#endif
__thread int t1;
-__thread extern int t2; // expected-warning {{'__thread' before 'extern'}}
-__thread static int t3; // expected-warning {{'__thread' before 'static'}}
+__thread extern int t2;
+__thread static int t3;
+#ifdef GNU
+// expected-warning@-3 {{'__thread' before 'extern'}}
+// expected-warning@-3 {{'__thread' before 'static'}}
+#endif
+
__thread __private_extern__ int t4;
-struct t5 { __thread int x; }; // expected-error {{type name does not allow storage class to be specified}}
-__thread int t6(); // expected-error {{'__thread' is only allowed on variable declarations}}
+struct t5 { __thread int x; };
+#ifdef __cplusplus
+// expected-error-re@-2 {{'(__thread|_Thread_local|thread_local)' is only allowed on variable declarations}}
+#else
+// FIXME: The 'is only allowed on variable declarations' diagnostic is better here.
+// expected-error@-5 {{type name does not allow storage class to be specified}}
+#endif
-int f(__thread int t7) { // expected-error {{'__thread' is only allowed on variable declarations}}
- __thread int t8; // expected-error {{'__thread' variables must have global storage}}
+__thread int t6();
+#if defined(GNU)
+// expected-error@-2 {{'__thread' is only allowed on variable declarations}}
+#elif defined(C11)
+// expected-error@-4 {{'_Thread_local' is only allowed on variable declarations}}
+#else
+// expected-error@-6 {{'thread_local' is only allowed on variable declarations}}
+#endif
+
+int f(__thread int t7) { // expected-error {{' is only allowed on variable declarations}}
+ __thread int t8;
+#if defined(GNU)
+ // expected-error@-2 {{'__thread' variables must have global storage}}
+#elif defined(C11)
+ // expected-error@-4 {{'_Thread_local' variables must have global storage}}
+#endif
extern __thread int t9;
static __thread int t10;
__thread __private_extern__ int t11;
- __thread auto int t12; // expected-error {{'__thread' variables must have global storage}}
- __thread register int t13; // expected-error {{'__thread' variables must have global storage}}
+#if __cplusplus < 201103L
+ __thread auto int t12a; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local)' declaration specifier}}
+ auto __thread int t12b; // expected-error {{cannot combine with previous 'auto' declaration specifier}}
+#elif !defined(CXX11)
+ __thread auto t12a = 0; // expected-error-re {{'_Thread_local' variables must have global storage}}
+ auto __thread t12b = 0; // expected-error-re {{'_Thread_local' variables must have global storage}}
+#endif
+ __thread register int t13a; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local|thread_local)' declaration specifier}}
+ register __thread int t13b; // expected-error {{cannot combine with previous 'register' declaration specifier}}
}
-__thread typedef int t14; // expected-error {{'__thread' is only allowed on variable declarations}}
-__thread int t15; // expected-note {{previous definition is here}}
-int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}}
-int t16; // expected-note {{previous definition is here}}
+__thread typedef int t14; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local|thread_local)' declaration specifier}}
+__thread int t15; // expected-note {{previous declaration is here}}
+extern int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}}
+extern int t16; // expected-note {{previous declaration is here}}
__thread int t16; // expected-error {{thread-local declaration of 't16' follows non-thread-local declaration}}
+#ifdef CXX11
+extern thread_local int t17; // expected-note {{previous declaration is here}}
+_Thread_local int t17; // expected-error {{thread-local declaration of 't17' with static initialization follows declaration with dynamic initialization}}
+extern _Thread_local int t18; // expected-note {{previous declaration is here}}
+thread_local int t18; // expected-error {{thread-local declaration of 't18' with dynamic initialization follows declaration with static initialization}}
+#endif
+
// PR13720
__thread int thread_int;
-int *thread_int_ptr = &thread_int; // expected-error{{initializer element is not a compile-time constant}}
+int *thread_int_ptr = &thread_int;
+#ifndef __cplusplus
+// expected-error@-2 {{initializer element is not a compile-time constant}}
+#endif
void g() {
int *p = &thread_int; // This is perfectly fine, though.
}
+#if __cplusplus >= 201103L
+constexpr int *thread_int_ptr_2 = &thread_int; // expected-error {{must be initialized by a constant expression}}
+#endif
+
+int non_const();
+__thread int non_const_init = non_const();
+#if !defined(__cplusplus)
+// expected-error@-2 {{initializer element is not a compile-time constant}}
+#elif !defined(CXX11)
+// expected-error@-4 {{initializer for thread-local variable must be a constant expression}}
+#if __cplusplus >= 201103L
+// expected-note@-6 {{use 'thread_local' to allow this}}
+#endif
+#endif
+
+#ifdef __cplusplus
+struct S {
+ ~S();
+};
+__thread S s;
+#if !defined(CXX11)
+// expected-error@-2 {{type of thread-local variable has non-trivial destruction}}
+#if __cplusplus >= 201103L
+// expected-note@-4 {{use 'thread_local' to allow this}}
+#endif
+#endif
+#endif
+
+__thread int aggregate[10] = {0};
diff --git a/test/Sema/var-redecl.c b/test/Sema/var-redecl.c
index f7576b6c02..363458b201 100644
--- a/test/Sema/var-redecl.c
+++ b/test/Sema/var-redecl.c
@@ -4,7 +4,7 @@ int outer1; // expected-note{{previous definition is here}}
extern int outer2; // expected-note{{previous definition is here}}
int outer4;
int outer4; // expected-note{{previous definition is here}}
-int outer5;
+int outer5; // expected-note{{previous definition is here}}
int outer6(float); // expected-note{{previous definition is here}}
int outer7(float);
@@ -13,7 +13,7 @@ void outer_test() {
extern float outer2; // expected-error{{redefinition of 'outer2' with a different type}}
extern float outer3; // expected-note{{previous definition is here}}
double outer4;
- extern int outer5; // expected-note{{previous definition is here}}
+ extern int outer5;
extern int outer6; // expected-error{{redefinition of 'outer6' as different kind of symbol}}
int outer7;
extern int outer8; // expected-note{{previous definition is here}}
diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp
index 0132ef280c..b3ab0199dc 100644
--- a/test/Sema/warn-documentation.cpp
+++ b/test/Sema/warn-documentation.cpp
@@ -892,10 +892,10 @@ typedef const struct test_nocrash7 * test_nocrash8;
// We used to crash on this.
+// expected-warning@+1 {{unknown command tag name}}
/// aaa \unknown aaa \unknown aaa
int test_nocrash9;
-
// We used to crash on this. PR15068
// expected-warning@+2 {{empty paragraph passed to '@param' command}}
diff --git a/test/Sema/warn-documentation.m b/test/Sema/warn-documentation.m
index 98c4993561..0737a8dedd 100644
--- a/test/Sema/warn-documentation.m
+++ b/test/Sema/warn-documentation.m
@@ -123,6 +123,20 @@ typedef id OBJ;
}
@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
@@ -135,6 +149,7 @@ struct S;
@class NSArray;
@interface NSArray @end
+// expected-warning@+3 {{unknown command tag name}}
/*!
@interface NSMutableArray
@super NSArray
diff --git a/test/Sema/warn-duplicate-enum.c b/test/Sema/warn-duplicate-enum.c
index 239f6f1995..f108b3aa6c 100644
--- a/test/Sema/warn-duplicate-enum.c
+++ b/test/Sema/warn-duplicate-enum.c
@@ -90,3 +90,12 @@ enum {
NMax = N2,
NCount = NMax + 1
};
+
+// PR15693
+enum enum1 {
+ VALUE // expected-note{{previous definition is here}}
+};
+
+enum enum2 {
+ VALUE // expected-error{{redefinition of enumerator 'VALUE'}}
+};
diff --git a/test/Sema/warn-sizeof-array-decay.c b/test/Sema/warn-sizeof-array-decay.c
new file mode 100644
index 0000000000..cc3ee1d0fc
--- /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-unused-variables-werror.c b/test/Sema/warn-unused-variables-werror.c
new file mode 100644
index 0000000000..ceaff1ba69
--- /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}}
+}