blob: 9c84ddc0192950c56e5c590ec5774eaf2f9693aa [file] [log] [blame]
Stephen Hines0e2c34f2015-03-23 12:09:02 -07001// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -ftrigraphs %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
Eli Friedmanb3da6132013-07-23 00:25:18 +000016#if -01000000000000000000000 // should not warn.
17#endif
Stephen Hines176edba2014-12-01 14:53:08 -080018#if 9223372036854775808 // expected-warning {{integer literal is too large to be represented in a signed integer type, interpreting as unsigned}}
Eli Friedmanb3da6132013-07-23 00:25:18 +000019#endif
Stephen Hines176edba2014-12-01 14:53:08 -080020#if 0x10000000000000000 // expected-error {{integer literal is too large to be represented in any integer type}}
Eli Friedmanb3da6132013-07-23 00:25:18 +000021#endif
Chris Lattnerb77f41e2009-04-28 18:52:02 +000022
John McCall091f23f2010-11-09 22:22:12 +000023int c[] = {
Chris Lattnere3ad8812009-04-28 21:51:46 +000024 'df', // expected-warning {{multi-character character constant}}
Chris Lattnerb77f41e2009-04-28 18:52:02 +000025 '\t',
26 '\\
27t',
Chris Lattnere3ad8812009-04-28 21:51:46 +000028 '??!', // expected-warning {{trigraph converted to '|' character}}
29 'abcd' // expected-warning {{multi-character character constant}}
Chris Lattnerb77f41e2009-04-28 18:52:02 +000030};
31
Chris Lattnerd80f7862010-07-07 23:24:27 +000032// PR4499
33int m0 = '0';
34int m1 = '\\\''; // expected-warning {{multi-character character constant}}
35int m2 = '\\\\'; // expected-warning {{multi-character character constant}}
36int m3 = '\\\
37';
38
Chris Lattnerb77f41e2009-04-28 18:52:02 +000039
Chris Lattnere8fa06e2009-05-12 18:21:11 +000040#pragma clang diagnostic ignored "-Wmultichar"
Chris Lattnerb77f41e2009-04-28 18:52:02 +000041
John McCall091f23f2010-11-09 22:22:12 +000042int d = 'df'; // no warning.
43int e = 'abcd'; // still warn: expected-warning {{multi-character character constant}}
Chris Lattnere3ad8812009-04-28 21:51:46 +000044
Chris Lattnere8fa06e2009-05-12 18:21:11 +000045#pragma clang diagnostic ignored "-Wfour-char-constants"
Chris Lattnere3ad8812009-04-28 21:51:46 +000046
John McCall091f23f2010-11-09 22:22:12 +000047int f = 'abcd'; // ignored.
John McCall94c939d2009-12-24 09:08:04 +000048
49// rdar://problem/6974641
50float t0[] = {
51 1.9e20f,
52 1.9e-20f,
John McCall2a0d7572010-02-26 23:35:57 +000053 1.9e50f, // expected-warning {{too large}}
54 1.9e-50f, // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000055 -1.9e20f,
56 -1.9e-20f,
John McCall2a0d7572010-02-26 23:35:57 +000057 -1.9e50f, // expected-warning {{too large}}
58 -1.9e-50f // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000059};
60double t1[] = {
61 1.9e50,
62 1.9e-50,
John McCall2a0d7572010-02-26 23:35:57 +000063 1.9e500, // expected-warning {{too large}}
64 1.9e-500, // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000065 -1.9e50,
66 -1.9e-50,
John McCall2a0d7572010-02-26 23:35:57 +000067 -1.9e500, // expected-warning {{too large}}
68 -1.9e-500 // expected-warning {{too small}}
John McCall94c939d2009-12-24 09:08:04 +000069};
Eli Friedman295a6372010-08-19 19:13:24 +000070
71// PR7888
72double g = 1e100000000; // expected-warning {{too large}}
Craig Topper0473cd52011-08-19 03:20:12 +000073
Seth Cantrell7748cbc2012-01-18 12:27:10 +000074char h = '\u1234'; // expected-error {{character too large for enclosing character literal type}}