FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / gcc.dg / cpp / lexnum.c
blob7df15540833a7f69bf895139a14a4cd3d7c2d071
1 /* Copyright (C) 2000 Free Software Foundation, Inc. */
3 /* { dg-do run } */
4 /* { dg-options "-trigraphs" } */
6 /* Test lexing of numbers. */
8 extern int puts (const char *);
9 extern void abort (void);
10 #define err(str) do { puts(str); abort(); } while (0)
12 /* Escaped newlines. */
13 #define foo 12\
16 4??/
19 #if foo != 12345
20 #error foo
21 #endif
23 int main (int argc, char *argv[])
25 double a = 5.;
26 double x = .5;
28 /* Decimal points, including initially and immediately before and
29 after an escaped newline. */
30 if (a != 5)
31 err ("a");
32 if (x != .\
34 err ("x != .5");
35 x = 25\
38 if (x != 25.6)
39 err ("x != 25.6");
41 /* Test exponentials and their signs. A buggy lexer is more likely
42 to fail the compile, but never mind. */
43 if (250 != 25e+1 || 250 != 25e1 || 250 != 2500e-1)
44 err ("exponentials");
46 /* Todo: p exponentials, and how to test preprocessing number
47 tokenisation? */
49 return 0;