1 /* Copyright (C) 2000 Free Software Foundation, Inc. */
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)
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
21 int main (int argc
, char *argv
[])
23 str (\
); /* { dg-warning "valid string" "str(\\)" } */
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__"))
34 if (strcmp(str(), "") || strcmp(str( ), ""))
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"))