File tree 11 files changed +64
-37
lines changed 11 files changed +64
-37
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ typedef float _Float32;
3
3
typedef double _Float32x ;
4
4
typedef double _Float64 ;
5
5
typedef long double _Float64x ;
6
+ typedef long double _Float128 ;
6
7
typedef long double _Float128x ;
7
8
8
9
// But this type should:
9
- _Float128 f128 ;
10
+ __float128 f128 ;
Original file line number Diff line number Diff line change @@ -5,3 +5,5 @@ _Float64 f64;
5
5
_Float64x f64x ;
6
6
_Float128 f128 ;
7
7
_Float128x f128x ;
8
+
9
+ __float128 gcc_f128 ;
Original file line number Diff line number Diff line change 1
- #if defined(__GNUC__ ) && !defined( __clang__ )
1
+ #if defined(__GNUC__ )
2
2
3
- #include <features.h> // For __GNUC_PREREQ
3
+ # ifdef __clang__
4
4
5
- #ifdef __x86_64__
6
- #define FLOAT128_MINOR_VERSION 3
7
- #else
8
- #define FLOAT128_MINOR_VERSION 5
9
- #endif
5
+ # define HAS_FLOAT128
10
6
11
- #if __GNUC__ >= 7
12
- #define HAS_FLOATN
13
- #elif __GNUC_PREREQ (4 , FLOAT128_MINOR_VERSION )
14
- #define HAS_FLOAT128
15
- #endif
7
+ # else
8
+
9
+ # include <features.h> // For __GNUC_PREREQ
10
+
11
+ # ifdef __x86_64__
12
+ # define FLOAT128_MINOR_VERSION 3
13
+ # else
14
+ # define FLOAT128_MINOR_VERSION 5
15
+ # endif
16
+
17
+ # if __GNUC__ >= 7
18
+ # define HAS_FLOATN
19
+ # endif
20
+
21
+ # if __GNUC_PREREQ (4 , FLOAT128_MINOR_VERSION )
22
+ # define HAS_FLOAT128
23
+ # endif
24
+
25
+ # endif
16
26
17
27
#endif
18
28
19
- #ifndef HAS_FLOATN
29
+ #ifdef HAS_FLOATN
30
+ typedef _Float32 f1 ;
31
+ typedef _Float32x f2 ;
32
+ typedef _Float64 f3 ;
33
+ typedef _Float64x f4 ;
34
+ typedef _Float128 f5 ;
35
+ typedef _Float128x f6 ;
36
+ #else
20
37
typedef float _Float32 ;
21
38
typedef double _Float32x ;
22
39
typedef double _Float64 ;
23
40
typedef long double _Float64x ;
41
+ typedef long double _Float128 ;
24
42
typedef long double _Float128x ;
25
43
#endif
26
44
27
- #if !defined(HAS_FLOATN ) && !defined(HAS_FLOAT128 )
28
- typedef long double _Float128 ;
45
+ #if defined(HAS_FLOAT128 )
46
+ typedef __float128 f7 ;
47
+ #else
48
+ typedef long double __float128 ;
29
49
#endif
30
50
31
51
int main (int argc , char * * argv ) {
Original file line number Diff line number Diff line change @@ -208,8 +208,12 @@ void ansi_c_internal_additions(std::string &code)
208
208
// https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
209
209
// For clang, __float128 is a keyword.
210
210
// For gcc, this is a typedef and not a keyword.
211
- if (config.ansi_c .mode != configt::ansi_ct::flavourt::CLANG)
211
+ if (
212
+ config.ansi_c .mode != configt::ansi_ct::flavourt::CLANG &&
213
+ config.ansi_c .gcc__float128_type )
214
+ {
212
215
code += " typedef " CPROVER_PREFIX " Float128 __float128;\n " ;
216
+ }
213
217
}
214
218
else if (config.ansi_c .arch == " ppc64le" )
215
219
{
@@ -222,8 +226,12 @@ void ansi_c_internal_additions(std::string &code)
222
226
// https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
223
227
// For clang, __float128 is a keyword.
224
228
// For gcc, this is a typedef and not a keyword.
225
- if (config.ansi_c .mode != configt::ansi_ct::flavourt::CLANG)
229
+ if (
230
+ config.ansi_c .mode != configt::ansi_ct::flavourt::CLANG &&
231
+ config.ansi_c .gcc__float128_type )
232
+ {
226
233
code+=" typedef long double __float128;\n " ;
234
+ }
227
235
}
228
236
229
237
if (
Original file line number Diff line number Diff line change @@ -76,7 +76,6 @@ bool ansi_c_languaget::parse(
76
76
ansi_c_parser.set_message_handler (get_message_handler ());
77
77
ansi_c_parser.for_has_scope =config.ansi_c .for_has_scope ;
78
78
ansi_c_parser.ts_18661_3_Floatn_types =config.ansi_c .ts_18661_3_Floatn_types ;
79
- ansi_c_parser.Float128_type = config.ansi_c .Float128_type ;
80
79
ansi_c_parser.cpp98 =false ; // it's not C++
81
80
ansi_c_parser.cpp11 =false ; // it's not C++
82
81
ansi_c_parser.mode =config.ansi_c .mode ;
Original file line number Diff line number Diff line change @@ -28,16 +28,15 @@ class ansi_c_parsert:public parsert
28
28
public:
29
29
ansi_c_parse_treet parse_tree;
30
30
31
- ansi_c_parsert ():
32
- tag_following (false ),
33
- asm_block_following (false ),
34
- parenthesis_counter (0 ),
35
- mode (modet::NONE),
36
- cpp98 (false ),
37
- cpp11 (false ),
38
- for_has_scope (false ),
39
- ts_18661_3_Floatn_types(false ),
40
- Float128_type(false )
31
+ ansi_c_parsert ()
32
+ : tag_following(false ),
33
+ asm_block_following (false ),
34
+ parenthesis_counter(0 ),
35
+ mode(modet::NONE),
36
+ cpp98(false ),
37
+ cpp11(false ),
38
+ for_has_scope(false ),
39
+ ts_18661_3_Floatn_types(false )
41
40
{
42
41
}
43
42
@@ -84,9 +83,6 @@ class ansi_c_parsert:public parsert
84
83
// ISO/IEC TS 18661-3:2015
85
84
bool ts_18661_3_Floatn_types;
86
85
87
- // Does the compiler version emulated provide _Float128?
88
- bool Float128_type;
89
-
90
86
typedef ansi_c_identifiert identifiert;
91
87
typedef ansi_c_scopet scopet;
92
88
Original file line number Diff line number Diff line change @@ -565,7 +565,7 @@ void ansi_c_scanner_init()
565
565
return make_identifier ();
566
566
}
567
567
568
- " _Float128" { if (PARSER.Float128_type )
568
+ " _Float128" { if (PARSER.ts_18661_3_Floatn_types )
569
569
{ loc (); return TOK_GCC_FLOAT128; }
570
570
else
571
571
return make_identifier ();
Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ bool cpp_parsert::parse()
25
25
config.cpp .cpp_standard ==configt::cppt::cpp_standardt::CPP11 ||
26
26
config.cpp .cpp_standard ==configt::cppt::cpp_standardt::CPP14;
27
27
ansi_c_parser.ts_18661_3_Floatn_types =false ;
28
- ansi_c_parser.Float128_type = false ;
29
28
ansi_c_parser.in =in;
30
29
ansi_c_parser.mode =mode;
31
30
ansi_c_parser.set_file (get_file ());
Original file line number Diff line number Diff line change @@ -539,7 +539,9 @@ int gcc_modet::doit()
539
539
const auto gcc_float128_minor_version =
540
540
config.ansi_c .arch == " x86_64" ? 3u : 5u ;
541
541
542
- config.ansi_c .Float128_type =
542
+ // __float128 exists (as a typedef) since gcc 4.5 everywhere,
543
+ // and since 4.3 on x86_64
544
+ config.ansi_c .gcc__float128_type =
543
545
gcc_version.flavor == gcc_versiont::flavort::GCC &&
544
546
gcc_version.is_at_least (4u , gcc_float128_minor_version);
545
547
Original file line number Diff line number Diff line change @@ -948,7 +948,7 @@ bool configt::set(const cmdlinet &cmdline)
948
948
}
949
949
950
950
if (ansi_c.preprocessor == ansi_ct::preprocessort::GCC)
951
- ansi_c.Float128_type = true ;
951
+ ansi_c.gcc__float128_type = true ;
952
952
953
953
set_arch (arch);
954
954
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ class configt
44
44
bool char_is_unsigned, wchar_t_is_unsigned;
45
45
bool for_has_scope;
46
46
bool ts_18661_3_Floatn_types; // ISO/IEC TS 18661-3:2015
47
- bool Float128_type;
47
+ bool gcc__float128_type; // __float128, a gcc extension since 4.3/4.5
48
48
bool single_precision_constant;
49
49
enum class c_standardt { C89, C99, C11 } c_standard;
50
50
static c_standardt default_c_standard ();
You can’t perform that action at this time.
0 commit comments