blob: fc7253e50499b41432d2d3157a81371da66cb4a4 [file] [log] [blame]
Andy Gibbs6f8cfccb2016-04-01 19:02:20 +00001#ifdef TEST1
2// RUN: %clang_cc1 -E %s -DTEST1 | FileCheck -strict-whitespace %s
Chris Lattner022b62e2006-07-30 07:20:09 +00003
4#define M(x, y) #x #y
5
6M( f(1, 2), g((x=y++, y)))
Edward O'Callaghanf78edf52009-10-27 02:36:32 +00007// CHECK: "f(1, 2)" "g((x=y++, y))"
8
Chris Lattner022b62e2006-07-30 07:20:09 +00009M( {a=1 , b=2;} ) /* A semicolon is not a comma */
Edward O'Callaghanf78edf52009-10-27 02:36:32 +000010// CHECK: "{a=1" "b=2;}"
11
Chris Lattner022b62e2006-07-30 07:20:09 +000012M( <, [ ) /* Passes the arguments < and [ */
Edward O'Callaghanf78edf52009-10-27 02:36:32 +000013// CHECK: "<" "["
14
Chris Lattner022b62e2006-07-30 07:20:09 +000015M( (,), (...) ) /* Passes the arguments (,) and (...) */
Edward O'Callaghanf78edf52009-10-27 02:36:32 +000016// CHECK: "(,)" "(...)"
Chris Lattner022b62e2006-07-30 07:20:09 +000017
18#define START_END(start, end) start c=3; end
19
20START_END( {a=1 , b=2;} ) /* braces are not parentheses */
Edward O'Callaghanf78edf52009-10-27 02:36:32 +000021// CHECK: {a=1 c=3; b=2;}
Chris Lattner022b62e2006-07-30 07:20:09 +000022
23/*
24 * To pass a comma token as an argument it is
25 * necessary to write:
26 */
27#define COMMA ,
28
29M(a COMMA b, (a, b))
Edward O'Callaghanf78edf52009-10-27 02:36:32 +000030// CHECK: "a COMMA b" "(a, b)"
Chris Lattner022b62e2006-07-30 07:20:09 +000031
Andy Gibbs6f8cfccb2016-04-01 19:02:20 +000032#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