Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -trigraphs %s |
Chris Lattner | 136f93a | 2007-07-16 06:55:01 +0000 | [diff] [blame] | 2 | |
Chris Lattner | 2dec3a1 | 2009-04-28 18:43:12 +0000 | [diff] [blame] | 3 | int x = 000000080; // expected-error {{invalid digit}} |
Chris Lattner | 136f93a | 2007-07-16 06:55:01 +0000 | [diff] [blame] | 4 | |
| 5 | int y = 0000\ |
Chris Lattner | 2dec3a1 | 2009-04-28 18:43:12 +0000 | [diff] [blame] | 6 | 00080; // expected-error {{invalid digit}} |
Chris Lattner | 136f93a | 2007-07-16 06:55:01 +0000 | [diff] [blame] | 7 | |
Chris Lattner | 2dec3a1 | 2009-04-28 18:43:12 +0000 | [diff] [blame] | 8 | |
| 9 | |
| 10 | float X = 1.17549435e-38F; |
| 11 | float Y = 08.123456; |
| 12 | |
| 13 | // PR2252 |
| 14 | #if -0x8000000000000000 // should not warn. |
| 15 | #endif |
Chris Lattner | b77f41e | 2009-04-28 18:52:02 +0000 | [diff] [blame] | 16 | |
| 17 | |
John McCall | 091f23f | 2010-11-09 22:22:12 +0000 | [diff] [blame] | 18 | int c[] = { |
Chris Lattner | e3ad881 | 2009-04-28 21:51:46 +0000 | [diff] [blame] | 19 | 'df', // expected-warning {{multi-character character constant}} |
Chris Lattner | b77f41e | 2009-04-28 18:52:02 +0000 | [diff] [blame] | 20 | '\t', |
| 21 | '\\ |
| 22 | t', |
Chris Lattner | e3ad881 | 2009-04-28 21:51:46 +0000 | [diff] [blame] | 23 | '??!', // expected-warning {{trigraph converted to '|' character}} |
| 24 | 'abcd' // expected-warning {{multi-character character constant}} |
Chris Lattner | b77f41e | 2009-04-28 18:52:02 +0000 | [diff] [blame] | 25 | }; |
| 26 | |
Chris Lattner | d80f786 | 2010-07-07 23:24:27 +0000 | [diff] [blame] | 27 | // PR4499 |
| 28 | int m0 = '0'; |
| 29 | int m1 = '\\\''; // expected-warning {{multi-character character constant}} |
| 30 | int m2 = '\\\\'; // expected-warning {{multi-character character constant}} |
| 31 | int m3 = '\\\ |
| 32 | '; |
| 33 | |
Chris Lattner | b77f41e | 2009-04-28 18:52:02 +0000 | [diff] [blame] | 34 | |
Chris Lattner | e8fa06e | 2009-05-12 18:21:11 +0000 | [diff] [blame] | 35 | #pragma clang diagnostic ignored "-Wmultichar" |
Chris Lattner | b77f41e | 2009-04-28 18:52:02 +0000 | [diff] [blame] | 36 | |
John McCall | 091f23f | 2010-11-09 22:22:12 +0000 | [diff] [blame] | 37 | int d = 'df'; // no warning. |
| 38 | int e = 'abcd'; // still warn: expected-warning {{multi-character character constant}} |
Chris Lattner | e3ad881 | 2009-04-28 21:51:46 +0000 | [diff] [blame] | 39 | |
Chris Lattner | e8fa06e | 2009-05-12 18:21:11 +0000 | [diff] [blame] | 40 | #pragma clang diagnostic ignored "-Wfour-char-constants" |
Chris Lattner | e3ad881 | 2009-04-28 21:51:46 +0000 | [diff] [blame] | 41 | |
John McCall | 091f23f | 2010-11-09 22:22:12 +0000 | [diff] [blame] | 42 | int f = 'abcd'; // ignored. |
John McCall | 94c939d | 2009-12-24 09:08:04 +0000 | [diff] [blame] | 43 | |
| 44 | // rdar://problem/6974641 |
| 45 | float t0[] = { |
| 46 | 1.9e20f, |
| 47 | 1.9e-20f, |
John McCall | 2a0d757 | 2010-02-26 23:35:57 +0000 | [diff] [blame] | 48 | 1.9e50f, // expected-warning {{too large}} |
| 49 | 1.9e-50f, // expected-warning {{too small}} |
John McCall | 94c939d | 2009-12-24 09:08:04 +0000 | [diff] [blame] | 50 | -1.9e20f, |
| 51 | -1.9e-20f, |
John McCall | 2a0d757 | 2010-02-26 23:35:57 +0000 | [diff] [blame] | 52 | -1.9e50f, // expected-warning {{too large}} |
| 53 | -1.9e-50f // expected-warning {{too small}} |
John McCall | 94c939d | 2009-12-24 09:08:04 +0000 | [diff] [blame] | 54 | }; |
| 55 | double t1[] = { |
| 56 | 1.9e50, |
| 57 | 1.9e-50, |
John McCall | 2a0d757 | 2010-02-26 23:35:57 +0000 | [diff] [blame] | 58 | 1.9e500, // expected-warning {{too large}} |
| 59 | 1.9e-500, // expected-warning {{too small}} |
John McCall | 94c939d | 2009-12-24 09:08:04 +0000 | [diff] [blame] | 60 | -1.9e50, |
| 61 | -1.9e-50, |
John McCall | 2a0d757 | 2010-02-26 23:35:57 +0000 | [diff] [blame] | 62 | -1.9e500, // expected-warning {{too large}} |
| 63 | -1.9e-500 // expected-warning {{too small}} |
John McCall | 94c939d | 2009-12-24 09:08:04 +0000 | [diff] [blame] | 64 | }; |
Eli Friedman | 295a637 | 2010-08-19 19:13:24 +0000 | [diff] [blame] | 65 | |
| 66 | // PR7888 |
| 67 | double g = 1e100000000; // expected-warning {{too large}} |
Craig Topper | 0473cd5 | 2011-08-19 03:20:12 +0000 | [diff] [blame] | 68 | |
Seth Cantrell | 7748cbc | 2012-01-18 12:27:10 +0000 | [diff] [blame] | 69 | char h = '\u1234'; // expected-error {{character too large for enclosing character literal type}} |