From 7f928dbda88bf0309dec4999a9f3ca9f184e10d5 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 16 Jul 2021 17:40:49 +0100 Subject: [PATCH] Avoid diagnostic code crashing when external front-ends use "C" mode At the time of writing both the rust and the Ada external front-ends generate .json_symtab files that use the "C" mode. If the ansi-c front-end is not loaded then these will crash when reporting some linking errors. --- src/symtab2gb/CMakeLists.txt | 1 + src/symtab2gb/Makefile | 1 + src/symtab2gb/module_dependencies.txt | 1 + src/symtab2gb/symtab2gb_parse_options.cpp | 4 ++++ 4 files changed, 7 insertions(+) diff --git a/src/symtab2gb/CMakeLists.txt b/src/symtab2gb/CMakeLists.txt index bfbc03a78f8..7aada9212ae 100644 --- a/src/symtab2gb/CMakeLists.txt +++ b/src/symtab2gb/CMakeLists.txt @@ -7,6 +7,7 @@ generic_includes(symtab2gb) target_link_libraries(symtab2gb util + ansi-c goto-programs json-symtab-language) diff --git a/src/symtab2gb/Makefile b/src/symtab2gb/Makefile index dd18aaa51c0..1f18f880430 100644 --- a/src/symtab2gb/Makefile +++ b/src/symtab2gb/Makefile @@ -4,6 +4,7 @@ SRC = \ # Empty last line OBJ += \ + ../ansi-c/ansi-c$(LIBEXT) \ ../util/util$(LIBEXT) \ ../goto-programs/goto-programs$(LIBEXT) \ ../big-int/big-int$(LIBEXT) \ diff --git a/src/symtab2gb/module_dependencies.txt b/src/symtab2gb/module_dependencies.txt index f1ce5725fbb..0e2983204cd 100644 --- a/src/symtab2gb/module_dependencies.txt +++ b/src/symtab2gb/module_dependencies.txt @@ -2,3 +2,4 @@ util json-symtab-language langapi goto-programs +ansi-c diff --git a/src/symtab2gb/symtab2gb_parse_options.cpp b/src/symtab2gb/symtab2gb_parse_options.cpp index 21767c5ab83..d8d9f3568e6 100644 --- a/src/symtab2gb/symtab2gb_parse_options.cpp +++ b/src/symtab2gb/symtab2gb_parse_options.cpp @@ -12,6 +12,8 @@ Author: Diffblue Ltd. #include #include +#include + #include #include #include @@ -113,6 +115,8 @@ int symtab2gb_parse_optionst::doit() gb_filename = cmdline.get_value(SYMTAB2GB_OUT_FILE_OPT); } register_language(new_json_symtab_language); + // Workaround to allow external front-ends to use "C" mode + register_language(new_ansi_c_language); config.set(cmdline); run_symtab2gb(symtab_filenames, gb_filename); return CPROVER_EXIT_SUCCESS;