From cff04cea7518ccb9412519d9259555a3d3eec820 Mon Sep 17 00:00:00 2001 From: Fabrice Le Fessant Date: Thu, 19 Oct 2023 08:43:14 +0200 Subject: [PATCH] Change --include to require absolute paths --- cobc/ChangeLog | 5 +++-- cobc/cobc.c | 1 - doc/gnucobol.texi | 4 +++- tests/testsuite.src/used_binaries.at | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cobc/ChangeLog b/cobc/ChangeLog index dccb4a81e..c9904aa7b 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -4,8 +4,9 @@ * cobc.c, codegen.c: new option --include FILE, to #include additional files in the C generated code. Such files can be used to statically check the number of arguments in static - calls, for example. The files are put into quoted, unless - they start by '<' + calls, for example. The files are put into quotes, unless + they start by '<'. Since C files are compiled in a temp dir, + quoted files should be absolute paths. 2023-10-11 Fabrice Le Fessant diff --git a/cobc/cobc.c b/cobc/cobc.c index f73fa6a45..1de39f3f9 100644 --- a/cobc/cobc.c +++ b/cobc/cobc.c @@ -4459,7 +4459,6 @@ process_filename (const char *filename) fn->translate = cobc_main_strdup (output_name); } else if (save_all_src || save_temps || save_c_src - || cb_include_file_list || cb_compile_level == CB_LEVEL_TRANSLATE) { fn->translate = cobc_main_stradd_dup (fbasename, ".c"); } else { diff --git a/doc/gnucobol.texi b/doc/gnucobol.texi index c100d917a..759a5c3e0 100644 --- a/doc/gnucobol.texi +++ b/doc/gnucobol.texi @@ -374,7 +374,9 @@ Include @file{copybook} at the beginning of the source code, as if @item --include @var{file.h} Add a @code{#include} @file{file.h} at the beginning of the generated C source file. The file name is put into quotes, unless it starts by -@code{<}. The option also implies @option{-fno-gen-c-decl-static-call}. +@code{<}. Quoted files should be absolute paths, since C files are compiled +in temporary directories. +The option also implies @option{-fno-gen-c-decl-static-call}. This option can be used to check function prototypes when static calls are used. When this option is used, the source file is compiled in the project directory (instead of the temp directory), and diff --git a/tests/testsuite.src/used_binaries.at b/tests/testsuite.src/used_binaries.at index 3f3190623..047196055 100644 --- a/tests/testsuite.src/used_binaries.at +++ b/tests/testsuite.src/used_binaries.at @@ -1021,7 +1021,7 @@ AT_DATA([prog.cob], [ AT_CHECK([$COBC -m -fstatic-call prog.cob], [0]) # We ignore the error output, as it depends on the C compiler in use -AT_CHECK([$COBC -m --include file.h -fstatic-call prog.cob], [1], [], [ignore]) +AT_CHECK([$COBC -m --include "$PWD/file.h" -fstatic-call prog.cob], [1], [], [ignore]) AT_DATA([prog2.cob], [ IDENTIFICATION DIVISION. @@ -1033,6 +1033,6 @@ AT_DATA([prog2.cob], [ CALL "f" USING "Hello" BY VALUE long RETURNING NOTHING. ]) -AT_CHECK([$COBC -m --include file.h -fstatic-call prog2.cob], [0], [], []) +AT_CHECK([$COBC -m --include "$PWD/file.h" -fstatic-call prog2.cob], [0], [], []) AT_CLEANUP