Fix type in the changelog entry,
[official-gcc.git] / gcc / testsuite / gcc.dg / cpp / lexstrng.c
blob9e13cd5fa336327eb0ecce59fe4204bc4ccd72ec
1 /* Copyright (C) 2000 Free Software Foundation, Inc. */
3 /* { dg-do run } */
4 /* { dg-options "-trigraphs" } */
6 /* Test lexing of strings and character constants. */
8 #ifndef __WCHAR_TYPE__
9 #define __WCHAR_TYPE__ int
10 #endif
11 typedef __WCHAR_TYPE__ wchar_t;
13 extern int strcmp (const char *, const char *);
14 #if DEBUG
15 extern int puts (const char *);
16 #else
17 #define puts(X)
18 #endif
19 extern void abort (void);
20 #define err(str) do { puts(str); abort(); } while (0)
22 /* Escaped newlines. */
23 const char *str1 = "s\
26 r??/
27 1";
29 const char x = '\
30 ??/
31 b';
33 /* Test escaped terminators. */
34 const char *term = "\"\\\"\\";
35 const char termc = '\'';
36 const char *terms = "'";
38 /* Test wide strings and chars are lexed. */
39 const wchar_t wchar = L'w';
40 const wchar_t* wstring = L"wide string";
42 /* Test all 9 trigraphs embedded in a string. Test trigraphs do not
43 survive an embedded backslash newline. Test trigraphs preceded by
44 a '?' are still noticed. */
45 const char *t = "??/\??<??>??=??)??\
46 (??(??!??'??-???=???/
47 ?-";
49 int main (int argc, char *argv[])
51 if (strcmp (str1, "str 1"))
52 err ("str1");
54 if (x != 'b')
55 err ("b");
57 /* We have to split the string up to avoid trigraph replacement
58 here. Split the 2 trigraphs after both 1 and 2 ?s; just doing
59 this exposed a bug in the initial release of the tokenized lexer. */
60 if (strcmp (t, "\\{}#]?" "?([|^~?#??" "-"))
61 err ("Embedded trigraphs");
63 if (term[0] != '"' || term[1] != '\\' || term[2] != '"'
64 || term[3] != '\\' || term[4] != '\0')
65 err ("Escaped string terminators");
67 if (termc != terms[0])
68 err ("Escaped character constant terminator");
70 return 0;