Convert Preprocessor Clang tests to FileCheck in regards to PR5307.

llvm-svn: 85199
This commit is contained in:
Edward O'Callaghan 2009-10-27 02:36:32 +00:00
parent a5ae75425d
commit f78edf52de
10 changed files with 73 additions and 44 deletions

View File

@ -1,10 +1,5 @@
// Example from C99 6.10.3.4p5
// RUN: clang-cc -E %s | grep -F 'f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);' &&
// RUN: clang-cc -E %s | grep -F 'f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);' &&
// RUN: clang-cc -E %s | grep -F 'int i[] = { 1, 23, 4, 5, };' &&
// RUN: clang-cc -E %s | grep -F 'char c[2][6] = { "hello", "" };'
// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s
#define x 3
#define f(a) f(x * (a))
@ -26,4 +21,8 @@
p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
char c[2][6] = { str(hello), str() };
// CHECK: f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);
// CHECK: f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);
// CHECK: int i[] = { 1, 23, 4, 5, };
// CHECK: char c[2][6] = { "hello", "" };

View File

@ -1,10 +1,6 @@
// Example from C99 6.10.3.4p6
// RUN: clang-cc -E %s | grep -F 'printf("x" "1" "= %d, x" "2" "= s" x1, x2);' &&
// RUN: clang-cc -E %s | grep 'fputs("strncmp(\\"abc\\\\0d\\" \\"abc\\", .\\\\4.) == 0" ": @\\n", s);' &&
// RUN: clang-cc -E %s | grep -F 'include "vers2.h"' &&
// RUN: clang-cc -E %s | grep -F '"hello";' &&
// RUN: clang-cc -E %s | grep -F '"hello" ", world"'
// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s
#define str(s) # s
#define xstr(s) str(s)
@ -22,3 +18,10 @@ include xstr(INCFILE(2).h)
glue(HIGH, LOW);
xglue(HIGH, LOW)
// CHECK: printf("x" "1" "= %d, x" "2" "= s" x1, x2);
// CHECK: fputs("strncmp(\"abc\\0d\" \"abc\", '\\4') == 0" ": @\n", s);
// CHECK: include "vers2.h"
// CHECK: "hello";
// CHECK: "hello" ", world"

View File

@ -1,9 +1,10 @@
// Example from C99 6.10.3.4p7
// RUN: clang-cc -E %s | grep -F 'int j[] = { 123, 45, 67, 89,' &&
// RUN: clang-cc -E %s | grep -F '10, 11, 12, };'
// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s
#define t(x,y,z) x ## y ## z
int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
t(10,,), t(,11,), t(,,12), t(,,) };
// CHECK: int j[] = { 123, 45, 67, 89,
// CHECK: 10, 11, 12, };

View File

@ -1,16 +1,20 @@
// Example from C99 6.10.3.4p9
// RUN: clang-cc -E %s | grep -F 'fprintf(stderr, "Flag");' &&
// RUN: clang-cc -E %s | grep -F 'fprintf(stderr, "X = %d\n", x);' &&
// RUN: clang-cc -E %s | grep -F 'puts("The first, second, and third items.");' &&
// RUN: clang-cc -E %s | grep -F '((x>y)?puts("x>y"): printf("x is %d but y is %d", x, y));'
// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define showlist(...) puts(#__VA_ARGS__)
#define report(test, ...) ((test)?puts(#test):\
printf(__VA_ARGS__))
debug("Flag");
debug("X = %d\n", x);
showlist(The first, second, and third items.);
report(x>y, "x is %d but y is %d", x, y);
// CHECK: fprintf(stderr, "Flag");
debug("X = %d\n", x);
// CHECK: fprintf(stderr, "X = %d\n", x);
showlist(The first, second, and third items.);
// CHECK: puts("The first, second, and third items.");
report(x>y, "x is %d but y is %d", x, y);
// CHECK: ((x>y)?puts("x>y"): printf("x is %d but y is %d", x, y));

View File

@ -1,7 +1,8 @@
// RUN: clang-cc -E -C %s | grep '^// foo$' &&
// RUN: clang-cc -E -C %s | grep -F '^/* bar */$'
// RUN: clang-cc -E -C %s | FileCheck -strict-whitespace %s
// foo
// CHECK: // foo
/* bar */
// CHECK: /* bar */

View File

@ -1,6 +1,11 @@
// RUN: clang-cc -E -C %s | grep '^boo bork bar // zot$' &&
// RUN: clang-cc -E -CC %s | grep -F '^boo bork /* blah*/ bar // zot$' &&
// RUN: clang-cc -E %s | grep '^boo bork bar$'
// RUN: clang-cc -E -C %s | FileCheck -strict-whitespace %s
// CHECK: boo bork bar // zot
// RUN: clang-cc -E -CC %s | FileCheck -strict-whitespace %s
// CHECK: boo bork /* blah*/ bar // zot
// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s
// CHECK: boo bork bar
#define FOO bork // blah

View File

@ -1,5 +1,4 @@
// RUN: clang-cc -P -E -fms-extensions %s | sed '/^#.\+/d' | tr -d '\n' > %t &&
// RUN: grep '^int foo;int bar;int baz;$' %t | count 1
// RUN: clang-cc -P -E -fms-extensions %s | FileCheck -strict-whitespace %s
// This horrible stuff should preprocess into (other than whitespace):
// int foo;
// int bar;
@ -7,14 +6,21 @@
int foo;
// CHECK: int foo;
#define comment /##/ dead tokens live here
comment This is stupidity
int bar;
// CHECK: int bar;
#define nested(x) int x comment cute little dead tokens...
nested(baz) rise of the dead tokens
;
// CHECK: int baz
// CHECK: ;

View File

@ -1,5 +1,5 @@
// RUN: clang-cc -E %s | grep -F "1: F, (, 'a', 'b', );" &&
// RUN: clang-cc -E %s | grep -F "2: 'a' + 'b';"
// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s
#define LPAREN (
#define RPAREN )
#define F(x, y) x + y
@ -8,3 +8,6 @@
1: ELLIP_FUNC(F, LPAREN, 'a', 'b', RPAREN); /* 1st invocation */
2: ELLIP_FUNC(F LPAREN 'a', 'b' RPAREN); /* 2nd invocation */
// CHECK: 1: F, (, 'a', 'b', );
// CHECK: 2: 'a' + 'b';

View File

@ -1,23 +1,26 @@
// RUN: clang-cc -E %s -o %t &&
// This should print as ".. ." to avoid turning into ...
// RUN: grep -F 'A: . . .' %t &&
// RUN: clang-cc -E %s -o %t | FileCheck -strict-whitespace %s
#define y(a) ..a
A: y(.)
// This should print as ".. ." to avoid turning into ...
// CHECK: A: . . .
// RUN: grep -F 'C: .. .' %t &&
#define DOT .
C: ..DOT
// CHECK: C: .. .
// RUN: grep -F 'D: + + - - + + = = =' %t &&
#define PLUS +
#define EMPTY
#define f(x) =x=
D: +PLUS -EMPTY- PLUS+ f(=)
// CHECK: D: + + - - + + = = =
// RUN: grep -F 'E: L "str"' %t
// Should expand to L "str" not L"str"
#define test(x) L#x
E: test(str)
// Should expand to L "str" not L"str"
// CHECK: E: L "str"

View File

@ -1,20 +1,23 @@
// RUN: clang-cc -E %s | grep -F '"f(1, 2)" "g((x=y++, y))"' &&
// RUN: clang-cc -E %s | grep -F '"{a=1" "b=2;}"' &&
// RUN: clang-cc -E %s | grep -F '"<" "["' &&
// RUN: clang-cc -E %s | grep -F '"(,)" "(...)"' &&
// RUN: clang-cc -E %s | grep -F '{a=1 c=3; b=2;}' &&
// RUN: clang-cc -E %s | grep -F '"a COMMA b" "(a, b)"'
// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s
#define M(x, y) #x #y
M( f(1, 2), g((x=y++, y)))
// CHECK: "f(1, 2)" "g((x=y++, y))"
M( {a=1 , b=2;} ) /* A semicolon is not a comma */
// CHECK: "{a=1" "b=2;}"
M( <, [ ) /* Passes the arguments < and [ */
// CHECK: "<" "["
M( (,), (...) ) /* Passes the arguments (,) and (...) */
// CHECK: "(,)" "(...)"
#define START_END(start, end) start c=3; end
START_END( {a=1 , b=2;} ) /* braces are not parentheses */
// CHECK: {a=1 c=3; b=2;}
/*
* To pass a comma token as an argument it is
@ -23,4 +26,5 @@ START_END( {a=1 , b=2;} ) /* braces are not parentheses */
#define COMMA ,
M(a COMMA b, (a, b))
// CHECK: "a COMMA b" "(a, b)"