xref: /aosp_15_r20/external/clang/test/Lexer/hexfloat.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -pedantic %s
2*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s
3*67e74705SXin Li // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify -pedantic %s
4*67e74705SXin Li // RUN: %clang_cc1 -std=c++1z -fsyntax-only -verify -pedantic %s
5*67e74705SXin Li double e = 0x.p0; // expected-error-re {{hexadecimal floating {{constant|literal}} requires a significand}}
6*67e74705SXin Li 
7*67e74705SXin Li float f = 0x1p+1;
8*67e74705SXin Li double d = 0x.2p2;
9*67e74705SXin Li float g = 0x1.2p2;
10*67e74705SXin Li double h = 0x1.p2;
11*67e74705SXin Li #if __cplusplus <= 201402L
12*67e74705SXin Li // expected-warning@-5 {{hexadecimal floating literals are a C++1z feature}}
13*67e74705SXin Li // expected-warning@-5 {{hexadecimal floating literals are a C++1z feature}}
14*67e74705SXin Li // expected-warning@-5 {{hexadecimal floating literals are a C++1z feature}}
15*67e74705SXin Li // expected-warning@-5 {{hexadecimal floating literals are a C++1z feature}}
16*67e74705SXin Li #endif
17*67e74705SXin Li 
18*67e74705SXin Li // PR12717: In order to minimally diverge from the C++ standard, we do not lex
19*67e74705SXin Li // 'p[+-]' as part of a pp-number unless the token starts 0x and doesn't contain
20*67e74705SXin Li // an underscore.
21*67e74705SXin Li double i = 0p+3; // expected-error {{invalid suffix 'p' on integer constant}}
22*67e74705SXin Li #define PREFIX(x) foo ## x
23*67e74705SXin Li double foo0p = 1, j = PREFIX(0p+3); // ok
24*67e74705SXin Li double k = 0x42_amp+3;
25*67e74705SXin Li #if __cplusplus > 201402L
26*67e74705SXin Li // expected-error@-2 {{no matching literal operator for call to 'operator""_amp+3'}}
27*67e74705SXin Li #elif __cplusplus >= 201103L
28*67e74705SXin Li // expected-error@-4 {{no matching literal operator for call to 'operator""_amp'}}
29*67e74705SXin Li #else
30*67e74705SXin Li // expected-error@-6 {{invalid suffix '_amp' on integer constant}}
31*67e74705SXin Li #endif
32