blob: b833e7b43f4717ac87ebd15b201b728b0f26a403 [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
18char 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
27
Chris Lattnere8fa06e2009-05-12 18:21:11 +000028#pragma clang diagnostic ignored "-Wmultichar"
Chris Lattnerb77f41e2009-04-28 18:52:02 +000029
30char d = 'df'; // no warning.
Chris Lattnere3ad8812009-04-28 21:51:46 +000031char e = 'abcd'; // still warn: expected-warning {{multi-character character constant}}
32
Chris Lattnere8fa06e2009-05-12 18:21:11 +000033#pragma clang diagnostic ignored "-Wfour-char-constants"
Chris Lattnere3ad8812009-04-28 21:51:46 +000034
35char f = 'abcd'; // ignored.
John McCall94c939d2009-12-24 09:08:04 +000036
37// rdar://problem/6974641
38float t0[] = {
39 1.9e20f,
40 1.9e-20f,
John McCall2a0d7572010-02-26 23:35:57 +000041 1.9e50f, // expected-warning {{too large}}
42 1.9e-50f, // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000043 -1.9e20f,
44 -1.9e-20f,
John McCall2a0d7572010-02-26 23:35:57 +000045 -1.9e50f, // expected-warning {{too large}}
46 -1.9e-50f // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000047};
48double t1[] = {
49 1.9e50,
50 1.9e-50,
John McCall2a0d7572010-02-26 23:35:57 +000051 1.9e500, // expected-warning {{too large}}
52 1.9e-500, // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000053 -1.9e50,
54 -1.9e-50,
John McCall2a0d7572010-02-26 23:35:57 +000055 -1.9e500, // expected-warning {{too large}}
56 -1.9e-500 // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000057};