blob: 3241751a1233a1737733deef64044c2e0fd6c101 [file] [log] [blame]
Richard Smith560a3572016-03-04 22:32:06 +00001// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -pedantic %s
Douglas Gregor227c3522011-10-12 18:51:02 +00002// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s
Richard Smith560a3572016-03-04 22:32:06 +00003// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify -pedantic %s
Richard Smithcbaaa292017-08-13 22:26:53 +00004// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -pedantic %s
Richard Smith560a3572016-03-04 22:32:06 +00005double e = 0x.p0; // expected-error-re {{hexadecimal floating {{constant|literal}} requires a significand}}
6
7float f = 0x1p+1;
8double d = 0x.2p2;
9float g = 0x1.2p2;
10double h = 0x1.p2;
11#if __cplusplus <= 201402L
Richard Smithcbaaa292017-08-13 22:26:53 +000012// 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 Smith560a3572016-03-04 22:32:06 +000016#endif
Richard Smithe6799dd2012-06-15 05:07:49 +000017
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 Smith560a3572016-03-04 22:32:06 +000021double i = 0p+3; // expected-error {{invalid suffix 'p' on integer constant}}
Richard Smithe6799dd2012-06-15 05:07:49 +000022#define PREFIX(x) foo ## x
23double foo0p = 1, j = PREFIX(0p+3); // ok
Richard Smith560a3572016-03-04 22:32:06 +000024double 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