OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / cpp / charconst.c
1 /* Copyright (C) 2001 Free Software Foundation, Inc.  */
2
3 /* { dg-do compile } */
4
5 /* This tests various diagnostics about character constants, for both
6    the preprocessor and the compiler.
7
8    Neil Booth, 22 May 2001.  */
9
10 #if ''                  /* { dg-warning "empty" "empty charconst" } */
11 #endif
12 #if L''                 /* { dg-warning "empty" "empty wide charconst" } */
13 #endif
14 #if 'very long'         /* { dg-warning "too long" "long charconst" } */
15 #endif
16 #if L'very long'        /* { dg-warning "too long" "long wide charconst" } */
17 #endif
18 /* Don't do this test for L'ab'; it depends upon sizeof (wchar_t).  */
19 #if 'ab'                /* { dg-warning "multi-char" "multi-character" } */
20 #endif
21
22 void foo ()
23 {
24   int c;
25   __WCHAR_TYPE__ w;
26
27   c = '';               /* { dg-warning "empty" "empty charconst" } */
28   w = L'';              /* { dg-warning "empty" "empty wide charconst" } */
29
30   c = 'very long';      /* { dg-warning "too long" "long charconst" } */
31   w = L'very long';     /* { dg-warning "too long" "long wide charconst" } */
32
33   c = 'ab';             /* { dg-warning "multi-char" "multi-char" } */
34   /* Wide charconsts cannot contain more than one wide character.  */
35   w = L'ab';            /* { dg-warning "too long" "multi-char wide" } */
36 }