Skip to content

Commit 378857d

Browse files
lzaoraltautschnig
andcommitted
cbmc: recognise -std={c,gnu}++17 options
CBMC will be able to understand code that is compiled with -std=c++17 or -std=gnu++17. Otherwise, it fell back to C++03 making the code un-parsable. Fixes: #6090 Co-authored-by: Michael Tautschnig <[email protected]> Co-authored-by: Lukas Zaoral <[email protected]>
1 parent 29ca8a9 commit 378857d

File tree

6 files changed

+22
-5
lines changed

6 files changed

+22
-5
lines changed

src/analyses/goto_check.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,8 @@ void goto_checkt::integer_overflow_check(
834834
{
835835
if(
836836
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP11 ||
837-
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP14)
837+
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP14 ||
838+
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP17)
838839
{
839840
allow_shift_into_sign_bit = false;
840841
}

src/ansi-c/c_preprocess.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,15 @@ bool c_preprocess_gcc_clang(
551551
#endif
552552
argv.push_back("-std=gnu++14");
553553
break;
554+
555+
case configt::cppt::cpp_standardt::CPP17:
556+
#if defined(__OpenBSD__)
557+
if(preprocessor == configt::ansi_ct::preprocessort::CLANG)
558+
argv.push_back("-std=c++17");
559+
else
560+
#endif
561+
argv.push_back("-std=gnu++17");
562+
break;
554563
}
555564
}
556565
else

src/ansi-c/gcc_version.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ void gcc_versiont::get(const std::string &executable)
120120
default_cxx_standard = configt::cppt::cpp_standardt::CPP11;
121121
else if(split[1] == "201402L")
122122
default_cxx_standard = configt::cppt::cpp_standardt::CPP14;
123+
else if(split[1] == "201703L")
124+
default_cxx_standard = configt::cppt::cpp_standardt::CPP17;
123125
}
124126
}
125127
}

src/cpp/cpp_parser.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ bool cpp_parsert::parse()
2121
{
2222
// We use the ANSI-C scanner
2323
ansi_c_parser.cpp98=true;
24-
ansi_c_parser.cpp11=
25-
config.cpp.cpp_standard==configt::cppt::cpp_standardt::CPP11 ||
26-
config.cpp.cpp_standard==configt::cppt::cpp_standardt::CPP14;
24+
ansi_c_parser.cpp11 =
25+
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP11 ||
26+
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP14 ||
27+
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP17;
2728
ansi_c_parser.ts_18661_3_Floatn_types=false;
2829
ansi_c_parser.in=in;
2930
ansi_c_parser.mode=mode;

src/goto-cc/gcc_mode.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@ int gcc_modet::doit()
593593

594594
if(std_string=="gnu++14" || std_string=="c++14")
595595
config.cpp.set_cpp14();
596+
597+
if(std_string == "gnu++17" || std_string == "c++17")
598+
config.cpp.set_cpp17();
596599
}
597600
else
598601
{

src/util/config.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,14 @@ class configt
224224

225225
struct cppt
226226
{
227-
enum class cpp_standardt { CPP98, CPP03, CPP11, CPP14 } cpp_standard;
227+
enum class cpp_standardt { CPP98, CPP03, CPP11, CPP14, CPP17 } cpp_standard;
228228
static cpp_standardt default_cpp_standard();
229229

230230
void set_cpp98() { cpp_standard=cpp_standardt::CPP98; }
231231
void set_cpp03() { cpp_standard=cpp_standardt::CPP03; }
232232
void set_cpp11() { cpp_standard=cpp_standardt::CPP11; }
233233
void set_cpp14() { cpp_standard=cpp_standardt::CPP14; }
234+
void set_cpp17() { cpp_standard=cpp_standardt::CPP17; }
234235

235236
static const std::size_t default_object_bits=8;
236237
} cpp;

0 commit comments

Comments
 (0)