diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
commit | dbe13110f59f48b4dbb7552b3ac2935acdeece7f (patch) | |
tree | be1815eb79b42ff482a8562b13c2dcbf0c5dcbee /test/Misc | |
parent | 9da628931ebf2609493570f87824ca22402cc65f (diff) |
Notes
Diffstat (limited to 'test/Misc')
-rw-r--r-- | test/Misc/caret-diags-macros.c | 58 | ||||
-rw-r--r-- | test/Misc/diag-aka-types.cpp | 18 | ||||
-rw-r--r-- | test/Misc/diag-format.c | 6 | ||||
-rw-r--r-- | test/Misc/diag-macro-backtrace.c | 53 | ||||
-rw-r--r-- | test/Misc/diag-verify.cpp | 48 | ||||
-rw-r--r-- | test/Misc/include-stack-for-note-flag.cpp | 4 | ||||
-rw-r--r-- | test/Misc/integer-literal-printing.cpp | 13 | ||||
-rw-r--r-- | test/Misc/macro-backtrace-limit.c | 32 | ||||
-rw-r--r-- | test/Misc/macro-backtrace.c | 57 | ||||
-rw-r--r-- | test/Misc/pubnames.c | 19 | ||||
-rw-r--r-- | test/Misc/serialized-diags-no-category.c | 12 | ||||
-rw-r--r-- | test/Misc/serialized-diags-no-issue.c | 10 | ||||
-rw-r--r-- | test/Misc/serialized-diags-single-issue.c | 36 | ||||
-rw-r--r-- | test/Misc/serialized-diags.c | 67 | ||||
-rw-r--r-- | test/Misc/serialized-diags.h | 5 | ||||
-rw-r--r-- | test/Misc/warn-in-system-header.c | 2 | ||||
-rw-r--r-- | test/Misc/warning-flags.c | 46 |
17 files changed, 373 insertions, 113 deletions
diff --git a/test/Misc/caret-diags-macros.c b/test/Misc/caret-diags-macros.c index 3d2e576d64144..de1ee76ed1bee 100644 --- a/test/Misc/caret-diags-macros.c +++ b/test/Misc/caret-diags-macros.c @@ -6,8 +6,8 @@ void foo() { M1( M2); // CHECK: :7:{{[0-9]+}}: warning: expression result unused - // CHECK: :4:{{[0-9]+}}: note: expanded from: - // CHECK: :3:{{[0-9]+}}: note: expanded from: + // CHECK: :4:{{[0-9]+}}: note: expanded from macro 'M2' + // CHECK: :3:{{[0-9]+}}: note: expanded from macro 'M1' } #define A 1 @@ -16,9 +16,9 @@ void foo() { void bar() { C; // CHECK: :17:3: warning: expression result unused - // CHECK: :15:11: note: expanded from: - // CHECK: :14:11: note: expanded from: - // CHECK: :13:11: note: expanded from: + // CHECK: :15:11: note: expanded from macro 'C' + // CHECK: :14:11: note: expanded from macro 'B' + // CHECK: :13:11: note: expanded from macro 'A' } // rdar://7597492 @@ -46,28 +46,28 @@ void test() { // its easy to FileCheck. // CHECK-NEXT: macro_args3(1); // CHECK-NEXT: ~~~~~~~~~~~~^~ - // CHECK: {{.*}}:36:36: note: expanded from: - // CHECK: {{.*}}:35:36: note: expanded from: - // CHECK: {{.*}}:34:24: note: expanded from: + // CHECK: {{.*}}:36:36: note: expanded from macro 'macro_args3' + // CHECK: {{.*}}:35:36: note: expanded from macro 'macro_args2' + // CHECK: {{.*}}:34:24: note: expanded from macro 'macro_args1' macro_many_args3( 1, 2, 3); // CHECK: {{.*}}:55:5: warning: expression result unused - // CHECK: {{.*}}:40:55: note: expanded from: - // CHECK: {{.*}}:39:55: note: expanded from: - // CHECK: {{.*}}:38:35: note: expanded from: + // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3' + // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2' + // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1' macro_many_args3( 1, M2, 3); // CHECK: {{.*}}:64:5: warning: expression result unused - // CHECK: {{.*}}:4:12: note: expanded from: - // CHECK: {{.*}}:40:55: note: expanded from: - // CHECK: {{.*}}:39:55: note: expanded from: - // CHECK: {{.*}}:38:35: note: expanded from: + // CHECK: {{.*}}:4:12: note: expanded from macro 'M2' + // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3' + // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2' + // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1' macro_many_args3( 1, @@ -78,11 +78,11 @@ void test() { // arguments. // CHECK-NEXT: macro_args2(2), // CHECK-NEXT: ~~~~~~~~~~~~^~~ - // CHECK: {{.*}}:35:36: note: expanded from: - // CHECK: {{.*}}:34:24: note: expanded from: - // CHECK: {{.*}}:40:55: note: expanded from: - // CHECK: {{.*}}:39:55: note: expanded from: - // CHECK: {{.*}}:38:35: note: expanded from: + // CHECK: {{.*}}:35:36: note: expanded from macro 'macro_args2' + // CHECK: {{.*}}:34:24: note: expanded from macro 'macro_args1' + // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3' + // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2' + // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1' } #define variadic_args1(x, y, ...) y @@ -94,9 +94,9 @@ void test2() { // CHECK: {{.*}}:93:21: warning: expression result unused // CHECK-NEXT: variadic_args3(1, 2, 3, 4); // CHECK-NEXT: ~~~~~~~~~~~~~~~~~~^~~~~~~~ - // CHECK: {{.*}}:90:53: note: expanded from: - // CHECK: {{.*}}:89:50: note: expanded from: - // CHECK: {{.*}}:88:35: note: expanded from: + // CHECK: {{.*}}:90:53: note: expanded from macro 'variadic_args3' + // CHECK: {{.*}}:89:50: note: expanded from macro 'variadic_args2' + // CHECK: {{.*}}:88:35: note: expanded from macro 'variadic_args1' } #define variadic_pasting_args1(x, y, z) y @@ -108,13 +108,13 @@ void test2() { void test3() { variadic_pasting_args3(1, 2, 3, 4); // CHECK: {{.*}}:109:32: warning: expression result unused - // CHECK: {{.*}}:105:72: note: expanded from: - // CHECK: {{.*}}:103:68: note: expanded from: - // CHECK: {{.*}}:102:41: note: expanded from: + // CHECK: {{.*}}:105:72: note: expanded from macro 'variadic_pasting_args3' + // CHECK: {{.*}}:103:68: note: expanded from macro 'variadic_pasting_args2' + // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1' variadic_pasting_args3a(1, 2, 3, 4); // CHECK: {{.*}}:115:30: warning: expression result unused - // CHECK: {{.*}}:106:71: note: expanded from: - // CHECK: {{.*}}:104:70: note: expanded from: - // CHECK: {{.*}}:102:41: note: expanded from: + // CHECK: {{.*}}:106:71: note: expanded from macro 'variadic_pasting_args3a' + // CHECK: {{.*}}:104:70: note: expanded from macro 'variadic_pasting_args2a' + // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1' } diff --git a/test/Misc/diag-aka-types.cpp b/test/Misc/diag-aka-types.cpp index 0339b7b63e82b..4c9a7312cdafe 100644 --- a/test/Misc/diag-aka-types.cpp +++ b/test/Misc/diag-aka-types.cpp @@ -27,7 +27,7 @@ namespace bar { } void test(Foo::foo* x) { - bar::f(x); // expected-error{{cannot initialize a parameter of type 'Foo::foo *' (aka 'bar::Foo::foo *') with an lvalue of type 'Foo::foo *')}} + bar::f(x); // expected-error{{cannot initialize a parameter of type 'Foo::foo *' (aka 'bar::Foo::foo *') with an lvalue of type 'Foo::foo *'}} } // PR9548 - "no known conversion from 'vector<string>' to 'vector<string>'" @@ -50,3 +50,19 @@ namespace std { f(v); // expected-error{{no matching function for call to 'f'}} } } + +namespace ns { + struct str { + static void method(struct data *) {} + }; +} + +struct data { int i; }; + +typedef void (*callback)(struct data *); + +void helper(callback cb) {} // expected-note{{candidate function not viable: no known conversion from 'void (*)(struct data *)' (aka 'void (*)(ns::data *)') to 'callback' (aka 'void (*)(struct data *)') for 1st argument;}} + +void test() { + helper(&ns::str::method); // expected-error{{no matching function for call to 'helper'}} +} diff --git a/test/Misc/diag-format.c b/test/Misc/diag-format.c index 39760b1f1a6c1..959177b2bd422 100644 --- a/test/Misc/diag-format.c +++ b/test/Misc/diag-format.c @@ -1,10 +1,10 @@ // RUN: %clang -fsyntax-only %s 2>&1 | FileCheck %s -check-prefix=DEFAULT // RUN: %clang -fsyntax-only -fdiagnostics-format=clang %s 2>&1 | FileCheck %s -check-prefix=DEFAULT -// RUN: %clang -fsyntax-only -fdiagnostics-format=clang -ccc-host-triple x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=DEFAULT +// RUN: %clang -fsyntax-only -fdiagnostics-format=clang -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=DEFAULT // // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc %s 2>&1 | FileCheck %s -check-prefix=MSVC -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -ccc-host-triple x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -ccc-host-triple x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC +// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC +// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC // // RUN: %clang -fsyntax-only -fdiagnostics-format=vi %s 2>&1 | FileCheck %s -check-prefix=VI // diff --git a/test/Misc/diag-macro-backtrace.c b/test/Misc/diag-macro-backtrace.c new file mode 100644 index 0000000000000..ea40cbec57edd --- /dev/null +++ b/test/Misc/diag-macro-backtrace.c @@ -0,0 +1,53 @@ +// RUN: %clang -fsyntax-only -fmacro-backtrace-limit=0 %s 2>&1 | FileCheck %s + +#define FOO 1+"hi" +#define BAR FOO +#define BAZ BAR +#define QUZ BAZ +#define TAZ QUZ +#define ABA TAZ +#define BAB ABA +#define ZAZ BAB +#define WAZ ZAZ +#define DROOL WAZ +#define FOOL DROOL + +FOOL + +// CHECK: :15:1: error: expected identifier or '(' +// CHECK: FOOL +// CHECK: ^ +// CHECK: :13:14: note: expanded from macro 'FOOL' +// CHECK: #define FOOL DROOL +// CHECK: ^ +// CHECK: :12:15: note: expanded from macro 'DROOL' +// CHECK: #define DROOL WAZ +// CHECK: ^ +// CHECK: :11:13: note: expanded from macro 'WAZ' +// CHECK: #define WAZ ZAZ +// CHECK: ^ +// CHECK: :10:13: note: expanded from macro 'ZAZ' +// CHECK: #define ZAZ BAB +// CHECK: ^ +// CHECK: :9:13: note: expanded from macro 'BAB' +// CHECK: #define BAB ABA +// CHECK: ^ +// CHECK: :8:13: note: expanded from macro 'ABA' +// CHECK: #define ABA TAZ +// CHECK: ^ +// CHECK: :7:13: note: expanded from macro 'TAZ' +// CHECK: #define TAZ QUZ +// CHECK: ^ +// CHECK: :6:13: note: expanded from macro 'QUZ' +// CHECK: #define QUZ BAZ +// CHECK: ^ +// CHECK: :5:13: note: expanded from macro 'BAZ' +// CHECK: #define BAZ BAR +// CHECK: ^ +// CHECK: :4:13: note: expanded from macro 'BAR' +// CHECK: #define BAR FOO +// CHECK: ^ +// CHECK: :3:13: note: expanded from macro 'FOO' +// CHECK: #define FOO 1+"hi" +// CHECK: ^ +// CHECK: 1 error generated. diff --git a/test/Misc/diag-verify.cpp b/test/Misc/diag-verify.cpp new file mode 100644 index 0000000000000..895bc3fe03030 --- /dev/null +++ b/test/Misc/diag-verify.cpp @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s 2>&1 | FileCheck %s + +// Test the -verify flag. Each of the "x = y;" lines will produce a +// "use of undeclared identifier 'y'" error message. + +void test() { + int x; + // Proper matches here. + x = y; // expected-error{{use of undeclared identifier 'y'}} + x = y; // expected-error{{use of undeclared identifier}} + x = y; // expected-error{{undeclared identifier 'y'}} + x = y; // expected-error{{use of}} + x = y; // expected-error{{undeclared identifier}} + x = y; // expected-error{{'y'}} + + // Bad matches here. + x = y; // expected-error{{use of undeclared identifier 'y' is fine}} + x = y; // expected-error{{abuse of undeclared identifier 'y'}} + x = y; // expected-error{{good use of undeclared identifier 'y' in code}} + x = y; // expected-error{{ use of undeclared identifier 'y' }} + x = y; // expected-error{{use of undeclared identifier 'y' is disallowed}} + x = y; // expected-error{{please don't use of undeclared identifier 'y'}} + x = y; // expected-error{{use of undeclared identifier 'y'; please declare y before use}} + x = y; // expected-error{{use of use of undeclared identifier 'y'}} + x = y; // expected-error{{use of undeclared identifier 'y' identifier 'y'}} +} + +//CHECK: error: 'error' diagnostics expected but not seen: +//CHECK: Line 17: use of undeclared identifier 'y' is fine +//CHECK: Line 18: abuse of undeclared identifier 'y' +//CHECK: Line 19: good use of undeclared identifier 'y' in code +//CHECK: Line 20: use of undeclared identifier 'y' +//CHECK: Line 21: use of undeclared identifier 'y' is disallowed +//CHECK: Line 22: please don't use of undeclared identifier 'y' +//CHECK: Line 23: use of undeclared identifier 'y'; please declare y before use +//CHECK: Line 24: use of use of undeclared identifier 'y' +//CHECK: Line 25: use of undeclared identifier 'y' identifier 'y' +//CHECK: error: 'error' diagnostics seen but not expected: +//CHECK: Line 17: use of undeclared identifier 'y' +//CHECK: Line 18: use of undeclared identifier 'y' +//CHECK: Line 19: use of undeclared identifier 'y' +//CHECK: Line 20: use of undeclared identifier 'y' +//CHECK: Line 21: use of undeclared identifier 'y' +//CHECK: Line 22: use of undeclared identifier 'y' +//CHECK: Line 23: use of undeclared identifier 'y' +//CHECK: Line 24: use of undeclared identifier 'y' +//CHECK: Line 25: use of undeclared identifier 'y' +//CHECK: 18 errors generated. diff --git a/test/Misc/include-stack-for-note-flag.cpp b/test/Misc/include-stack-for-note-flag.cpp index cfec5066a05f7..b41284fd607e7 100644 --- a/test/Misc/include-stack-for-note-flag.cpp +++ b/test/Misc/include-stack-for-note-flag.cpp @@ -18,11 +18,11 @@ bool macro(int x, int y) { // STACK: note: candidate function not viable // STACK: error: comparison between pointer and integer // STACK: In file included from -// STACK: note: expanded from: +// STACK: note: expanded from macro // STACKLESS: error: no matching function for call to 'foo' // STACKLESS-NOT: In file included from // STACKLESS: note: candidate function not viable // STACKLESS: error: comparison between pointer and integer // STACKLESS-NOT: In file included from -// STACKLESS: note: expanded from: +// STACKLESS: note: expanded from macro diff --git a/test/Misc/integer-literal-printing.cpp b/test/Misc/integer-literal-printing.cpp new file mode 100644 index 0000000000000..d751730d95f6e --- /dev/null +++ b/test/Misc/integer-literal-printing.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify + +// PR11179 +template <short T> class Type1 {}; +template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate function [with T = -42] not viable: no known conversion from 'Type1<-42>' to 'Type1<-42> &' for 1st argument;}} + +template <unsigned short T> class Type2 {}; +template <unsigned short T> void Function2(Type2<T>& x) {} // expected-note{{candidate function [with T = 42] not viable: no known conversion from 'Type2<42>' to 'Type2<42> &' for 1st argument;}} + +void Function() { + Function1(Type1<-42>()); // expected-error{{no matching function for call to 'Function1'}} + Function2(Type2<42>()); // expected-error{{no matching function for call to 'Function2'}} +} diff --git a/test/Misc/macro-backtrace-limit.c b/test/Misc/macro-backtrace-limit.c deleted file mode 100644 index ee73c61afc64c..0000000000000 --- a/test/Misc/macro-backtrace-limit.c +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -fmacro-backtrace-limit 5 %s > %t 2>&1 -// RUN: FileCheck %s < %t - -#define M1(A, B) ((A) < (B)) -#define M2(A, B) M1(A, B) -#define M3(A, B) M2(A, B) -#define M4(A, B) M3(A, B) -#define M5(A, B) M4(A, B) -#define M6(A, B) M5(A, B) -#define M7(A, B) M6(A, B) -#define M8(A, B) M7(A, B) -#define M9(A, B) M8(A, B) -#define M10(A, B) M9(A, B) -#define M11(A, B) M10(A, B) -#define M12(A, B) M11(A, B) - -void f(int *ip, float *fp) { - // CHECK: macro-backtrace-limit.c:31:7: warning: comparison of distinct pointer types ('int *' and 'float *') - // CHECK: if (M12(ip, fp)) { } - // CHECK: macro-backtrace-limit.c:15:19: note: expanded from: - // CHECK: #define M12(A, B) M11(A, B) - // CHECK: macro-backtrace-limit.c:14:19: note: expanded from: - // CHECK: #define M11(A, B) M10(A, B) - // CHECK: note: (skipping 7 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) - // CHECK: macro-backtrace-limit.c:6:18: note: expanded from: - // CHECK: #define M3(A, B) M2(A, B) - // CHECK: macro-backtrace-limit.c:5:18: note: expanded from: - // CHECK: #define M2(A, B) M1(A, B) - // CHECK: macro-backtrace-limit.c:4:23: note: expanded from: - // CHECK: #define M1(A, B) ((A) < (B)) - if (M12(ip, fp)) { } -} diff --git a/test/Misc/macro-backtrace.c b/test/Misc/macro-backtrace.c new file mode 100644 index 0000000000000..7aeaf21a13d53 --- /dev/null +++ b/test/Misc/macro-backtrace.c @@ -0,0 +1,57 @@ +// Tests for macro expansion backtraces. The RUN and CHECK lines are grouped +// below the test code to reduce noise when updating them. + +#define M1(A, B) ((A) < (B)) +#define M2(A, B) M1(A, B) +#define M3(A, B) M2(A, B) +#define M4(A, B) M3(A, B) +#define M5(A, B) M4(A, B) +#define M6(A, B) M5(A, B) +#define M7(A, B) M6(A, B) +#define M8(A, B) M7(A, B) +#define M9(A, B) M8(A, B) +#define M10(A, B) M9(A, B) +#define M11(A, B) M10(A, B) +#define M12(A, B) M11(A, B) + +void f(int *ip, float *fp) { + if (M12(ip, fp)) { } + // RUN: %clang_cc1 -fsyntax-only -fmacro-backtrace-limit 5 %s 2>&1 \ + // RUN: | FileCheck %s -check-prefix=CHECK-LIMIT + // CHECK-LIMIT: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *') + // CHECK-LIMIT: if (M12(ip, fp)) { } + // CHECK-LIMIT: macro-backtrace.c:15:19: note: expanded from macro 'M12' + // CHECK-LIMIT: #define M12(A, B) M11(A, B) + // CHECK-LIMIT: macro-backtrace.c:14:19: note: expanded from macro 'M11' + // CHECK-LIMIT: #define M11(A, B) M10(A, B) + // CHECK-LIMIT: note: (skipping 7 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) + // CHECK-LIMIT: macro-backtrace.c:6:18: note: expanded from macro 'M3' + // CHECK-LIMIT: #define M3(A, B) M2(A, B) + // CHECK-LIMIT: macro-backtrace.c:5:18: note: expanded from macro 'M2' + // CHECK-LIMIT: #define M2(A, B) M1(A, B) + // CHECK-LIMIT: macro-backtrace.c:4:23: note: expanded from macro 'M1' + // CHECK-LIMIT: #define M1(A, B) ((A) < (B)) + + // RUN: %clang_cc1 -fsyntax-only -fno-caret-diagnostics %s 2>&1 \ + // RUN: | FileCheck %s -check-prefix=CHECK-NO-CARETS + // CHECK-NO-CARETS: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *') + // CHECK-NO-CARETS-NEXT: macro-backtrace.c:15:19: note: expanded from macro 'M12' + // CHECK-NO-CARETS-NEXT: macro-backtrace.c:14:19: note: expanded from macro 'M11' + // CHECK-NO-CARETS-NEXT: macro-backtrace.c:13:19: note: expanded from macro 'M10' + // CHECK-NO-CARETS-NEXT: note: (skipping 6 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) + // CHECK-NO-CARETS-NEXT: macro-backtrace.c:6:18: note: expanded from macro 'M3' + // CHECK-NO-CARETS-NEXT: macro-backtrace.c:5:18: note: expanded from macro 'M2' + // CHECK-NO-CARETS-NEXT: macro-backtrace.c:4:23: note: expanded from macro 'M1' + + // Check that the expansion notes respect the same formatting options as + // other diagnostics. + // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-format vi %s 2>&1 \ + // RUN: | FileCheck %s -check-prefix=CHECK-NOTE-FORMAT + // CHECK-NOTE-FORMAT: macro-backtrace.c +18:7: warning: + // CHECK-NOTE-FORMAT: macro-backtrace.c +15:19: note: + // CHECK-NOTE-FORMAT: macro-backtrace.c +14:19: note: + // CHECK-NOTE-FORMAT: note: + // CHECK-NOTE-FORMAT: macro-backtrace.c +6:18: note: + // CHECK-NOTE-FORMAT: macro-backtrace.c +5:18: note: + // CHECK-NOTE-FORMAT: macro-backtrace.c +4:23: note: +} diff --git a/test/Misc/pubnames.c b/test/Misc/pubnames.c new file mode 100644 index 0000000000000..03048972c0021 --- /dev/null +++ b/test/Misc/pubnames.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -pubnames-dump %s | FileCheck %s +#define FOO +#define BAR +#undef FOO +#define WIBBLE + +int foo(); +int bar(float); +int wibble; + +// CHECK: BAR +// CHECK-NOT: FOO +// CHECK: WIBBLE +// CHECK-NOT: __clang_major__ +// CHECK: bar +// CHECK: foo +// CHECK: wibble + + diff --git a/test/Misc/serialized-diags-no-category.c b/test/Misc/serialized-diags-no-category.c new file mode 100644 index 0000000000000..3074892e0ebbb --- /dev/null +++ b/test/Misc/serialized-diags-no-category.c @@ -0,0 +1,12 @@ +#error foo +#error bar + +// RUN: rm -f %t +// RUN: %clang -ferror-limit=1 -fsyntax-only %s --serialize-diagnostics %t > /dev/null 2>&1 || true +// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s + +// This test case tests that we can handle both fatal errors and errors without categories. + +// CHECK: {{.*[/\\]}}serialized-diags-no-category.c:1:2: error: foo [] +// CHECK: Number of diagnostics: 2 + diff --git a/test/Misc/serialized-diags-no-issue.c b/test/Misc/serialized-diags-no-issue.c new file mode 100644 index 0000000000000..5c7da8267db9d --- /dev/null +++ b/test/Misc/serialized-diags-no-issue.c @@ -0,0 +1,10 @@ +void foo(); + +// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t +// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s +// RUN: rm -f %t + +// NOTE: it is important that this test case contains no issues. It tests +// that serialize diagnostics work in the absence of any issues. + +// CHECK: Number of diagnostics: 0 diff --git a/test/Misc/serialized-diags-single-issue.c b/test/Misc/serialized-diags-single-issue.c new file mode 100644 index 0000000000000..938dda3f0de77 --- /dev/null +++ b/test/Misc/serialized-diags-single-issue.c @@ -0,0 +1,36 @@ +void foo() { + int voodoo; + voodoo = voodoo + 1; +} + +// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t +// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s +// RUN: rm -f %t + +// NOTE: it is important that this test case only contain a single issue. This test case checks +// if we can handle serialized diagnostics that contain only one diagnostic. + +// CHECK: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] [Semantic Issue] +// CHECK: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18 +// CHECK: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning [] +// CHECK: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13 +// CHECK: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0" + +// Test that we handle serializing diagnostics for multiple source files +// RUN: %clang_cc1 -Wall -fsyntax-only %s %s -serialize-diagnostic-file %t +// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck -check-prefix=CHECK-MULT %s +// RUN: rm -f %t + +// CHECK-MULT: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] +// CHECK-MULT: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18 +// CHECK-MULT: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning [] +// CHECK-MULT: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13 +// CHECK-MULT: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0" + +// CHECK-MULT: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] +// CHECK-MULT: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18 +// CHECK-MULT: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning [] +// CHECK-MULT: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13 +// CHECK-MULT: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0" + +// CHECK-MULT: Number of diagnostics: 2 diff --git a/test/Misc/serialized-diags.c b/test/Misc/serialized-diags.c new file mode 100644 index 0000000000000..ae4611ba66722 --- /dev/null +++ b/test/Misc/serialized-diags.c @@ -0,0 +1,67 @@ +void foo() { + int voodoo; + voodoo = voodoo + 1; +} + +void bar() { + int dragon; + dragon = dragon + 1 +} + +// Test handling of FixIts that only remove text. +int baz(); +void qux(int x) { + if ((x == baz())) + return; +} + +// Test handling of macros. +void taz(int x, int y); +#define false 0 +void testMacro() { + taz(0, 0, false); +} + +// Test handling of issues from #includes. +#include "serialized-diags.h" + +// Test handling of warnings that have empty fixits. +void rdar11040133() { + unsigned x; +} + +// RUN: rm -f %t +// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.diag > /dev/null 2>&1 || true +// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1 +// RUN: FileCheck --input-file=%t %s + +// This test case tests that we can handle multiple diagnostics which contain +// FIXITs at different levels (one at the note, another at the main diagnostic). + +// CHECK: {{.*[/\\]}}serialized-diags.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] +// CHECK: Range: {{.*[/\\]}}serialized-diags.c:3:12 {{.*[/\\]}}serialized-diags.c:3:18 +// CHECK: +-{{.*[/\\]}}serialized-diags.c:2:13: note: initialize the variable 'voodoo' to silence this warning [] +// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:2:13 - {{.*[/\\]}}serialized-diags.c:2:13): " = 0" +// CHECK: {{.*[/\\]}}serialized-diags.c:8:22: error: expected ';' after expression [] +// CHECK: FIXIT: ({{.*[/\\]}}serialized-diags.c:8:22 - {{.*[/\\]}}serialized-diags.c:8:22): ";" +// CHECK: {{.*[/\\]}}serialized-diags.c:14:10: warning: equality comparison with extraneous parentheses [-Wparentheses-equality] +// CHECK: Range: {{.*[/\\]}}serialized-diags.c:14:8 {{.*[/\\]}}serialized-diags.c:14:18 +// CHECK: +-{{.*[/\\]}}serialized-diags.c:14:10: note: remove extraneous parentheses around the comparison to silence this warning [] +// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:7 - {{.*[/\\]}}serialized-diags.c:14:8): "" +// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:18 - {{.*[/\\]}}serialized-diags.c:14:19): "" +// CHECK: +-{{.*[/\\]}}serialized-diags.c:14:10: note: use '=' to turn this equality comparison into an assignment [] +// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:10 - {{.*[/\\]}}serialized-diags.c:14:12): "=" +// CHECK: {{.*[/\\]}}serialized-diags.c:22:13: error: too many arguments to function call, expected 2, have 3 [] +// CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:3 {{.*[/\\]}}serialized-diags.c:22:6 +// CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:13 {{.*[/\\]}}serialized-diags.c:22:18 +// CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 'false' [] +// CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:22:3 {{.*[/\\]}}serialized-diags.c:22:6 +// CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 {{.*[/\\]}}serialized-diags.c:20:16 +// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here [] +// CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion] +// CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 {{.*[/\\]}}serialized-diags.h:5:17 +// CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from {{.*[/\\]}}serialized-diags.c:26: [] +// CHECK: Number FIXITs = 0 +// CHECK: {{.*[/\\]}}serialized-diags.c:30:12: warning: unused variable 'x' +// CHECK: Number FIXITs = 0 +// CHECK: Number of diagnostics: 6 diff --git a/test/Misc/serialized-diags.h b/test/Misc/serialized-diags.h new file mode 100644 index 0000000000000..d38a3521caffe --- /dev/null +++ b/test/Misc/serialized-diags.h @@ -0,0 +1,5 @@ +// This file intentionally has a bug. It is intended +// to be used with serialized-diagnostics.c to show +// how errors are handled with #includes in serialized +// diagnostics. +char *badStr = 1; diff --git a/test/Misc/warn-in-system-header.c b/test/Misc/warn-in-system-header.c index 7e4615e65efa2..6e0237d0dcdc2 100644 --- a/test/Misc/warn-in-system-header.c +++ b/test/Misc/warn-in-system-header.c @@ -1,4 +1,4 @@ // RUN: %clang_cc1 -isystem %S %s -fsyntax-only -verify #include <warn-in-system-header.h> -// expected-warning {{#warning}} +// expected-warning {{the cake is a lie}} diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c index 2f7103ab1cd2b..bc0c941bd99d1 100644 --- a/test/Misc/warning-flags.c +++ b/test/Misc/warning-flags.c @@ -17,28 +17,14 @@ This test serves two purposes: The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (297): -CHECK-NEXT: backslash_newline_space -CHECK-NEXT: charize_microsoft_ext -CHECK-NEXT: ext_anon_param_requires_type_specifier +CHECK: Warnings without flags (253): CHECK-NEXT: ext_anonymous_struct_union_qualified -CHECK-NEXT: ext_array_init_copy -CHECK-NEXT: ext_auto_storage_class CHECK-NEXT: ext_binary_literal -CHECK-NEXT: ext_c99_array_usage -CHECK-NEXT: ext_c99_compound_literal -CHECK-NEXT: ext_c99_variable_decl_in_for_loop -CHECK-NEXT: ext_c99_whitespace_required_after_macro_name CHECK-NEXT: ext_cast_fn_obj -CHECK-NEXT: ext_catch_incomplete_ptr -CHECK-NEXT: ext_catch_incomplete_ref CHECK-NEXT: ext_delete_void_ptr_operand CHECK-NEXT: ext_designated_init -CHECK-NEXT: ext_designated_init_cxx -CHECK-NEXT: ext_dollar_in_identifier CHECK-NEXT: ext_duplicate_declspec CHECK-NEXT: ext_ellipsis_exception_spec -CHECK-NEXT: ext_embedded_directive CHECK-NEXT: ext_empty_fnmacro_arg CHECK-NEXT: ext_empty_source_file CHECK-NEXT: ext_enum_friend @@ -47,11 +33,8 @@ CHECK-NEXT: ext_enumerator_list_comma CHECK-NEXT: ext_expected_semi_decl_list CHECK-NEXT: ext_explicit_instantiation_without_qualified_id CHECK-NEXT: ext_explicit_specialization_storage_class -CHECK-NEXT: ext_expr_not_ice CHECK-NEXT: ext_extra_ivar_semi CHECK-NEXT: ext_extra_struct_semi -CHECK-NEXT: ext_flexible_array_in_array -CHECK-NEXT: ext_flexible_array_in_struct CHECK-NEXT: ext_forward_ref_enum CHECK-NEXT: ext_freestanding_complex CHECK-NEXT: ext_hexconstant_invalid @@ -68,15 +51,12 @@ CHECK-NEXT: ext_missing_varargs_arg CHECK-NEXT: ext_missing_whitespace_after_macro_name CHECK-NEXT: ext_new_paren_array_nonconst CHECK-NEXT: ext_nonstandard_escape -CHECK-NEXT: ext_offsetof_extended_field_designator CHECK-NEXT: ext_param_not_declared -CHECK-NEXT: ext_param_promoted_not_compatible_with_prototype CHECK-NEXT: ext_paste_comma CHECK-NEXT: ext_plain_complex CHECK-NEXT: ext_pp_bad_vaargs_use CHECK-NEXT: ext_pp_comma_expr CHECK-NEXT: ext_pp_ident_directive -CHECK-NEXT: ext_pp_import_directive CHECK-NEXT: ext_pp_include_next_directive CHECK-NEXT: ext_pp_line_too_big CHECK-NEXT: ext_pp_macro_redef @@ -96,8 +76,6 @@ CHECK-NEXT: ext_typecheck_comparison_of_pointer_integer CHECK-NEXT: ext_typecheck_cond_incompatible_operands CHECK-NEXT: ext_typecheck_cond_incompatible_operands_nonstandard CHECK-NEXT: ext_typecheck_cond_one_void -CHECK-NEXT: ext_typecheck_convert_int_pointer -CHECK-NEXT: ext_typecheck_convert_pointer_int CHECK-NEXT: ext_typecheck_convert_pointer_void_func CHECK-NEXT: ext_typecheck_ordered_comparison_of_function_pointers CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_and_zero @@ -106,9 +84,6 @@ CHECK-NEXT: ext_typecheck_zero_array_size CHECK-NEXT: ext_unknown_escape CHECK-NEXT: ext_using_undefined_std CHECK-NEXT: ext_vla_folded_to_constant -CHECK-NEXT: null_in_char -CHECK-NEXT: null_in_file -CHECK-NEXT: null_in_string CHECK-NEXT: pp_include_next_absolute_path CHECK-NEXT: pp_include_next_in_primary CHECK-NEXT: pp_invalid_string_literal @@ -126,7 +101,6 @@ CHECK-NEXT: warn_attribute_iboutlet CHECK-NEXT: warn_attribute_ignored CHECK-NEXT: warn_attribute_ignored_for_field_of_type CHECK-NEXT: warn_attribute_malloc_pointer_only -CHECK-NEXT: warn_attribute_method_def CHECK-NEXT: warn_attribute_nonnull_no_pointers CHECK-NEXT: warn_attribute_precede_definition CHECK-NEXT: warn_attribute_sentinel_named_arguments @@ -145,7 +119,6 @@ CHECK-NEXT: warn_bad_receiver_type CHECK-NEXT: warn_bitfield_width_exceeds_type_size CHECK-NEXT: warn_bool_switch_condition CHECK-NEXT: warn_braces_around_scalar_init -CHECK-NEXT: warn_builtin_unknown CHECK-NEXT: warn_c_kext CHECK-NEXT: warn_call_to_pure_virtual_member_function_from_ctor_dtor CHECK-NEXT: warn_call_wrong_number_of_arguments @@ -161,24 +134,18 @@ CHECK-NEXT: warn_conv_to_base_not_used CHECK-NEXT: warn_conv_to_self_not_used CHECK-NEXT: warn_conv_to_void_not_used CHECK-NEXT: warn_cxx0x_right_shift_in_template_arg -CHECK-NEXT: warn_decl_in_param_list CHECK-NEXT: warn_delete_array_type -CHECK-NEXT: warn_delete_incomplete CHECK-NEXT: warn_division_by_zero CHECK-NEXT: warn_double_const_requires_fp64 CHECK-NEXT: warn_drv_assuming_mfloat_abi_is CHECK-NEXT: warn_drv_clang_unsupported -CHECK-NEXT: warn_drv_conflicting_deployment_targets CHECK-NEXT: warn_drv_input_file_unused CHECK-NEXT: warn_drv_not_using_clang_arch CHECK-NEXT: warn_drv_not_using_clang_cpp CHECK-NEXT: warn_drv_not_using_clang_cxx CHECK-NEXT: warn_drv_objc_gc_unsupported CHECK-NEXT: warn_drv_pch_not_first_include -CHECK-NEXT: warn_drv_pipe_ignored_with_save_temps CHECK-NEXT: warn_drv_preprocessed_input_file_unused -CHECK-NEXT: warn_drv_unsupported_option_argument -CHECK-NEXT: warn_drv_unused_argument CHECK-NEXT: warn_dup_category_def CHECK-NEXT: warn_duplicate_protocol_def CHECK-NEXT: warn_enum_too_large @@ -201,8 +168,6 @@ CHECK-NEXT: warn_hex_escape_too_large CHECK-NEXT: warn_ignoring_ftabstop_value CHECK-NEXT: warn_illegal_constant_array_size CHECK-NEXT: warn_implements_nscopying -CHECK-NEXT: warn_implicit_decl_requires_setjmp -CHECK-NEXT: warn_implicit_decl_requires_stdio CHECK-NEXT: warn_incompatible_qualified_id CHECK-NEXT: warn_initializer_string_for_char_array_too_long CHECK-NEXT: warn_inline_namespace_reopened_noninline @@ -211,7 +176,6 @@ CHECK-NEXT: warn_instance_method_on_class_found CHECK-NEXT: warn_integer_too_large CHECK-NEXT: warn_integer_too_large_for_signed CHECK-NEXT: warn_invalid_asm_cast_lvalue -CHECK-NEXT: warn_label_attribute_not_unused CHECK-NEXT: warn_many_braces_around_scalar_init CHECK-NEXT: warn_maynot_respond CHECK-NEXT: warn_member_extra_qualification @@ -236,7 +200,6 @@ CHECK-NEXT: warn_octal_escape_too_large CHECK-NEXT: warn_odr_tag_type_inconsistent CHECK-NEXT: warn_on_superclass_use CHECK-NEXT: warn_param_default_argument_redefinition -CHECK-NEXT: warn_parens_disambiguated_as_function_decl CHECK-NEXT: warn_partial_specs_not_deducible CHECK-NEXT: warn_pointer_attribute_wrong_type CHECK-NEXT: warn_pp_convert_lhs_to_positive @@ -258,7 +221,6 @@ CHECK-NEXT: warn_pragma_options_align_unsupported_option CHECK-NEXT: warn_pragma_options_expected_align CHECK-NEXT: warn_pragma_pack_invalid_action CHECK-NEXT: warn_pragma_pack_invalid_alignment -CHECK-NEXT: warn_pragma_pack_invalid_constant CHECK-NEXT: warn_pragma_pack_malformed CHECK-NEXT: warn_pragma_pack_pop_failed CHECK-NEXT: warn_pragma_pack_pop_identifer_and_alignment @@ -286,8 +248,6 @@ CHECK-NEXT: warn_remainder_by_zero CHECK-NEXT: warn_root_inst_method_not_found CHECK-NEXT: warn_second_parameter_of_va_start_not_last_named_argument CHECK-NEXT: warn_second_parameter_to_va_arg_never_compatible -CHECK-NEXT: warn_setter_getter_impl_required -CHECK-NEXT: warn_setter_getter_impl_required_in_category CHECK-NEXT: warn_standalone_specifier CHECK-NEXT: warn_static_inline_explicit_inst_ignored CHECK-NEXT: warn_static_non_static @@ -298,16 +258,12 @@ CHECK-NEXT: warn_transparent_union_attribute_field_size_align CHECK-NEXT: warn_transparent_union_attribute_floating CHECK-NEXT: warn_transparent_union_attribute_not_definition CHECK-NEXT: warn_transparent_union_attribute_zero_fields -CHECK-NEXT: warn_transparent_union_nonpointer CHECK-NEXT: warn_typecheck_function_qualifiers -CHECK-NEXT: warn_ucn_escape_too_large -CHECK-NEXT: warn_ucn_not_valid_in_c89 CHECK-NEXT: warn_unavailable_fwdclass_message CHECK-NEXT: warn_undef_interface CHECK-NEXT: warn_undef_interface_suggest CHECK-NEXT: warn_undef_protocolref CHECK-NEXT: warn_undefined_internal -CHECK-NEXT: warn_uninit_val CHECK-NEXT: warn_unknown_analyzer_checker CHECK-NEXT: warn_unknown_method_family CHECK-NEXT: warn_unterminated_char |