Richard Smith | 560a357 | 2016-03-04 22:32:06 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -pedantic %s |
Douglas Gregor | 227c352 | 2011-10-12 18:51:02 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s |
Richard Smith | 560a357 | 2016-03-04 22:32:06 +0000 | [diff] [blame] | 3 | // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify -pedantic %s |
Richard Smith | cbaaa29 | 2017-08-13 22:26:53 +0000 | [diff] [blame] | 4 | // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -pedantic %s |
Richard Smith | 560a357 | 2016-03-04 22:32:06 +0000 | [diff] [blame] | 5 | double e = 0x.p0; // expected-error-re {{hexadecimal floating {{constant|literal}} requires a significand}} |
| 6 | |
| 7 | float f = 0x1p+1; |
| 8 | double d = 0x.2p2; |
| 9 | float g = 0x1.2p2; |
| 10 | double h = 0x1.p2; |
| 11 | #if __cplusplus <= 201402L |
Richard Smith | cbaaa29 | 2017-08-13 22:26:53 +0000 | [diff] [blame] | 12 | // expected-warning@-5 {{hexadecimal floating literals are a C++17 feature}} |
| 13 | // expected-warning@-5 {{hexadecimal floating literals are a C++17 feature}} |
| 14 | // expected-warning@-5 {{hexadecimal floating literals are a C++17 feature}} |
| 15 | // expected-warning@-5 {{hexadecimal floating literals are a C++17 feature}} |
Richard Smith | 560a357 | 2016-03-04 22:32:06 +0000 | [diff] [blame] | 16 | #endif |
Richard Smith | e6799dd | 2012-06-15 05:07:49 +0000 | [diff] [blame] | 17 | |
| 18 | // PR12717: In order to minimally diverge from the C++ standard, we do not lex |
| 19 | // 'p[+-]' as part of a pp-number unless the token starts 0x and doesn't contain |
| 20 | // an underscore. |
Richard Smith | 560a357 | 2016-03-04 22:32:06 +0000 | [diff] [blame] | 21 | double i = 0p+3; // expected-error {{invalid suffix 'p' on integer constant}} |
Richard Smith | e6799dd | 2012-06-15 05:07:49 +0000 | [diff] [blame] | 22 | #define PREFIX(x) foo ## x |
| 23 | double foo0p = 1, j = PREFIX(0p+3); // ok |
Richard Smith | 560a357 | 2016-03-04 22:32:06 +0000 | [diff] [blame] | 24 | double k = 0x42_amp+3; |
| 25 | #if __cplusplus > 201402L |
| 26 | // expected-error@-2 {{no matching literal operator for call to 'operator""_amp+3'}} |
| 27 | #elif __cplusplus >= 201103L |
| 28 | // expected-error@-4 {{no matching literal operator for call to 'operator""_amp'}} |
| 29 | #else |
| 30 | // expected-error@-6 {{invalid suffix '_amp' on integer constant}} |
| 31 | #endif |