Skip to content

Commit 89468e3

Browse files
author
Daniel Kroening
committed
add configure_gcc for version-specific gcc properties
1 parent 01f114e commit 89468e3

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

src/ansi-c/gcc_version.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,23 @@ std::ostream &operator<<(std::ostream &out, const gcc_versiont &v)
142142
{
143143
return out << v.v_major << '.' << v.v_minor << '.' << v.v_patchlevel;
144144
}
145+
146+
void configure_gcc(const gcc_versiont &gcc_version)
147+
{
148+
// ISO/IEC TS 18661-3:2015 support was introduced with gcc 7.0
149+
if(
150+
gcc_version.flavor == gcc_versiont::flavort::GCC &&
151+
gcc_version.is_at_least(7))
152+
{
153+
config.ansi_c.ts_18661_3_Floatn_types = true;
154+
}
155+
156+
const auto gcc_float128_minor_version =
157+
config.ansi_c.arch == "x86_64" ? 3u : 5u;
158+
159+
// __float128 exists (as a typedef) since gcc 4.5 everywhere,
160+
// and since 4.3 on x86_64
161+
config.ansi_c.gcc__float128_type =
162+
gcc_version.flavor == gcc_versiont::flavort::GCC &&
163+
gcc_version.is_at_least(4u, gcc_float128_minor_version);
164+
}

src/ansi-c/gcc_version.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class gcc_versiont
5050
}
5151
};
5252

53+
void configure_gcc(const gcc_versiont &);
54+
5355
std::ostream &operator<<(std::ostream &, const gcc_versiont &);
5456

5557
#endif

src/cbmc/cbmc_parse_options.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Author: Daniel Kroening, [email protected]
2828

2929
#include <ansi-c/c_preprocess.h>
3030
#include <ansi-c/cprover_library.h>
31+
#include <ansi-c/gcc_version.h>
3132

3233
#include <assembler/remove_asm.h>
3334

@@ -490,6 +491,13 @@ int cbmc_parse_optionst::doit()
490491

491492
register_languages();
492493

494+
// configure gcc, if required
495+
if(config.ansi_c.preprocessor == configt::ansi_ct::preprocessort::GCC)
496+
{
497+
gcc_versiont gcc_version;
498+
configure_gcc(gcc_version);
499+
}
500+
493501
if(cmdline.isset("test-preprocessor"))
494502
return test_c_preprocessor(ui_message_handler)
495503
? CPROVER_EXIT_PREPROCESSOR_TEST_FAILED

src/goto-cc/gcc_mode.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -531,24 +531,13 @@ int gcc_modet::doit()
531531
if(cmdline.isset("-fsingle-precision-constant"))
532532
config.ansi_c.single_precision_constant=true;
533533

534-
// ISO/IEC TS 18661-3:2015 support was introduced with gcc 7.0
535-
if(gcc_version.flavor==gcc_versiont::flavort::GCC &&
536-
gcc_version.is_at_least(7))
537-
config.ansi_c.ts_18661_3_Floatn_types=true;
538-
539-
const auto gcc_float128_minor_version =
540-
config.ansi_c.arch == "x86_64" ? 3u : 5u;
541-
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 =
545-
gcc_version.flavor == gcc_versiont::flavort::GCC &&
546-
gcc_version.is_at_least(4u, gcc_float128_minor_version);
547-
548534
// -fshort-double makes double the same as float
549535
if(cmdline.isset("fshort-double"))
550536
config.ansi_c.double_width=config.ansi_c.single_width;
551537

538+
// configure version-specific gcc settings
539+
configure_gcc(gcc_version);
540+
552541
switch(compiler.mode)
553542
{
554543
case compilet::LINK_LIBRARY:

0 commit comments

Comments
 (0)