Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gcc4 / gcc / testsuite / gcc.dg / cpp / strify2.c
blob2c768dcd05ec8ab3df510e3bc0f2a35a4a7cfef5
1 /* Copyright (C) 2000 Free Software Foundation, Inc. */
3 /* { dg-do run } */
4 /* { dg-options "-std=c99 -pedantic-errors -fno-show-column" } */
6 /* Tests a whole bunch of things are correctly stringified. */
8 extern int strcmp (const char *, const char *);
9 extern int puts (const char *);
10 extern void abort (void);
11 #define err(str) do { puts(str); abort(); } while (0)
13 #define str(x) #x
14 #define xstr(x) str(x)
15 #define strvar(...) #__VA_ARGS__
17 #define glibc_str(x) glibc_str2 (w, x)
18 #define glibc_str2(w, x) #x
19 #define ver GLIBC_2.2
21 int main (int argc, char *argv[])
23 str (\); /* { dg-warning "valid string" "str(\\)" } */
24 str (\\); /* OK. */
25 str (\\\); /* { dg-warning "valid string" "str(\\\\\\)" } */
27 /* This also serves as a useful test of the value of __INCLUDE_LEVEL. */
28 if (strcmp (xstr (__INCLUDE_LEVEL__), "0"))
29 err ("macro expansion");
31 if (strcmp(str (__INCLUDE_LEVEL__), "__INCLUDE_LEVEL__"))
32 err ("macro name");
34 if (strcmp(str(), "") || strcmp(str( ), ""))
35 err ("empty string");
37 if (strcmp(str ("s\n"), "\"s\\n\""))
38 err ("quoted string");
40 if (strcmp (str (a € b), "a \200 b"))
41 err ("unprintable char");
43 if (strcmp (str ( a b@ c ), "a b@ c"))
44 err ("internal whitespace");
46 if (strcmp (str(a \n), "a \n"))
47 err ("backslash token");
49 if (strcmp (strvar (foo, bar), "foo, bar"))
50 err ("variable arguments");
52 if (strcmp (glibc_str (ver), "GLIBC_2.2"))
53 err ("whitespace");
55 return 0;