From 3437a3922460af97eb0667c87cf7dc254652daf7 Mon Sep 17 00:00:00 2001 From: Bob Dubner <rdubner@symas.com> Date: Sat, 21 Dec 2024 20:17:45 -0500 Subject: [PATCH] gcc/cobol compiles using .h files from libgcobol --- gcc/cobol/Make-lang.in | 2 ++ gcc/cobol/except.cc | 2 +- gcc/cobol/parse_ante.h | 12 ++++++------ gcc/cobol/scan.l | 1 + gcc/cobol/symbols.h | 29 ++++++++++++++++++----------- libgcobol/common-defs.h | 2 -- libgcobol/ec.h | 2 -- libgcobol/{except.h => exceptc.h} | 2 +- libgcobol/libgcobol.cc | 2 +- 9 files changed, 30 insertions(+), 24 deletions(-) rename libgcobol/{except.h => exceptc.h} (99%) diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in index 57ef7a460db2..c2c49e5f5011 100644 --- a/gcc/cobol/Make-lang.in +++ b/gcc/cobol/Make-lang.in @@ -46,6 +46,7 @@ cobol: cobol1$(exeext) .PHONY: cobol BINCLUDE ?= ./gcc +LIB_INCLUDE ?= $(srcdir)/../libgcobol # # At this point, as of 2022-10-21, CPPFLAGS is an empty string and can be @@ -58,6 +59,7 @@ CPPFLAGS = \ $(MAX_ERRORS) \ -Iinclude \ -I$(BINCLUDE) \ + -I$(LIB_INCLUDE) \ -Wno-cpp \ -Wno-missing-field-initializers \ -DEXEC_LIB=\"$(DESTDIR)$(libdir)\" diff --git a/gcc/cobol/except.cc b/gcc/cobol/except.cc index c7f437198f98..ea281a1f0510 100644 --- a/gcc/cobol/except.cc +++ b/gcc/cobol/except.cc @@ -43,7 +43,7 @@ #include "gengen.h" #include "ec.h" -#include "except.h" +#include "exceptc.h" static const ec_descr_t * ec_type_descr( ec_type_t type ) { diff --git a/gcc/cobol/parse_ante.h b/gcc/cobol/parse_ante.h index e37156c35107..65552d6e3351 100644 --- a/gcc/cobol/parse_ante.h +++ b/gcc/cobol/parse_ante.h @@ -51,12 +51,12 @@ #define MAXLENGTH_FORMATTED_DATETIME 30 - - - - - - +// This definition is for a function in except.cc. When I dissected lihgcobol +// from gcc/cobol, I had to rename except.h to exceptc.h, because it was +// conflicting with a poisoned GCC_EXCEPT_H. And then I didn't know where to +// put this declaration. So, I shoved it here. RJD. +extern void declarative_runtime_match(cbl_field_t *declaratives, + cbl_label_t *lave ); extern int yylineno, yyleng, yychar; extern char *yytext; diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l index 7ee809bc5d45..4b65b63ea9bb 100644 --- a/gcc/cobol/scan.l +++ b/gcc/cobol/scan.l @@ -29,6 +29,7 @@ */ %{ +#include "symbols.h" #include "scan_ante.h" #include "ec.h" #include "lexio.h" diff --git a/gcc/cobol/symbols.h b/gcc/cobol/symbols.h index 13d1125c91df..a8bca49204b2 100644 --- a/gcc/cobol/symbols.h +++ b/gcc/cobol/symbols.h @@ -46,6 +46,8 @@ #include <variant> #include <vector> +#include "common-defs.h" + #define PICTURE_MAX 64 // Define a tree type as void pointer outside the generator code. @@ -516,6 +518,22 @@ struct cbl_field_t { } }; +// Necessary forward referencea +struct cbl_label_t; +struct cbl_refer_t; + +struct cbl_span_t { + cbl_refer_t *from, *len; + + cbl_span_t( cbl_refer_t *from, cbl_refer_t *len = NULL ) + : from(from), len(len) {}; + bool is_active() const { return !( from == NULL && len == NULL ); } + + cbl_field_t *from_field(); + cbl_field_t *len_field(); +}; + + struct cbl_refer_t { cbl_field_t *field; cbl_label_t *prog_func; @@ -719,17 +737,6 @@ struct cbl_label_addresses_t { struct cbl_refer_t; -struct cbl_span_t { - cbl_refer_t *from, *len; - - cbl_span_t( cbl_refer_t *from, cbl_refer_t *len = NULL ) - : from(from), len(len) {}; - bool is_active() const { return !( from == NULL && len == NULL ); } - - cbl_field_t *from_field(); - cbl_field_t *len_field(); -}; - static inline const char * logop_str( enum logop_t logop ) { switch ( logop ) { diff --git a/libgcobol/common-defs.h b/libgcobol/common-defs.h index 87683fb9f133..5a1740d3ff3b 100644 --- a/libgcobol/common-defs.h +++ b/libgcobol/common-defs.h @@ -35,8 +35,6 @@ #include "ec.h" - - #define COUNT_OF(X) (sizeof(X) / sizeof(X[0])) // This constant establishes the maximum number of digits in a fixed point diff --git a/libgcobol/ec.h b/libgcobol/ec.h index 4116b884e630..999ed3fe8d54 100644 --- a/libgcobol/ec.h +++ b/libgcobol/ec.h @@ -32,8 +32,6 @@ #ifndef _CBL_EC_H_ #define _CBL_EC_H_ -#include "common-defs.h" - #include <set> #include <assert.h> diff --git a/libgcobol/except.h b/libgcobol/exceptc.h similarity index 99% rename from libgcobol/except.h rename to libgcobol/exceptc.h index 156872a39319..236edaeef2ab 100644 --- a/libgcobol/except.h +++ b/libgcobol/exceptc.h @@ -404,7 +404,7 @@ ec_descr_t exception_table[] = { static const auto exception_table_end = exception_table + COUNT_OF(exception_table); /* Inventory of exceptions: - In except.h::exception_table, unimplemented ECs have a uc_ disposition. + In except.hc::exception_table, unimplemented ECs have a uc_ disposition. ec_function_argument_e ACOS ANNUITY diff --git a/libgcobol/libgcobol.cc b/libgcobol/libgcobol.cc index a39b6d994e22..85b896ca6166 100644 --- a/libgcobol/libgcobol.cc +++ b/libgcobol/libgcobol.cc @@ -61,7 +61,7 @@ #include <execinfo.h> #include "ec.h" -#include "except.h" +#include "exceptc.h" // This couldn't be defined in symbols.h because it conflicts with a LEVEL66 // in parse.h -- GitLab