blob: 013103b1f5dd94b63515d5eab14c9a98560fae23 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -trigraphs %s
Chris Lattner136f93a2007-07-16 06:55:01 +00002
Chris Lattner2dec3a12009-04-28 18:43:12 +00003int x = 000000080; // expected-error {{invalid digit}}
Chris Lattner136f93a2007-07-16 06:55:01 +00004
5int y = 0000\
Chris Lattner2dec3a12009-04-28 18:43:12 +0000600080; // expected-error {{invalid digit}}
Chris Lattner136f93a2007-07-16 06:55:01 +00007
Chris Lattner2dec3a12009-04-28 18:43:12 +00008
9
10float X = 1.17549435e-38F;
11float Y = 08.123456;
12
13// PR2252
14#if -0x8000000000000000 // should not warn.
15#endif
Chris Lattnerb77f41e2009-04-28 18:52:02 +000016
17
John McCall091f23f2010-11-09 22:22:12 +000018int c[] = {
Chris Lattnere3ad8812009-04-28 21:51:46 +000019 'df', // expected-warning {{multi-character character constant}}
Chris Lattnerb77f41e2009-04-28 18:52:02 +000020 '\t',
21 '\\
22t',
Chris Lattnere3ad8812009-04-28 21:51:46 +000023 '??!', // expected-warning {{trigraph converted to '|' character}}
24 'abcd' // expected-warning {{multi-character character constant}}
Chris Lattnerb77f41e2009-04-28 18:52:02 +000025};
26
Chris Lattnerd80f7862010-07-07 23:24:27 +000027// PR4499
28int m0 = '0';
29int m1 = '\\\''; // expected-warning {{multi-character character constant}}
30int m2 = '\\\\'; // expected-warning {{multi-character character constant}}
31int m3 = '\\\
32';
33
Chris Lattnerb77f41e2009-04-28 18:52:02 +000034
Chris Lattnere8fa06e2009-05-12 18:21:11 +000035#pragma clang diagnostic ignored "-Wmultichar"
Chris Lattnerb77f41e2009-04-28 18:52:02 +000036
John McCall091f23f2010-11-09 22:22:12 +000037int d = 'df'; // no warning.
38int e = 'abcd'; // still warn: expected-warning {{multi-character character constant}}
Chris Lattnere3ad8812009-04-28 21:51:46 +000039
Chris Lattnere8fa06e2009-05-12 18:21:11 +000040#pragma clang diagnostic ignored "-Wfour-char-constants"
Chris Lattnere3ad8812009-04-28 21:51:46 +000041
John McCall091f23f2010-11-09 22:22:12 +000042int f = 'abcd'; // ignored.
John McCall94c939d2009-12-24 09:08:04 +000043
44// rdar://problem/6974641
45float t0[] = {
46 1.9e20f,
47 1.9e-20f,
John McCall2a0d7572010-02-26 23:35:57 +000048 1.9e50f, // expected-warning {{too large}}
49 1.9e-50f, // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000050 -1.9e20f,
51 -1.9e-20f,
John McCall2a0d7572010-02-26 23:35:57 +000052 -1.9e50f, // expected-warning {{too large}}
53 -1.9e-50f // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000054};
55double t1[] = {
56 1.9e50,
57 1.9e-50,
John McCall2a0d7572010-02-26 23:35:57 +000058 1.9e500, // expected-warning {{too large}}
59 1.9e-500, // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000060 -1.9e50,
61 -1.9e-50,
John McCall2a0d7572010-02-26 23:35:57 +000062 -1.9e500, // expected-warning {{too large}}
63 -1.9e-500 // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000064};
Eli Friedman295a6372010-08-19 19:13:24 +000065
66// PR7888
67double g = 1e100000000; // expected-warning {{too large}}
Craig Topper0473cd52011-08-19 03:20:12 +000068
69char h = '\u1234'; // expected-warning {{character unicode escape sequence too long for its type}}