-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C/C++ front-end: accept all floating-point extensions that GCC and Clang support #8169
Merged
tautschnig
merged 1 commit into
diffblue:develop
from
tautschnig:bugfixes/float-extensions
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,12 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <string> | ||
|
||
void ansi_c_internal_additions( | ||
std::string &code, | ||
bool support_ts_18661_3_Floatn_types); | ||
void ansi_c_internal_additions(std::string &code, bool support_float16_type); | ||
void ansi_c_architecture_strings(std::string &code); | ||
|
||
extern const char clang_builtin_headers[]; | ||
extern const char cprover_builtin_headers[]; | ||
extern const char gcc_builtin_headers_types[]; | ||
extern const char gcc_builtin_headers_types_gcc7plus[]; | ||
extern const char gcc_builtin_headers_generic[]; | ||
extern const char gcc_builtin_headers_math[]; | ||
extern const char gcc_builtin_headers_mem_string[]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
src/ansi-c/compiler_headers/gcc_builtin_headers_types_gcc7plus.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,19 +13,36 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <util/config.h> | ||
|
||
#include <ansi-c/gcc_version.h> | ||
|
||
cpp_parsert cpp_parser; | ||
|
||
bool cpp_parse(); | ||
|
||
bool cpp_parsert::parse() | ||
{ | ||
if(!support_float16.has_value()) | ||
{ | ||
if(config.ansi_c.preprocessor == configt::ansi_ct::preprocessort::GCC) | ||
{ | ||
gcc_versiont gcc_version; | ||
gcc_version.get("gcc"); | ||
support_float16 = gcc_version.flavor == gcc_versiont::flavort::GCC && | ||
gcc_version.is_at_least(13u); | ||
} | ||
else | ||
support_float16 = false; | ||
} | ||
|
||
// We use the ANSI-C scanner | ||
ansi_c_parser.cpp98=true; | ||
ansi_c_parser.cpp11 = | ||
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP11 || | ||
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP14 || | ||
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP17; | ||
ansi_c_parser.ts_18661_3_Floatn_types=false; | ||
ansi_c_parser.ts_18661_3_Floatn_types = false; // these are still typedefs | ||
ansi_c_parser.float16_type = *support_float16; | ||
ansi_c_parser.bf16_type = *support_float16; | ||
ansi_c_parser.in=in; | ||
ansi_c_parser.mode=mode; | ||
ansi_c_parser.set_file(get_file()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ Author: Daniel Kroening, [email protected] | |
#include "cpp_parse_tree.h" | ||
#include "cpp_token_buffer.h" | ||
|
||
#include <optional> | ||
|
||
class cpp_parsert:public parsert | ||
{ | ||
public: | ||
|
@@ -34,10 +36,11 @@ class cpp_parsert:public parsert | |
asm_block_following=false; | ||
} | ||
|
||
cpp_parsert(): | ||
mode(configt::ansi_ct::flavourt::ANSI), | ||
recognize_wchar_t(true), | ||
asm_block_following(false) | ||
cpp_parsert() | ||
: mode(configt::ansi_ct::flavourt::ANSI), | ||
recognize_wchar_t(true), | ||
asm_block_following(false), | ||
support_float16(std::nullopt) | ||
{ | ||
} | ||
|
||
|
@@ -65,6 +68,9 @@ class cpp_parsert:public parsert | |
// scanner | ||
unsigned parenthesis_counter; | ||
bool asm_block_following; | ||
|
||
protected: | ||
std::optional<bool> support_float16; | ||
}; | ||
|
||
extern cpp_parsert cpp_parser; | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these are standardised in the C++ standards; e.g.,
bf16
is C++23. They are not clang extensions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GCC and Clang support these at varying versions, and while the standard appears to specify them I wasn't able to make them work when using
-std=c++23
(Clang) or/std:c++latest
(MSVC).