> -----Original Message----- > From: Richard Biener <rguent...@suse.de> > Sent: Wednesday, March 19, 2025 10:24 > To: gcc-patches@gcc.gnu.org > Cc: Jakub Jelinek <ja...@redhat.com>; rdub...@symas.com > Subject: [PATCH 2/2] [cobol] make sources coretypes.h and tree.h clean > > The following removes HOWEVER_GCC_DEFINES_TREE and the alternate > definition of tree from symbols.h and instead ensures that both > coretypes.h and tree.h are included where required. This required > putting GCCs own 'NONE' in a scoped enum (see separate patch) and > renaming the cobol use of UNSIGNED, SIGNED and BLOCK which conflict > with enums from tree.h. > > There's a few things in conflict with options.h defines, notably > cobol_dialect and cobol_exceptions but also yy_flex_debug (wherever > that comes from). I've chosen to simply #undef those where > appropriate. I've refrained from putting the coretypes.h and > tree.h includes in cobol-system.h since not all files require this. > > This helps in making use of real.h instead of using _Float128. > > Bootstrap and regtest is running on x86_64-unknown-linux-gnu. Is > this OK if it succeeds?
I talked this over with Jim. His instant reaction is that numerical calculations are significant in the Compiler Directing Facility (CDF) code, and that we don't have much coverage for them in our testcases. He asked me to mention that. That said: I applied your two patches to my development environment. It compiles on an x86_64-Linux, and the resulting GCOBOL compiler runs through our entire testsuite, which on the order of 10,000 individual tests in about 1,000 modules. Many are duplicated using EBCDIC as the internal character set. Toss in the current 697 expected passes, with no unexpected failures, of "make check-cobol", and well, that's as okay as we can be. I won't mention that again; I mention it here to let you know that I run all those tests routinely, pretty much whenever I commit anything, and I am now routinely merging in origin/trunk as I am working. So, yes: It's OK with us. > > Thanks, > Richard. > > PR cobol/119241 > gcc/cobol/ > * symbols.h: Do not typedef tree. > * cdf.y: Include coretypes.h and tree.h. > * symbols.cc: Likewise. > * symfind.cc: Likewise. > * util.cc: Likewise. > * parse.y: Include coretypes.h and tree.h where appropriate. > Rename BLOCK to COB_BLOCK, SIGNED to COB_SIGNED, UNSIGNED > to COB_UNSIGNED. > * scan.l: Likewise. > * token_names.h: Likewise. > * cobol1.cc: Do not define HOWEVER_GCC_DEFINES_TREE. > * except.cc: Likewise. > * genapi.cc: Likewise. > * gengen.cc: Likewise. > * genmath.cc: Likewise. > * genutil.cc: Likewise. > * structs.cc: Likewise. > --- > gcc/cobol/cdf.y | 3 +++ > gcc/cobol/cobol1.cc | 1 - > gcc/cobol/except.cc | 1 - > gcc/cobol/genapi.cc | 2 -- > gcc/cobol/gengen.cc | 1 - > gcc/cobol/genmath.cc | 1 - > gcc/cobol/genutil.cc | 1 - > gcc/cobol/parse.y | 24 +++++++++++++++--------- > gcc/cobol/scan.l | 13 ++++++++----- > gcc/cobol/structs.cc | 1 - > gcc/cobol/symbols.cc | 4 ++++ > gcc/cobol/symbols.h | 5 ----- > gcc/cobol/symfind.cc | 3 +++ > gcc/cobol/token_names.h | 6 +++--- > gcc/cobol/util.cc | 5 ++++- > 15 files changed, 40 insertions(+), 31 deletions(-) > > diff --git a/gcc/cobol/cdf.y b/gcc/cobol/cdf.y > index 12d11e78116..c44ee5ee072 100644 > --- a/gcc/cobol/cdf.y > +++ b/gcc/cobol/cdf.y > @@ -30,6 +30,9 @@ > %{ > > #include "cobol-system.h" > +#include "coretypes.h" > +#include "tree.h" > +#undef yy_flex_debug > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > #include "util.h" > diff --git a/gcc/cobol/cobol1.cc b/gcc/cobol/cobol1.cc > index 08af367e226..0d07c460d41 100644 > --- a/gcc/cobol/cobol1.cc > +++ b/gcc/cobol/cobol1.cc > @@ -29,7 +29,6 @@ along with GCC; see the file COPYING3. If not see > #include "langhooks-def.h" > #include "target.h" > #include "stringpool.h" > -#define HOWEVER_GCC_DEFINES_TREE 1 > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > #include "util.h" > diff --git a/gcc/cobol/except.cc b/gcc/cobol/except.cc > index 5374201b4c8..ba49f78d897 100644 > --- a/gcc/cobol/except.cc > +++ b/gcc/cobol/except.cc > @@ -32,7 +32,6 @@ > #include "cobol-system.h" > #include "coretypes.h" > #include "tree.h" > -#define HOWEVER_GCC_DEFINES_TREE 1 > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > #include "util.h" > diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc > index a4abbd13ab6..8f4f9b21370 100644 > --- a/gcc/cobol/genapi.cc > +++ b/gcc/cobol/genapi.cc > @@ -35,8 +35,6 @@ > #include "stringpool.h" > #include "diagnostic-core.h" > > -#define HOWEVER_GCC_DEFINES_TREE 1 > - > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > #include "util.h" > diff --git a/gcc/cobol/gengen.cc b/gcc/cobol/gengen.cc > index 2796b7facdb..ffb64c8993d 100644 > --- a/gcc/cobol/gengen.cc > +++ b/gcc/cobol/gengen.cc > @@ -95,7 +95,6 @@ > #include "toplev.h" > #include "function.h" > #include "fold-const.h" > -#define HOWEVER_GCC_DEFINES_TREE 1 > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > #include "util.h" > diff --git a/gcc/cobol/genmath.cc b/gcc/cobol/genmath.cc > index 42f01cda6ee..56254e88cc6 100644 > --- a/gcc/cobol/genmath.cc > +++ b/gcc/cobol/genmath.cc > @@ -30,7 +30,6 @@ > #include "cobol-system.h" > #include "coretypes.h" > #include "tree.h" > -#define HOWEVER_GCC_DEFINES_TREE 1 > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > #include "util.h" > diff --git a/gcc/cobol/genutil.cc b/gcc/cobol/genutil.cc > index c0e6631bb76..f8bf7bc34b7 100644 > --- a/gcc/cobol/genutil.cc > +++ b/gcc/cobol/genutil.cc > @@ -30,7 +30,6 @@ > #include "cobol-system.h" > #include "coretypes.h" > #include "tree.h" > -#define HOWEVER_GCC_DEFINES_TREE 1 > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > #include "util.h" > diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y > index c45dc333ec7..01053888736 100644 > --- a/gcc/cobol/parse.y > +++ b/gcc/cobol/parse.y > @@ -30,6 +30,7 @@ > %code requires { > #include <fstream> // Before cobol-system because it uses poisoned > functions > #include "cobol-system.h" > + #include "coretypes.h" > #include "../../libgcobol/io.h" > #include "../../libgcobol/ec.h" > > @@ -279,6 +280,11 @@ > %{ > #include <fstream> // Before cobol-system because it uses poisoned > functions > #include "cobol-system.h" > +#include "coretypes.h" > +#include "tree.h" > +#undef cobol_dialect > +#undef cobol_exceptions > +#undef yy_flex_debug > #include "cdfval.h" > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > @@ -402,7 +408,7 @@ > > BASED BASECONVERT > BEFORE BINARY BIT BIT_OF "BIT-OF" BIT_TO_CHAR "BIT-TO- > CHAR" > - BLANK BLOCK > + BLANK COB_BLOCK > BOOLEAN_OF_INTEGER "BOOLEAN-OF-INTEGER" > BOTTOM BY > BYTE BYTE_LENGTH "BYTE-LENGTH" > @@ -607,7 +613,7 @@ > NONE NORMAL NUMBERS > PREFIXED PREVIOUS PROHIBITED RELATION REQUIRED > REVERSE_VIDEO ROUNDING > - SECONDS SECURE SHORT SIGNED > + SECONDS SECURE SHORT COB_SIGNED > STANDARD_BINARY "STANDARD-BINARY" > STANDARD_DECIMAL "STANDARD-DECIMAL" > STATEMENT STEP STRUCTURE > @@ -615,7 +621,7 @@ > TOWARD_LESSER "TOWARD-LESSER" > TRUNCATION > UCS_4 "UCS-4" > - UNDERLINE UNSIGNED > + UNDERLINE COB_UNSIGNED > UTF_16 "UTF-16" > UTF_8 "UTF-8" > > @@ -1008,7 +1014,7 @@ > > BACKWARD BASED BASECONVERT > BEFORE BINARY BIT BIT_OF BIT_TO_CHAR > - BLANK BLOCK > + BLANK COB_BLOCK > BOOLEAN_OF_INTEGER > BOTTOM BY > BYTE BYTE_LENGTH > @@ -1222,7 +1228,7 @@ > NONE NORMAL NUMBERS > PREFIXED PREVIOUS PROHIBITED RELATION REQUIRED > REVERSE_VIDEO ROUNDING > - SECONDS SECURE SHORT SIGNED > + SECONDS SECURE SHORT COB_SIGNED > STANDARD_BINARY > STANDARD_DECIMAL > STATEMENT STEP STRUCTURE > @@ -1230,7 +1236,7 @@ > TOWARD_LESSER > TRUNCATION > UCS_4 > - UNDERLINE UNSIGNED > + UNDERLINE COB_UNSIGNED > UTF_16 > UTF_8 > > @@ -2901,7 +2907,7 @@ fd_clause: record_desc > } > ; > > -block_desc: BLOCK contains rec_contains chars_recs > +block_desc: COB_BLOCK contains rec_contains chars_recs > ; > rec_contains: NUMSTR[min] { > ssize_t n; > @@ -6522,7 +6528,7 @@ context_word: APPLY { static > char s[] ="APPLY"; > $$ = s; } // screen description > entry > | SHORT { static char s[] ="SHORT"; > $$ = s; } // DYNAMIC LENGTH > STRUCTURE clause > - | SIGNED { static char s[] ="SIGNED"; > + | COB_SIGNED { static char s[] ="SIGNED"; > $$ = s; } // DYNAMIC LENGTH > STRUCTURE clause and USAGE clause > | STANDARD_BINARY { static char s[] ="STANDARD- > BINARY"; > $$ = s; } // ARITHMETIC clause > @@ -6548,7 +6554,7 @@ context_word: APPLY { static > char s[] ="APPLY"; > $$ = s; } // ALPHABET clause > | UNDERLINE { static char s[] ="UNDERLINE"; > $$ = s; } // screen description > entry and SET attribute statement > - | UNSIGNED { static char s[] ="UNSIGNED"; > + | COB_UNSIGNED { static char s[] ="UNSIGNED"; > $$ = s; } // USAGE clause > | UTF_8 { static char s[] ="UTF-8"; > $$ = s; } // ALPHABET clause > diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l > index 18d0d82cf43..4b212f02a11 100644 > --- a/gcc/cobol/scan.l > +++ b/gcc/cobol/scan.l > @@ -30,6 +30,9 @@ > %{ > #include <fstream> // Before cobol-system because it uses poisoned > functions > #include "cobol-system.h" > +#include "coretypes.h" > +#include "tree.h" > +#undef yy_flex_debug > > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > @@ -371,7 +374,7 @@ ROUNDING { return ROUNDING; } > SECONDS { return SECONDS; } > SECURE { return SECURE; } > SHORT { return SHORT; } > -SIGNED { return SIGNED; } > +SIGNED { return COB_SIGNED; } > STANDARD-BINARY { return STANDARD_BINARY; } > STANDARD-DECIMAL { return STANDARD_DECIMAL; } > STATEMENT { return STATEMENT; } > @@ -391,7 +394,7 @@ TOWARD-LESSER { return TOWARD_LESSER; } > TRUNCATION { return TRUNCATION; } > UCS-4 { return UCS_4; } > UNDERLINE { return UNDERLINE; } > -UNSIGNED { return UNSIGNED; } > +UNSIGNED { return COB_UNSIGNED; } > UTF-16 { return UTF_16; } > UTF-8 { return UTF_8; } > > @@ -834,7 +837,7 @@ CALL { return CALL; } > BY { return BY; } > BOTTOM { return BOTTOM; } > BEFORE { return BEFORE; } > -BLOCK { return BLOCK; } > +BLOCK { return COB_BLOCK; } > BACKWARD { return BACKWARD; } > > AT { return AT; } > @@ -1039,7 +1042,7 @@ USE({SPC}FOR)? { return USE; } > AS { return AS; } > ASCENDING { return ASCENDING; } > BLANK { return BLANK; } > - BLOCK { return BLOCK; } > + BLOCK { return COB_BLOCK; } > BY { return BY; } > BYTE-LENGTH { return BYTE_LENGTH; } > CHARACTER { return CHARACTER; } > @@ -2161,7 +2164,7 @@ BASIS { yy_push_state(basis); return BASIS; > } > BINARY { return BINARY; } > BIT { return BIT; } > BLANK { return BLANK; } > - BLOCK { return BLOCK; } > + BLOCK { return COB_BLOCK; } > BOTTOM { return BOTTOM; } > BY { return BY; } > CALL { return CALL; } > diff --git a/gcc/cobol/structs.cc b/gcc/cobol/structs.cc > index 39c8a425fa5..1d2d9845fdf 100644 > --- a/gcc/cobol/structs.cc > +++ b/gcc/cobol/structs.cc > @@ -55,7 +55,6 @@ > #include "cobol-system.h" > #include "coretypes.h" > #include "tree.h" > -#define HOWEVER_GCC_DEFINES_TREE 1 > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > #include "util.h" > diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc > index 38c7a2ed47b..17583e002a1 100644 > --- a/gcc/cobol/symbols.cc > +++ b/gcc/cobol/symbols.cc > @@ -30,6 +30,10 @@ > > #include <fstream> // Before cobol-system because it uses poisoned > functions > #include "cobol-system.h" > + > +#include "coretypes.h" > +#include "tree.h" > + > #include <search.h> > #include <iconv.h> > #include "../../libgcobol/ec.h" > diff --git a/gcc/cobol/symbols.h b/gcc/cobol/symbols.h > index c1894129781..fb7b60d9eaa 100644 > --- a/gcc/cobol/symbols.h > +++ b/gcc/cobol/symbols.h > @@ -48,11 +48,6 @@ > > #define PICTURE_MAX 64 > > -// Define a tree type as void pointer outside the generator code. > -#ifndef HOWEVER_GCC_DEFINES_TREE > -typedef void *tree; > -#endif > - > #if ! (__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)) > static_assert( sizeof(output) == sizeof(long double), "long doubles?" ); > > diff --git a/gcc/cobol/symfind.cc b/gcc/cobol/symfind.cc > index 38a890006c8..2687fdb83df 100644 > --- a/gcc/cobol/symfind.cc > +++ b/gcc/cobol/symfind.cc > @@ -31,6 +31,9 @@ > > #include "cobol-system.h" > > +#include "coretypes.h" > +#include "tree.h" > + > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > #include "util.h" > diff --git a/gcc/cobol/token_names.h b/gcc/cobol/token_names.h > index 26dabc87eff..f9b80b6fcb0 100644 > --- a/gcc/cobol/token_names.h > +++ b/gcc/cobol/token_names.h > @@ -219,7 +219,7 @@ tokens = { > { "bit-of", BIT_OF }, // 470 > { "bit-to-char", BIT_TO_CHAR }, // 471 > { "blank", BLANK }, // 472 > - { "block", BLOCK }, // 473 > + { "block", COB_BLOCK }, // 473 > { "boolean-of-integer", BOOLEAN_OF_INTEGER }, // 474 > { "bottom", BOTTOM }, // 475 > { "by", BY }, // 476 > @@ -642,7 +642,7 @@ tokens = { > { "seconds", SECONDS }, // 891 > { "secure", SECURE }, // 892 > { "short", SHORT }, // 893 > - { "signed", SIGNED }, // 894 > + { "signed", COB_SIGNED }, // 894 > { "standard-binary", STANDARD_BINARY }, // 895 > { "standard-decimal", STANDARD_DECIMAL }, // 896 > { "statement", STATEMENT }, // 897 > @@ -653,7 +653,7 @@ tokens = { > { "truncation", TRUNCATION }, // 902 > { "ucs-4", UCS_4 }, // 903 > { "underline", UNDERLINE }, // 904 > - { "unsigned", UNSIGNED }, // 905 > + { "unsigned", COB_UNSIGNED }, // 905 > { "utf-16", UTF_16 }, // 906 > { "utf-8", UTF_8 }, // 907 > { "address", ADDRESS }, // 908 > diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc > index 101a0a0d803..1c0810bf229 100644 > --- a/gcc/cobol/util.cc > +++ b/gcc/cobol/util.cc > @@ -35,6 +35,10 @@ > */ > > #include "cobol-system.h" > +#include "coretypes.h" > +#include "tree.h" > +#undef yy_flex_debug > + > #include <langinfo.h> > > #include "coretypes.h" > @@ -55,7 +59,6 @@ > #include "cbldiag.h" > #include "lexio.h" > > -#define HOWEVER_GCC_DEFINES_TREE > #include "../../libgcobol/ec.h" > #include "../../libgcobol/common-defs.h" > #include "symbols.h" > -- > 2.43.0