• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifdef TEST1
2 // RUN: %clang_cc1 -E %s -DTEST1 | FileCheck -strict-whitespace %s
3 
4 #define M(x, y) #x #y
5 
6 M( f(1, 2), g((x=y++, y)))
7 // CHECK: "f(1, 2)" "g((x=y++, y))"
8 
9 M( {a=1 , b=2;} ) /* A semicolon is not a comma */
10 // CHECK: "{a=1" "b=2;}"
11 
12 M( <, [ ) /* Passes the arguments < and [ */
13 // CHECK: "<" "["
14 
15 M( (,), (...) ) /* Passes the arguments (,) and (...) */
16 // CHECK: "(,)" "(...)"
17 
18 #define START_END(start, end) start c=3; end
19 
20 START_END( {a=1 , b=2;} ) /* braces are not parentheses */
21 // CHECK: {a=1 c=3; b=2;}
22 
23 /*
24  * To pass a comma token as an argument it is
25  * necessary to write:
26  */
27 #define COMMA ,
28 
29 M(a COMMA b, (a, b))
30 // CHECK: "a COMMA b" "(a, b)"
31 
32 #endif
33 
34 #ifdef TEST2
35 // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST2
36 
37 #define HASH #
38 #define INVALID() #
39 // expected-error@-1{{'#' is not followed by a macro parameter}}
40 
41 #endif
42