File: hexfloat.cpp

package info (click to toggle)
llvm-toolchain-7 1%3A7.0.1-8
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 733,456 kB
  • sloc: cpp: 3,776,651; ansic: 633,271; asm: 350,301; python: 142,716; objc: 107,612; sh: 22,626; lisp: 11,056; perl: 7,999; pascal: 6,742; ml: 5,537; awk: 3,536; makefile: 2,557; cs: 2,027; xml: 841; ruby: 156
file content (31 lines) | stat: -rw-r--r-- 1,438 bytes parent folder | download | duplicates (28)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -pedantic %s
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify -pedantic %s
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify -pedantic %s
double e = 0x.p0; // expected-error-re {{hexadecimal floating {{constant|literal}} requires a significand}}

float f = 0x1p+1;
double d = 0x.2p2;
float g = 0x1.2p2;
double h = 0x1.p2;
#if __cplusplus <= 201402L
// expected-warning@-5 {{hexadecimal floating literals are a C++17 feature}}
// expected-warning@-5 {{hexadecimal floating literals are a C++17 feature}}
// expected-warning@-5 {{hexadecimal floating literals are a C++17 feature}}
// expected-warning@-5 {{hexadecimal floating literals are a C++17 feature}}
#endif

// PR12717: In order to minimally diverge from the C++ standard, we do not lex
// 'p[+-]' as part of a pp-number unless the token starts 0x and doesn't contain
// an underscore.
double i = 0p+3; // expected-error {{invalid suffix 'p' on integer constant}}
#define PREFIX(x) foo ## x
double foo0p = 1, j = PREFIX(0p+3); // ok
double k = 0x42_amp+3;
#if __cplusplus > 201402L
// expected-error@-2 {{no matching literal operator for call to 'operator""_amp+3'}}
#elif __cplusplus >= 201103L
// expected-error@-4 {{no matching literal operator for call to 'operator""_amp'}}
#else
// expected-error@-6 {{invalid suffix '_amp' on integer constant}}
#endif