diff options
Diffstat (limited to 'test/Misc')
-rw-r--r-- | test/Misc/caret-diags-macros.c | 26 | ||||
-rw-r--r-- | test/Misc/caret-diags-scratch-buffer.c | 12 | ||||
-rw-r--r-- | test/Misc/diag-checker.c | 5 | ||||
-rw-r--r-- | test/Misc/diag-mapping.c | 30 | ||||
-rw-r--r-- | test/Misc/diag-mapping2.c | 19 | ||||
-rw-r--r-- | test/Misc/emit-html-insert.c | 4 | ||||
-rw-r--r-- | test/Misc/emit-html.c | 18 | ||||
-rw-r--r-- | test/Misc/message-length.c | 35 | ||||
-rw-r--r-- | test/Misc/predefines.c | 5 |
9 files changed, 154 insertions, 0 deletions
diff --git a/test/Misc/caret-diags-macros.c b/test/Misc/caret-diags-macros.c new file mode 100644 index 0000000..58d293f --- /dev/null +++ b/test/Misc/caret-diags-macros.c @@ -0,0 +1,26 @@ +// RUN: clang-cc -fsyntax-only %s > %t 2>&1 && + +#define M1(x) x + +// RUN: grep ":6:12: note: instantiated from:" %t && +#define M2 1; + +void foo() { + // RUN: grep ":10:2: warning: expression result unused" %t && + M1( + // RUN: grep ":12:5: note: instantiated from:" %t && + M2) +} + +// RUN: grep ":16:11: note: instantiated from:" %t && +#define A 1 +// RUN: grep ":18:11: note: instantiated from:" %t && +#define B A +// RUN: grep ":20:11: note: instantiated from:" %t && +#define C B + +void bar() { + // RUN: grep ":24:3: warning: expression result unused" %t + C; +} + diff --git a/test/Misc/caret-diags-scratch-buffer.c b/test/Misc/caret-diags-scratch-buffer.c new file mode 100644 index 0000000..e339d56 --- /dev/null +++ b/test/Misc/caret-diags-scratch-buffer.c @@ -0,0 +1,12 @@ +// RUN: clang-cc -fsyntax-only %s 2>&1 | not grep keyXXXX +// This should not show keyXXXX in the caret diag output. This once +// happened because the two tokens ended up in the scratch buffer and +// the caret diag from the scratch buffer included the previous token. +#define M(name) \ + if (name ## XXXX != name ## _sb); + +void foo() { + int keyXXXX; + M(key); +} + diff --git a/test/Misc/diag-checker.c b/test/Misc/diag-checker.c new file mode 100644 index 0000000..4733ee1 --- /dev/null +++ b/test/Misc/diag-checker.c @@ -0,0 +1,5 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +#include <stdio.h> + +void foo(FILE *FP) {} diff --git a/test/Misc/diag-mapping.c b/test/Misc/diag-mapping.c new file mode 100644 index 0000000..dc07e0d --- /dev/null +++ b/test/Misc/diag-mapping.c @@ -0,0 +1,30 @@ +// This should warn by default. +// RUN: clang-cc %s 2>&1 | grep "warning:" && +// This should not emit anything. +// RUN: clang-cc %s -Wno-extra-tokens 2>&1 | not grep diagnostic && + +// -Werror can map all warnings to error. +// RUN: clang-cc %s -Werror 2>&1 | grep "error:" && + +// -Werror can map this one warning to error. +// RUN: clang-cc %s -Werror=extra-tokens 2>&1 | grep "error:" && + +// Mapping unrelated diags to errors doesn't affect this one. +// RUN: clang-cc %s -Werror=trigraphs 2>&1 | grep "warning:" && + +// This should stay a warning with -pedantic. +// RUN: clang-cc %s -pedantic 2>&1 | grep "warning:" && + +// This should emit an error with -pedantic-errors. +// RUN: clang-cc %s -pedantic-errors 2>&1 | grep "error:" && + +// This should emit a warning, because -Wfoo overrides -pedantic*. +// RUN: clang-cc %s -pedantic-errors -Wextra-tokens 2>&1 | grep "warning:" && + +// This should emit nothing, because -Wno-extra-tokens overrides -pedantic* +// RUN: clang-cc %s -pedantic-errors -Wno-extra-tokens 2>&1 | not grep diagnostic + +#ifdef foo +#endif bad // extension! + +int x; diff --git a/test/Misc/diag-mapping2.c b/test/Misc/diag-mapping2.c new file mode 100644 index 0000000..7e0d774 --- /dev/null +++ b/test/Misc/diag-mapping2.c @@ -0,0 +1,19 @@ +// This should warn by default. +// RUN: clang-cc %s 2>&1 | grep "warning:" && + +// This should not emit anything. +// RUN: clang-cc %s -w 2>&1 | not grep diagnostic && +// RUN: clang-cc %s -Wno-#warnings 2>&1 | not grep diagnostic && + +// -Werror can map all warnings to error. +// RUN: clang-cc %s -Werror 2>&1 | grep "error:" && + +// -Werror can map this one warning to error. +// RUN: clang-cc %s -Werror=#warnings 2>&1 | grep "error:" && + +// -Wno-error= overrides -Werror. rdar://3158301 +// RUN: clang-cc %s -Werror -Wno-error=#warnings 2>&1 | grep "warning:" + +#warning foo + + diff --git a/test/Misc/emit-html-insert.c b/test/Misc/emit-html-insert.c new file mode 100644 index 0000000..ac6b519 --- /dev/null +++ b/test/Misc/emit-html-insert.c @@ -0,0 +1,4 @@ +// RUN: clang-cc %s -emit-html -o - | grep ">< 10; }" + +int a(int x) { return x +< 10; } diff --git a/test/Misc/emit-html.c b/test/Misc/emit-html.c new file mode 100644 index 0000000..22d0d28 --- /dev/null +++ b/test/Misc/emit-html.c @@ -0,0 +1,18 @@ +// RUN: clang-cc %s -emit-html -o - + +// rdar://6562329 +#line 42 "foo.c" + +// PR3635 +#define F(fmt, ...) fmt, ## __VA_ARGS__ +int main(int argc, char **argv) { + return F(argc, 1); +} + +// PR3798 +#define FOR_ALL_FILES(f,i) i + +#if 0 + FOR_ALL_FILES(f) { } +#endif + diff --git a/test/Misc/message-length.c b/test/Misc/message-length.c new file mode 100644 index 0000000..ac5dab9 --- /dev/null +++ b/test/Misc/message-length.c @@ -0,0 +1,35 @@ +// RUN: clang -fsyntax-only -fmessage-length=72 %s 2> %t && + +// RUN: grep -A4 "FILE:23" %t > %t.msg && +// FIXME: This diagnostic is getting truncated very poorly. +// RUN: grep -e '^ ...// some long comment text and a brace, eh {} ' %t.msg && +// RUN: grep -e '^ \^' %t.msg && +// RUN: clang -fsyntax-only -fmessage-length=1 %s && +// RUN: true + +// Hack so we can check things better, force the file name and line. + +# 1 "FILE" 1 + +/* It's tough to verify the results of this test mechanically, since + the length of the filename (and, therefore, how the word-wrapping + behaves) changes depending on where the test-suite resides in the + file system. */ +void f(int, float, char, float); + +void g() { + int (*fp1)(int, float, short, float) = f; + + int (*fp2)(int, float, short, float) = f; +} + +void a_func_to_call(int, int, int); + +void a_very_long_line(int *ip, float *FloatPointer) { + for (int ALongIndexName = 0; ALongIndexName < 100; ALongIndexName++) if (ip[ALongIndexName] == 17) a_func_to_call(ip == FloatPointer, ip[ALongIndexName], FloatPointer[ALongIndexName]); + + + int array0[] = { [3] 3, 5, 7, 4, 2, 7, 6, 3, 4, 5, 6, 7, 8, 9, 12, 345, 14, 345, 789, 234, 678, 345, 123, 765, 234 }; +} + +#pragma STDC CX_LIMITED_RANGE // some long comment text and a brace, eh {} diff --git a/test/Misc/predefines.c b/test/Misc/predefines.c new file mode 100644 index 0000000..c7fac86 --- /dev/null +++ b/test/Misc/predefines.c @@ -0,0 +1,5 @@ +/* RUN: clang-cc -fsyntax-only -verify -std=c89 -pedantic-errors %s + * rdar://6814950 + */ +#include <stdint.h> + |