1 /* Copyright (C) 2000 Free Software Foundation, Inc. */
4 /* { dg-options "-trigraphs" } */
6 /* Test lexing of strings and character constants. */
9 #define __WCHAR_TYPE__ int
11 typedef __WCHAR_TYPE__
wchar_t;
13 extern int strcmp (const char *, const char *);
14 extern int puts (const char *);
15 extern void abort (void);
16 #define err(str) do { puts(str); abort(); } while (0)
18 /* Escaped newlines. */
19 const char *str1
= "s\
29 /* Test escaped terminators. */
30 const char *term
= "\"\\\"\\";
31 const char termc
= '\'';
32 const char *terms
= "'";
34 /* Test wide strings and chars are lexed. */
35 const wchar_t wchar
= L
'w';
36 const wchar_t* wstring
= L
"wide string";
38 /* Test all 9 trigraphs embedded in a string. Test trigraphs do not
39 survive an embedded backslash newline. Test trigraphs preceded by
40 a '?' are still noticed. */
41 const char *t
= "??/\??<??>??=??)??\
45 int main (int argc
, char *argv
[])
47 if (strcmp (str1
, "str 1"))
53 /* We have to split the string up to avoid trigraph replacement
54 here. Split the 2 trigraphs after both 1 and 2 ?s; just doing
55 this exposed a bug in the initial release of the tokenized lexer. */
56 if (strcmp (t
, "\\{}#]?" "?([|^~?#??" "-"))
57 err ("Embedded trigraphs");
59 if (term
[0] != '"' || term
[1] != '\\' || term
[2] != '"'
60 || term
[3] != '\\' || term
[4] != '\0')
61 err ("Escaped string terminators");
63 if (termc
!= terms
[0])
64 err ("Escaped character constant terminator");