Skip to content

Commit 16a49a7

Browse files
author
Daniel Kroening
committed
bugfix: __float128
1 parent 3849bb0 commit 16a49a7

5 files changed

+48
-16
lines changed

src/ansi-c/ansi_c_internal_additions.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,25 @@ void ansi_c_internal_additions(std::string &code)
192192
// there are many more, e.g., look at
193193
// https://developer.apple.com/library/mac/#documentation/developertools/gcc-4.0.1/gcc/Target-Builtins.html
194194

195-
if(config.ansi_c.arch=="i386" ||
196-
config.ansi_c.arch=="x86_64" ||
197-
config.ansi_c.arch=="x32")
195+
if(
196+
config.ansi_c.arch == "i386" || config.ansi_c.arch == "x86_64" ||
197+
config.ansi_c.arch == "x32" || config.ansi_c.arch == "powerpc" ||
198+
config.ansi_c.arch == "ppc64" || config.ansi_c.arch == "ppc64le" ||
199+
config.ansi_c.arch == "ia64")
198200
{
199-
if(config.ansi_c.mode == configt::ansi_ct::flavourt::CLANG)
200-
code+="typedef double __float128;\n"; // clang doesn't do __float128
201+
// https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
202+
// For clang, __float128 is a keyword.
203+
// For gcc, this is a typedef and not a keyword.
204+
if(config.ansi_c.mode != configt::ansi_ct::flavourt::CLANG)
205+
code += "typedef __CPROVER_Float128 __float128;\n";
206+
}
207+
else if(config.ansi_c.arch == "hppa")
208+
{
209+
// https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
210+
// For clang, __float128 is a keyword.
211+
// For gcc, this is a typedef and not a keyword.
212+
if(config.ansi_c.mode != configt::ansi_ct::flavourt::CLANG)
213+
code+="typedef long double __float128;\n";
201214
}
202215

203216
// On 64-bit systems, both gcc and clang have typedefs

src/ansi-c/gcc_builtin_headers_ia32.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// from
22
// http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/X86-Built_002din-Functions.html
33

4-
__float128 __builtin_fabsq(__float128);
5-
__float128 __builtin_copysignq(__float128, __float128);
4+
__CPROVER_Float128 __builtin_fabsq(__CPROVER_Float128);
5+
__CPROVER_Float128 __builtin_copysignq(__CPROVER_Float128, __CPROVER_Float128);
66
void __builtin_ia32_pause();
7-
__float128 __builtin_infq(void);
8-
__float128 __builtin_huge_valq(void);
7+
__CPROVER_Float128 __builtin_infq(void);
8+
__CPROVER_Float128 __builtin_huge_valq(void);
99
__gcc_v8qi __builtin_ia32_paddb(__gcc_v8qi, __gcc_v8qi);
1010
__gcc_v4hi __builtin_ia32_paddw(__gcc_v4hi, __gcc_v4hi);
1111
__gcc_v2si __builtin_ia32_paddd(__gcc_v2si, __gcc_v2si);

src/ansi-c/get-gcc-builtins.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ cat > builtins.h <<EOF
102102
// some newer versions of GCC apparently support __floatXYZ
103103
#define dfloat32_type_node __float32
104104
#define dfloat64_type_node __float64
105-
#define dfloat128_type_node __float128
105+
#define dfloat128_type_node __CPROVER_Float128
106106
107107
#define build_qualified_type(t, q) q t
108108
#define build_pointer_type(t) t*

src/ansi-c/scanner.l

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,9 @@ void ansi_c_scanner_init()
496496
return make_identifier();
497497
}
498498

499-
"__float128" { // clang doesn't have it
500-
if(PARSER.mode==configt::ansi_ct::flavourt::GCC)
499+
"__float128" { // This is a keyword for CLANG,
500+
// but a typedef for GCC
501+
if(PARSER.mode==configt::ansi_ct::flavourt::CLANG)
501502
{ loc(); return TOK_GCC_FLOAT128; }
502503
else
503504
return make_identifier();
@@ -509,6 +510,10 @@ void ansi_c_scanner_init()
509510
return make_identifier();
510511
}
511512

513+
"__CPROVER_Float128" {
514+
loc(); return TOK_GCC_FLOAT128;
515+
}
516+
512517
"_Float128x" { if(PARSER.ts_18661_3_Floatn_types)
513518
{ loc(); return TOK_GCC_FLOAT128X; }
514519
else

src/cpp/cpp_internal_additions.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,25 @@ void cpp_internal_additions(std::ostream &out)
124124

125125
if(
126126
config.ansi_c.arch == "i386" || config.ansi_c.arch == "x86_64" ||
127-
config.ansi_c.arch == "x32")
127+
config.ansi_c.arch == "x32" || config.ansi_c.arch == "powerpc" ||
128+
config.ansi_c.arch == "ppc64" || config.ansi_c.arch == "ppc64le" ||
129+
config.ansi_c.arch == "ia64")
128130
{
129-
// clang doesn't do __float128
130-
if(config.ansi_c.mode == configt::ansi_ct::flavourt::CLANG)
131-
out << "typedef double __float128;" << '\n';
131+
// https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
132+
// For clang, __float128 is a keyword.
133+
// For gcc, this is a typedef and not a keyword.
134+
// C++ doesn't have _Float128.
135+
if(config.ansi_c.mode != configt::ansi_ct::flavourt::CLANG)
136+
out << "typedef __CPROVER_Float128 __float128;" << '\n';
137+
}
138+
else if(config.ansi_c.arch == "hppa")
139+
{
140+
// https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
141+
// For clang, __float128 is a keyword.
142+
// For gcc, this is a typedef and not a keyword.
143+
// C++ doesn't have _Float128.
144+
if(config.ansi_c.mode != configt::ansi_ct::flavourt::CLANG)
145+
out << "typedef long double __float128;" << '\n';
132146
}
133147

134148
// On 64-bit systems, gcc has typedefs

0 commit comments

Comments
 (0)