Debian Codegraph @

gcc/testsuite/gcc.dg/cpp/trad/macroargs.c

raw
1 /* Test that whitespace in arguments is preserved, and that each
2 newline in macro arguments become a space. */
3
4 /* { dg-do run } */
5
6 #define f(x, y) "x y"
7 #define g(x) x
8
9 extern void abort (void);
10 extern int strcmp (const char *, const char *);
11
12 void testquoting ()
13 {
14 const char *str1 = f("a", "\"a\"");
15 const char *str2 = f( \t, " \t");
16
17 if (strcmp (str1, "\"a\" \"\\\"a\\\"\""))
18 abort ();
19 if (strcmp (str2, " \t \" \\t\""))
20 abort ();
21 }
22
23 int main ()
24 {
25 const char *str1 = f( foo ,bar);
26 const char *str2 = f(
27 foo
28 ,bar);
29
30 if (strcmp (str1, " foo bar"))
31 abort ();
32
33 if (strcmp (str1, str2))
34 abort ();
35
36 /* Verify that quoted state is preserved over a newline. */
37 if (strcmp (g /* { dg-bogus "unterminated 2" } */ ("1
38 , 2"), "1 , 2"))
39 abort ();
40
41 testquoting ();
42
43 return 0;
44 }