Skip to content

Commit fd10a22

Browse files
authored
Merge pull request #6402 from lzaoral/c++17-support
Set standard to C++17 when -std=c++17 or -std=gnu++17 are used
2 parents 9892924 + 5e12e87 commit fd10a22

File tree

6 files changed

+99
-22
lines changed

6 files changed

+99
-22
lines changed

src/analyses/goto_check.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,8 @@ void goto_checkt::integer_overflow_check(
835835
{
836836
if(
837837
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP11 ||
838-
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP14)
838+
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP14 ||
839+
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP17)
839840
{
840841
allow_shift_into_sign_bit = false;
841842
}

src/ansi-c/c_preprocess.cpp

Lines changed: 9 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Author: Daniel Kroening, [email protected]
66
77
\*******************************************************************/
88

9-
109
#ifndef CPROVER_UTIL_CONFIG_H
1110
#define CPROVER_UTIL_CONFIG_H
1211

@@ -125,12 +124,29 @@ class configt
125124
bool ts_18661_3_Floatn_types; // ISO/IEC TS 18661-3:2015
126125
bool gcc__float128_type; // __float128, a gcc extension since 4.3/4.5
127126
bool single_precision_constant;
128-
enum class c_standardt { C89, C99, C11 } c_standard;
127+
enum class c_standardt
128+
{
129+
C89,
130+
C99,
131+
C11
132+
} c_standard;
129133
static c_standardt default_c_standard();
130134

131-
void set_c89() { c_standard=c_standardt::C89; for_has_scope=false; }
132-
void set_c99() { c_standard=c_standardt::C99; for_has_scope=true; }
133-
void set_c11() { c_standard=c_standardt::C11; for_has_scope=true; }
135+
void set_c89()
136+
{
137+
c_standard = c_standardt::C89;
138+
for_has_scope = false;
139+
}
140+
void set_c99()
141+
{
142+
c_standard = c_standardt::C99;
143+
for_has_scope = true;
144+
}
145+
void set_c11()
146+
{
147+
c_standard = c_standardt::C11;
148+
for_has_scope = true;
149+
}
134150

135151
ieee_floatt::rounding_modet rounding_mode;
136152

@@ -152,10 +168,21 @@ class configt
152168
// instruction (in bytes)
153169
std::size_t memory_operand_size;
154170

155-
enum class endiannesst { NO_ENDIANNESS, IS_LITTLE_ENDIAN, IS_BIG_ENDIAN };
171+
enum class endiannesst
172+
{
173+
NO_ENDIANNESS,
174+
IS_LITTLE_ENDIAN,
175+
IS_BIG_ENDIAN
176+
};
156177
endiannesst endianness;
157178

158-
enum class ost { NO_OS, OS_LINUX, OS_MACOS, OS_WIN };
179+
enum class ost
180+
{
181+
NO_OS,
182+
OS_LINUX,
183+
OS_MACOS,
184+
OS_WIN
185+
};
159186
ost os;
160187

161188
static std::string os_to_string(ost);
@@ -194,8 +221,15 @@ class configt
194221
};
195222
flavourt mode; // the syntax of source files
196223

197-
enum class preprocessort { NONE, GCC, CLANG, VISUAL_STUDIO,
198-
CODEWARRIOR, ARM };
224+
enum class preprocessort
225+
{
226+
NONE,
227+
GCC,
228+
CLANG,
229+
VISUAL_STUDIO,
230+
CODEWARRIOR,
231+
ARM
232+
};
199233
preprocessort preprocessor; // the preprocessor to use
200234

201235
std::list<std::string> defines;
@@ -204,7 +238,11 @@ class configt
204238
std::list<std::string> include_paths;
205239
std::list<std::string> include_files;
206240

207-
enum class libt { LIB_NONE, LIB_FULL };
241+
enum class libt
242+
{
243+
LIB_NONE,
244+
LIB_FULL
245+
};
208246
libt lib;
209247

210248
bool string_abstraction;
@@ -219,20 +257,43 @@ class configt
219257

220258
malloc_failure_modet malloc_failure_mode = malloc_failure_mode_none;
221259

222-
static const std::size_t default_object_bits=8;
260+
static const std::size_t default_object_bits = 8;
223261
} ansi_c;
224262

225263
struct cppt
226264
{
227-
enum class cpp_standardt { CPP98, CPP03, CPP11, CPP14 } cpp_standard;
265+
enum class cpp_standardt
266+
{
267+
CPP98,
268+
CPP03,
269+
CPP11,
270+
CPP14,
271+
CPP17
272+
} cpp_standard;
228273
static cpp_standardt default_cpp_standard();
229274

230-
void set_cpp98() { cpp_standard=cpp_standardt::CPP98; }
231-
void set_cpp03() { cpp_standard=cpp_standardt::CPP03; }
232-
void set_cpp11() { cpp_standard=cpp_standardt::CPP11; }
233-
void set_cpp14() { cpp_standard=cpp_standardt::CPP14; }
275+
void set_cpp98()
276+
{
277+
cpp_standard = cpp_standardt::CPP98;
278+
}
279+
void set_cpp03()
280+
{
281+
cpp_standard = cpp_standardt::CPP03;
282+
}
283+
void set_cpp11()
284+
{
285+
cpp_standard = cpp_standardt::CPP11;
286+
}
287+
void set_cpp14()
288+
{
289+
cpp_standard = cpp_standardt::CPP14;
290+
}
291+
void set_cpp17()
292+
{
293+
cpp_standard = cpp_standardt::CPP17;
294+
}
234295

235-
static const std::size_t default_object_bits=8;
296+
static const std::size_t default_object_bits = 8;
236297
} cpp;
237298

238299
struct verilogt
@@ -246,7 +307,7 @@ class configt
246307
classpatht classpath;
247308
irep_idt main_class;
248309

249-
static const std::size_t default_object_bits=16;
310+
static const std::size_t default_object_bits = 16;
250311
} java;
251312

252313
struct bv_encodingt

0 commit comments

Comments
 (0)