Skip to content

Commit c5de7ba

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#2296 from smowton/smowton/fix/restore-float128
Restore _Float128 support by default
2 parents 9160e99 + 7b61482 commit c5de7ba

File tree

15 files changed

+70
-10
lines changed

15 files changed

+70
-10
lines changed
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22

3-
gcc -Wno-macro-redefined -U __clang_major__ -D __GNUC__=4 -D __GNUC_MINOR__=9 -D __GNUC_PATCHLEVEL__=1 $*
3+
gcc -Wno-macro-redefined -U __clang_major__ -D __GNUC__=4 -D __GNUC_MINOR__=2 -D __GNUC_PATCHLEVEL__=1 "$@"
44

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
gcc -Wno-macro-redefined -U __clang_major__ -D __GNUC__=5 -D __GNUC_MINOR__=0 -D __GNUC_PATCHLEVEL__=0 "$@"
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22

3-
gcc -Wno-macro-redefined -U __clang_major__ -D __GNUC__=7 -D __GNUC_MINOR__=0 -D __GNUC_PATCHLEVEL__=0 $*
3+
gcc -Wno-macro-redefined -U __clang_major__ -D __GNUC__=7 -D __GNUC_MINOR__=0 -D __GNUC_PATCHLEVEL__=0 "$@"
44

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
typedef double _Float64;
1+
// None of these types should be defined when emulating gcc-4:
22

3+
typedef float _Float32;
4+
typedef double _Float32x;
5+
typedef double _Float64;
6+
typedef long double _Float64x;
7+
typedef long double _Float128;
8+
typedef long double _Float128x;
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// These types should *not* be provided when emulating gcc-5:
2+
typedef float _Float32;
3+
typedef double _Float32x;
4+
typedef double _Float64;
5+
typedef long double _Float64x;
6+
typedef long double _Float128x;
7+
8+
// But this type should:
9+
_Float128 f128;
+7-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
_Float64 some_var;
2-
1+
// All these types should be provided when emulating gcc-7:
2+
_Float32 f32;
3+
_Float32x f32x;
4+
_Float64 f64;
5+
_Float64x f64x;
6+
_Float128 f128;
7+
_Float128x f128x;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
gcc-5.c
3+
--native-compiler ./fake-gcc-5
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^CONVERSION ERROR$
+17-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
1-
#if defined(__clang__)
2-
#elif defined(__GNUC__)
1+
#if defined(__GNUC__) && !defined(__clang__)
2+
3+
#include <features.h> // For __GNUC_PREREQ
4+
5+
#ifdef __x86_64__
6+
#define FLOAT128_MINOR_VERSION 3
7+
#else
8+
#define FLOAT128_MINOR_VERSION 5
9+
#endif
10+
311
#if __GNUC__ >= 7
412
#define HAS_FLOATN
13+
#elif __GNUC_PREREQ(4, FLOAT128_MINOR_VERSION)
14+
#define HAS_FLOAT128
515
#endif
16+
617
#endif
718

819
#ifndef HAS_FLOATN
920
typedef float _Float32;
1021
typedef double _Float32x;
1122
typedef double _Float64;
1223
typedef long double _Float64x;
13-
typedef long double _Float128;
1424
typedef long double _Float128x;
1525
#endif
1626

27+
#if !defined(HAS_FLOATN) && !defined(HAS_FLOAT128)
28+
typedef long double _Float128;
29+
#endif
30+
1731
int main(int argc, char** argv) {
1832
}

src/ansi-c/ansi_c_language.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ bool ansi_c_languaget::parse(
7676
ansi_c_parser.set_message_handler(get_message_handler());
7777
ansi_c_parser.for_has_scope=config.ansi_c.for_has_scope;
7878
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;
7980
ansi_c_parser.cpp98=false; // it's not C++
8081
ansi_c_parser.cpp11=false; // it's not C++
8182
ansi_c_parser.mode=config.ansi_c.mode;

src/ansi-c/ansi_c_parser.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class ansi_c_parsert:public parsert
3636
cpp98(false),
3737
cpp11(false),
3838
for_has_scope(false),
39-
ts_18661_3_Floatn_types(false)
39+
ts_18661_3_Floatn_types(false),
40+
Float128_type(false)
4041
{
4142
}
4243

@@ -81,6 +82,9 @@ class ansi_c_parsert:public parsert
8182
// ISO/IEC TS 18661-3:2015
8283
bool ts_18661_3_Floatn_types;
8384

85+
// Does the compiler version emulated provide _Float128?
86+
bool Float128_type;
87+
8488
typedef ansi_c_identifiert identifiert;
8589
typedef ansi_c_scopet scopet;
8690

src/ansi-c/scanner.l

+1-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ void ansi_c_scanner_init()
503503
return make_identifier();
504504
}
505505

506-
"_Float128" { if(PARSER.ts_18661_3_Floatn_types)
506+
"_Float128" { if(PARSER.Float128_type)
507507
{ loc(); return TOK_GCC_FLOAT128; }
508508
else
509509
return make_identifier();

src/cpp/cpp_parser.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ bool cpp_parsert::parse()
2525
config.cpp.cpp_standard==configt::cppt::cpp_standardt::CPP11 ||
2626
config.cpp.cpp_standard==configt::cppt::cpp_standardt::CPP14;
2727
ansi_c_parser.ts_18661_3_Floatn_types=false;
28+
ansi_c_parser.Float128_type = false;
2829
ansi_c_parser.in=in;
2930
ansi_c_parser.mode=mode;
3031
ansi_c_parser.set_file(get_file());

src/goto-cc/gcc_mode.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,12 @@ int gcc_modet::doit()
530530
gcc_version.is_at_least(7))
531531
config.ansi_c.ts_18661_3_Floatn_types=true;
532532

533+
int gcc_float128_minor_version = config.ansi_c.arch == "x86_64" ? 3 : 5;
534+
535+
config.ansi_c.Float128_type =
536+
gcc_version.flavor == gcc_versiont::flavort::GCC &&
537+
gcc_version.is_at_least(4, gcc_float128_minor_version);
538+
533539
// -fshort-double makes double the same as float
534540
if(cmdline.isset("fshort-double"))
535541
config.ansi_c.double_width=config.ansi_c.single_width;

src/util/config.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,9 @@ bool configt::set(const cmdlinet &cmdline)
912912
ansi_c.preprocessor=ansi_ct::preprocessort::GCC;
913913
}
914914

915+
if(ansi_c.preprocessor == ansi_ct::preprocessort::GCC)
916+
ansi_c.Float128_type = true;
917+
915918
set_arch(arch);
916919

917920
if(os=="windows")

src/util/config.h

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class configt
4343
bool char_is_unsigned, wchar_t_is_unsigned;
4444
bool for_has_scope;
4545
bool ts_18661_3_Floatn_types; // ISO/IEC TS 18661-3:2015
46+
bool Float128_type;
4647
bool single_precision_constant;
4748
enum class c_standardt { C89, C99, C11 } c_standard;
4849
static c_standardt default_c_standard();

0 commit comments

Comments
 (0)