PR c/56980
[official-gcc.git] / gcc / testsuite / gcc.dg / cpp / escape-1.c
blob0f5c11e9ab3dda2285e8db8026d89c0e60e1f389
1 /* Copyright (C) 2001 Free Software Foundation, Inc. */
3 /* { dg-do compile } */
5 /* This tests various diagnostics about escape sequences, for both
6 the preprocessor and the compiler.
8 Neil Booth, 22 May 2001. */
10 #if '\x' /* { dg-error "no following" "\x with no digits" } */
11 #endif
12 #if '\x400' /* { dg-error "out of range" "\x out of range" } */
13 #endif
14 #if '\x0ff' /* { dg-bogus "out of range" "\x out of range" } */
15 #endif
16 #if '\400' /* { dg-error "out of range" "\x out of range" } */
17 #endif
18 #if '\377' /* { dg-bogus "out of range" "bogus \x out of range" } */
19 #endif
20 #if '\177' != 0x7f /* { dg-bogus "out of range" "bogus \x out of range" } */
21 #error bad octal /* { dg-bogus "bad" "bad octal evaluation" } */
22 #endif
23 #if '\0377' /* { dg-warning "multi" "too long octal" } */
24 #endif
25 #if '\p' /* { dg-error "unknown escape" "unknown escape seq" } */
26 #endif
28 void foo ()
30 int c;
32 c = '\x'; /* { dg-error "no following" "\x with no digits" } */
33 c = '\x100'; /* { dg-error "out of range" "\x out of range" } */
34 c = '\x0ff'; /* { dg-bogus "out of range" "\x out of range" } */
35 c = '\400'; /* { dg-error "out of range" "\x out of range" } */
36 c = '\377'; /* { dg-bogus "out of range" "bogus \x out of range" } */
37 c = '\0377'; /* { dg-warning "multi" "too long octal" } */
38 c = '\p'; /* { dg-error "unknown escape" "unknown escape seq" } */