From 5466524a4ba5bdbcfbeb032b4ba5123fccddb884 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Wed, 18 May 2022 11:26:18 +0000 Subject: [PATCH 1/2] Support _Complex in the C++ front-end We typecheck this via the same code path as the C front-end, and just need to accept that this type exists. Clang-14 uses _Complex in system headers, and moving to Ubuntu 22.04 GitHub runners requires fixing this first. --- src/cpp/cpp_typecheck_type.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cpp/cpp_typecheck_type.cpp b/src/cpp/cpp_typecheck_type.cpp index 83bd51f609f..d54d1bf4e6c 100644 --- a/src/cpp/cpp_typecheck_type.cpp +++ b/src/cpp/cpp_typecheck_type.cpp @@ -276,6 +276,10 @@ void cpp_typecheckt::typecheck_type(typet &type) { c_typecheck_baset::typecheck_type(type); } + else if(type.id() == ID_complex) + { + // already done + } else { error().source_location=type.source_location(); From 12354e4a5da93dad917ee453745447abcccad19a Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 19 May 2022 08:17:39 +0000 Subject: [PATCH 2/2] C++ type conversion: gcc_attribute_mode must not be re-converted C typecheck_type performs its own conversion of raw type structures, and can't deal with those already done by the C++ front-end. Therefore, restored the "merged_type" before handing off to the C front-end. Also clean up unnecessary enum conversion steps, which later type checking stages actually take care of. --- regression/ansi-c/gcc_attributes6/test.desc | 2 +- src/cpp/cpp_convert_type.cpp | 9 ++------- src/cpp/cpp_typecheck_type.cpp | 15 +++++++++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/regression/ansi-c/gcc_attributes6/test.desc b/regression/ansi-c/gcc_attributes6/test.desc index 0e1ed863bc1..da401175efb 100644 --- a/regression/ansi-c/gcc_attributes6/test.desc +++ b/regression/ansi-c/gcc_attributes6/test.desc @@ -1,4 +1,4 @@ -CORE gcc-only +CORE gcc-only test-c++-front-end main.c ^EXIT=0$ diff --git a/src/cpp/cpp_convert_type.cpp b/src/cpp/cpp_convert_type.cpp index 627d5a65945..ff79b21a576 100644 --- a/src/cpp/cpp_convert_type.cpp +++ b/src/cpp/cpp_convert_type.cpp @@ -330,15 +330,10 @@ void cpp_convert_plain_type(typet &type, message_handlert &message_handler) type.id() == ID_union || type.id() == ID_array || type.id() == ID_code || type.id() == ID_unsignedbv || type.id() == ID_signedbv || type.id() == ID_bool || type.id() == ID_floatbv || type.id() == ID_empty || - type.id() == ID_constructor || type.id() == ID_destructor) + type.id() == ID_constructor || type.id() == ID_destructor || + type.id() == ID_c_enum) { } - else if(type.id()==ID_c_enum) - { - // add width -- we use int, but the standard - // doesn't guarantee that - type.set(ID_width, config.ansi_c.int_width); - } else if(type.id() == ID_c_bool) { type.set(ID_width, config.ansi_c.bool_width); diff --git a/src/cpp/cpp_typecheck_type.cpp b/src/cpp/cpp_typecheck_type.cpp index d54d1bf4e6c..ee84285ca0f 100644 --- a/src/cpp/cpp_typecheck_type.cpp +++ b/src/cpp/cpp_typecheck_type.cpp @@ -9,15 +9,15 @@ Author: Daniel Kroening, kroening@cs.cmu.edu /// \file /// C++ Language Type Checking -#include "cpp_typecheck.h" - -#include -#include #include +#include +#include #include +#include #include "cpp_convert_type.h" +#include "cpp_typecheck.h" #include "cpp_typecheck_fargs.h" void cpp_typecheckt::typecheck_type(typet &type) @@ -274,6 +274,13 @@ void cpp_typecheckt::typecheck_type(typet &type) } else if(type.id() == ID_gcc_attribute_mode) { + PRECONDITION(type.has_subtype()); + merged_typet as_parsed; + as_parsed.move_to_subtypes(type.subtype()); + type.get_sub().clear(); + as_parsed.move_to_subtypes(type); + type.swap(as_parsed); + c_typecheck_baset::typecheck_type(type); } else if(type.id() == ID_complex)