From: James K. Lowden Date: Tue, 16 Jun 2026 15:15:46 +0000 (-0400) Subject: cobol: Use cdf namespace in CDF Bison parser output. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7bb846ed7fde99fa4d423e5dfa3b9560191e98a2;p=thirdparty%2Fgcc.git cobol: Use cdf namespace in CDF Bison parser output. Fixes PR 119215 LTO error by removing enumerated types and other names from the global namespace, and by deleting use of YYLTYPE. A single location type cbl_loc_t is used by both parsers. Also fixes PR 122466 using conditional compilation for non-POSIX symbols. Require Bison 3.8.2 for C++ output. The generated C++ uses iostreams to format error messages. The cdf.y file includes the iostream header and does not use any GCC header files. gcc/cobol/ChangeLog: * Make-lang.in: Report Bison version. * cbldiag.h (defined): Define possibly missing macros. (ATTRIBUTE_GCOBOL_DIAG): Define if missing. (ATTRIBUTE_PRINTF_1): Same. (ATTRIBUTE_PRINTF_3): Same. (yyerror): Remove. (struct YYLTYPE): Remove. (enum cbl_gcobol_feature_t): Relocate from symbols.h. (YYLTYPE_IS_DECLARED): Remove. (YYLTYPE_IS_TRIVIAL): Remove. (cobol_location): Relocate. (cobol_gcobol_feature_set): Declare. (struct YDFLTYPE): Remove. (enum cbl_call_convention_t): Relocate from symbols.h. (YDFLTYPE_IS_DECLARED): Remove. (YDFLTYPE_IS_TRIVIAL): Remove. (current_call_convention): Declare. (cdf_push): Declare. (cdf_push_call_convention): Declare. (cdf_push_current_tokens): Declare. (cdf_push_dictionary): Declare. (cdf_push_enabled_exceptions): Declare. (cdf_push_source_format): Declare. (cdf_pop): Declare. (cdf_pop_call_convention): Declare. (cdf_pop_current_tokens): Declare. (cdf_pop_dictionary): Declare. (cdf_pop_source_format): Declare. (cdf_pop_enabled_exceptions): Declare. (current_program_index): Declare. (struct cbl_loc_t): Derive from cbl_loc_base_t. (struct cbl_loc_base_t): Define. (cbl_err): Declare. (cbl_errx): Declare. (error_msg): Use cbl_loc_t. (warn_msg): Same. (cbl_unimplemented_at): Same. (gcc_location_set): Same. * cdf.y: Require Bison 3.8.2 and generate C++ in cdf namespace. * cdfval.h (struct YDFLTYPE): Remove. (struct cbl_loc_t): Forward declaration. (struct cdfval_base_t): User-defined conversion from derived. * copybook.h (gcc_assert): Use assert(3) within cdf.y. (gcc_unreachable): Declare within cdf.y. (class copybook_elem_t): Use cbl_loc_t. (CTOUPPER): Use toupper(3) in uppername_t helper. (TOUPPER): Same. (class copybook_t): Use cbl_loc_t. * exceptg.h (struct cbl_label_t): Declare cbl_label_t. * gcobc: Support -fno-ec. * gcobol.1: Reword -fsyntax-only slightly. * genapi.cc (parser_label_label): Use cobol_location(). * lang.opt: Add comment in re lang.opt.urls. * lexio.cc (struct replacing_term_t): Use cbl_loc_t. (location_in): Same. (parse_copy_directive): Same. * lexio.h (struct filespan_t): Same. * messages.cc (cbl_message): Same. * parse.y: Same, and propagate location variously. * parse_ante.h (current_data_section_set): Use cbl_loc_t. (namcpy): Same. (reject_refmod): Same. (require_pointer): Same. (require_integer): Same. (ast_op): Same. (perform_tgt_set): Same. (label_add): Same. (paragraph_reference): Same. (tee_up_name): Same. (ast_inspect): Same. (ast_enter_section): Same. (ast_enter_paragraph): Same. (prototype_add): Same. (verify_args): Same. (subscript_dimension_error): Same. (literal_subscripts_valid): Same. (literal_refmod_valid): Same. (struct cbl_fieldloc_t): Remove. (intrinsic_call_1): Use cbl_loc_t. (symbol_find): Same. (valid_redefine): Same. (field_add): Same. (field_type_update): Same. (field_capacity_error): Same. (field_alloc): Same. (file_add): Same. (alphabet_add): Same. (set_real_from_capacity): Same. (procedure_division_ready): Same. (file_section_fd_set): Same. (ast_call): Same. (field_binary_usage): Same. (ast_end_program): Same. (cobol_location): Same. (location_set): Same. (statement_begin): Same. (ast_first_statement): Same. * scan.l: Qualify tokens with new cdf namespace. * scan_ante.h (ydfparse): Now static. (cdf_context): Declare. (ydfltype_of): Remove. (update_location): Use cbl_loc_t. (reset_location): Same. (YY_USER_INIT): Same. (class picture_t): Same. * scan_post.h (ydfparse): Wrapper for cdf_parser::parse() method. (ydfchar): Lookahead helper. (ydfdebug): Same. (run_cdf): Clearer debug messages. (struct pending_token_t): Renamed to recent_token_t. (struct recent_token_t): As above. (PENDING): Renames to RECENT. (RECENT): As above. (next_token): Removed. (recent_tokens_t): Capture abandoned lookahead tokens. (prelex): Use recent_tokens queue. (yylex): Drop normal parsing idea. * symbols.cc (symbol_field_location): Use cbl_loc_t. (symbol_alphabet): Same. (cbl_alphabet_t::cbl_alphabet_t): Same. (cbl_alphabet_t::assign): Same. (cbl_alphabet_t::also): Same. (symbol_temporary_location): Same. (cbl_field_t::encode): Same. * symbols.h (enum cbl_gcobol_feature_t): Remove. (cobol_gcobol_feature_set): Remove. (struct cbl_field_t): Use cbl_loc_t. (struct cbl_refer_t): Same. (struct cbl_alphabet_t): Same. (struct cbl_perform_tgt_t): Same. (struct cbl_nameloc_t): Same. (class name_queue_t): Same. (tee_up_name): Same. (symbol_field_location): Same. (enum cbl_call_convention_t): Remove (class current_tokens_t): Use cbl_loc_t. (current_call_convention): Same. (gcc_location_set): Same. * util.cc (class cdf_directives_t): Use cbl_loc_t. (cdf_unreachable): Define as gcc_unreachable. (cdf_literalize): Do not handle location. (cdf_file): New function. (cdf_file_index): Same. (cdf_file_name): Same. (cdf_add_field): Same. (cbl_field_t::encode_numeric): Remove unused parameter. (cbl_field_t::report_invalid_initial_value): Use cbl_loc_t. (match_proc): Namespace for local prototype-verification functions. (DUMP_PROCEDURE_CALLS): Guard macro for debug function. (procedure_calls_dump): New function to show uses of PERFORM. (gcc_location_set_impl): Use cbl_loc_t. (gcc_location_set): Same. (class temp_loc_t): Same. (error_msg): Same. (warn_msg): Same. (ydfdebug): Same. (cobol_set_debugging): Same. (cbl_unimplemented_at): Same. * util.h (cbl_err): Remove declaration. (cbl_errx): Same. (cdf_push): Same. (cdf_push_call_convention): Same. (cdf_push_current_tokens): Same. (cdf_push_dictionary): Same. (cdf_push_enabled_exceptions): Same. (cdf_push_source_format): Same. (cdf_pop): Same. (cdf_pop_call_convention): Same. (cdf_pop_current_tokens): Same. (cdf_pop_dictionary): Same. (cdf_pop_source_format): Same. (cdf_pop_enabled_exceptions): Same. libgcobol/ChangeLog: * posix/shim/open.cc (defined): Honor _GNU_SOURCE and _POSIX_C_SOURCE. --- diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in index a43a2244220..3a760eea056 100644 --- a/gcc/cobol/Make-lang.in +++ b/gcc/cobol/Make-lang.in @@ -152,6 +152,7 @@ gcobol-cross$(exeext): gcobol$(exeext) # First, files needed for parsing: cobol/parse.cc: cobol/parse.y + $(BISON) --version | grep ^bison $(BISON) -o $@ $(YFLAGS) \ --defines=cobol/parse.h \ --report-file=cobol/parser.out $< diff --git a/gcc/cobol/cbldiag.h b/gcc/cobol/cbldiag.h index 07d92c0b48d..827667bdcbd 100644 --- a/gcc/cobol/cbldiag.h +++ b/gcc/cobol/cbldiag.h @@ -41,66 +41,95 @@ const char * cobol_filename(); +#if ! defined(ATTRIBUTE_GCOBOL_DIAG) +#define ATTRIBUTE_GCOBOL_DIAG(a, b) +#endif +#if ! defined(ATTRIBUTE_PRINTF_1) +#define ATTRIBUTE_PRINTF_1 +#endif +#if ! defined(ATTRIBUTE_PRINTF_3) +#define ATTRIBUTE_PRINTF_3 +#endif + /* - * These are user-facing messages. They go through the gcc - * diagnostic framework and use text that can be localized. + * Enumerations do not depend on anything else. */ -void yyerror( const char fmt[], ... ) ATTRIBUTE_GCOBOL_DIAG(1, 2); -/* Location type. Borrowed from parse.h as generated by Bison. */ -#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE YYLTYPE; -struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; +enum cbl_gcobol_feature_t { + feature_gcc_e = 0x00, + feature_internal_ebcdic_e = 0x01, + feature_embiggen_e = 0x02, // widen numeric that redefine POINTER }; -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 -const YYLTYPE& cobol_location(); -#endif +bool cobol_gcobol_feature_set( cbl_gcobol_feature_t gcobol_feature, + bool on = true ); -#if ! defined YDFLTYPE && ! defined YDFLTYPE_IS_DECLARED -typedef struct YDFLTYPE YDFLTYPE; -struct YDFLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; +enum cbl_call_convention_t { + cbl_call_verbatim_e = 'V', + cbl_call_cobol_e = 'N', // native }; -# define YDFLTYPE_IS_DECLARED 1 -# define YDFLTYPE_IS_TRIVIAL 1 -#endif +void current_call_convention( cbl_call_convention_t convention); +cbl_call_convention_t current_call_convention(); + + +/* + * CDF state does not require types that would be defined in another file. + */ +void cdf_push(); +void cdf_push_call_convention(); +void cdf_push_current_tokens(); +void cdf_push_dictionary(); +void cdf_push_enabled_exceptions(); +void cdf_push_source_format(); + +void cdf_pop(); +void cdf_pop_call_convention(); +void cdf_pop_current_tokens(); +void cdf_pop_dictionary(); +void cdf_pop_source_format(); +void cdf_pop_enabled_exceptions(); + +size_t current_program_index(); + +/* + * These are user-facing messages. They go through the gcc + * diagnostic framework and use text that can be localized. + */ +void yyerror( const char fmt[], ... ) ATTRIBUTE_GCOBOL_DIAG(1, 2); -struct cbl_loc_t { +struct cbl_loc_base_t { int first_line; int first_column; int last_line; int last_column; +}; +struct cbl_loc_t : public cbl_loc_base_t { - cbl_loc_t() - : first_line(0) - , first_column(0) - , last_line(0) - , last_column(0) + cbl_loc_t() : cbl_loc_base_t{} {} - cbl_loc_t( const YYLTYPE& loc ) - : first_line(loc.first_line) - , first_column(loc.first_column) - , last_line(loc.last_line) - , last_column(loc.last_column) + cbl_loc_t( int first_line, int first_column, + int last_line, int last_column ) + : cbl_loc_base_t { + first_line , first_column, + last_line, last_column + } {} - - operator YYLTYPE() const { // cppcheck-suppress syntaxError - return { first_line, first_column, last_line, last_column }; - } + cbl_loc_t( const cbl_loc_base_t& base ) : cbl_loc_base_t(base) + {} +#if 0 + cbl_loc_t( int first_line, int first_column, + int last_line, int last_column ) + : first_line(first_line) + , first_column(first_column) + , last_line(last_line) + , last_column(last_column) + {} +#endif }; +const cbl_loc_t& cobol_location(); + /* * Naming Convention: Names end with a letter that indicates * their kind: @@ -176,12 +205,18 @@ enum cbl_diag_id_t : uint64_t { DiagDiagDiag // always last }; +void cbl_err(const char *format_string, ...) ATTRIBUTE_GCOBOL_DIAG(1, 2); +void cbl_errx(const char *format_string, ...) ATTRIBUTE_GCOBOL_DIAG(1, 2); + bool cbl_message( cbl_diag_id_t id, const char msg[], ... ) ATTRIBUTE_GCOBOL_DIAG(2, 3); bool cbl_message( cbl_loc_t loc, cbl_diag_id_t id, const char msg[], ... ) ATTRIBUTE_GCOBOL_DIAG(3, 4); +[[noreturn]] void cbl_internal_error(const char *format_string, ...) + ATTRIBUTE_GCOBOL_DIAG(1, 2); + bool dialect_ok( const cbl_loc_t& loc, cbl_diag_id_t id, const char term[], bool ok = true ); @@ -192,11 +227,14 @@ dialect_not_ok( const cbl_loc_t& loc, cbl_diag_id_t id, const char term[] ) { // Diagnostic format specifiers are documented in gcc/pretty-print.cc // an error at a location, called from the parser for semantic errors -void error_msg( const YYLTYPE& loc, const char gmsgid[], ... ) +void error_msg( const cbl_loc_t& loc, const char gmsgid[], ... ) + ATTRIBUTE_GCOBOL_DIAG(2, 3); + +void error_msg( const cbl_loc_t& loc, const char gmsgid[], ... ) ATTRIBUTE_GCOBOL_DIAG(2, 3); bool -warn_msg( const YYLTYPE& loc, const char gmsgid[], ... ) +warn_msg( const cbl_loc_t& loc, const char gmsgid[], ... ) ATTRIBUTE_GCOBOL_DIAG(2, 3); // an error that uses token_location, not yylloc @@ -212,7 +250,7 @@ void cbl_unimplementedw(cbl_diag_id_t id, const char *gmsgid, ...) ATTRIBUTE_GCOBOL_DIAG(2, 3); // warning void cbl_unimplemented(const char *gmsgid, ...) ATTRIBUTE_GCOBOL_DIAG(1, 2); // error -void cbl_unimplemented_at( const YYLTYPE& loc, const char *gmsgid, ... ) +void cbl_unimplemented_at( const cbl_loc_t& loc, const char *gmsgid, ... ) ATTRIBUTE_GCOBOL_DIAG(2, 3); /* @@ -222,7 +260,7 @@ void cbl_unimplemented_at( const YYLTYPE& loc, const char *gmsgid, ... ) */ void dbgmsg( const char fmt[], ... ) ATTRIBUTE_PRINTF_1; -void gcc_location_set( const YYLTYPE& loc ); +void gcc_location_set( const cbl_loc_t& loc ); void gcc_location_dump(); diff --git a/gcc/cobol/cdf.y b/gcc/cobol/cdf.y index 967952538d1..83548a2bbb8 100644 --- a/gcc/cobol/cdf.y +++ b/gcc/cobol/cdf.y @@ -27,30 +27,99 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + %{ -#include "cobol-system.h" -#include -#include +#include +#include +#include +#include +#include +#include -#undef yy_flex_debug +#include +#include +#include +#include +#include +#include +#include + +#include + +#define HAVE_DECL_BASENAME 1 +#include + +#define CDF_Y -#include "../../libgcobol/ec.h" -#include "../../libgcobol/common-defs.h" -#include "util.h" #include "cbldiag.h" -#include "symbols.h" #include "copybook.h" +#include "../../libgcobol/ec.h" +#include "../../libgcobol/common-defs.h" #include "../../libgcobol/exceptl.h" #include "exceptg.h" +// Quell warning: variable yynerrs_ set but not used +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" + +std::ostream& +operator<<( std::ostream& os, cbl_loc_t const& loc ) { + os << "(" + << loc.first_line + << "," + << loc.first_column + << ") to (" + << loc.last_line + << "," + << loc.last_column + << ")"; + return os; +} + +const char * keyword_str( int token ); + +namespace cdf { +static int current_token; +static int used_token( int token ) { + dbgmsg("%s: %s", __func__, keyword_str(token)); + return current_token = token; +} + +int used_token() { return current_token; } +} +#define USED_TOKEN(T) cdf::used_token(parser::token::YDF_ ##T) + +%} + +%code requires { + namespace cdf + { + class parser; + } +} + +%code { + // https://learnmoderncpp.com/2020/12/17/generating-c-programs-with-flex-and-bison-2/ + namespace cdf + { + int cdflex( parser::semantic_type *value, cbl_loc_t *loc ); + } +} + +%define api.location.type {cbl_loc_t} + +%{ #define COUNT_OF(X) (sizeof(X) / sizeof(X[0])) +int keyword_tok( const char * text, bool include_intrinsics = false ); + copybook_t copybook; +std::ostream& operator<<(std::ostream& os, const cbl_loc_t& loc); + static inline bool is_word( int c ) { - return c == '_' || ISALNUM(c); + return c == '_' || ::isalnum(c); } static std::pair @@ -66,15 +135,15 @@ integer_literal( const char input[] ) { 'yynerrs', 'yylval', 'yylloc', 'yychar' and 'yydebug'. [...] The renamed macros include 'YYSTYPE', 'YYLTYPE', and 'YYDEBUG'" */ -extern int yylineno, yyleng; +extern int yylineno, yyleng, yydebug; extern char *yytext; -static int ydflex(void); +extern size_t cbl_gcobol_features; #define PROGRAM current_program_index() -const YYLTYPE& cobol_location(); -static YYLTYPE location_set( const YYLTYPE& loc ); +const cbl_loc_t& cobol_location(); +static cbl_loc_t location_set( const cbl_loc_t& loc ); void input_file_status_notify(); #define YYLLOC_DEFAULT(Current, Rhs, N) \ @@ -104,7 +173,7 @@ void input_file_status_notify(); %code requires { #include "cdfval.h" - + struct cbl_file_t; using std::map; #pragma GCC diagnostic push @@ -153,9 +222,11 @@ void input_file_status_notify(); cdfval_t operator/( const cdfval_base_t& lhs, const cdfval_base_t& rhs ); cdfval_t negate( cdfval_base_t lhs ); - cbl_field_t - cdf_literalize( const cbl_loc_t& loc, - const std::string& name, const cdfval_t& value, bool init = true ); + void cdf_unreachable(); + void cdf_field_add( const cbl_loc_t&, const std::string& name, const cdfval_t& value ); + cbl_file_t * cdf_file( size_t program, const cbl_name_t name ); + size_t cdf_file_index( const cbl_file_t *file ); + const char * cdf_file_name(const cbl_file_t*); } %{ @@ -189,15 +260,15 @@ apply_cdf_turn( const exception_turn_t& turn ) { std::set *files; } -%printer { fprintf(yyo, "'%s'", $$? "true" : "false" ); } -%printer { fprintf(yyo, "'%s'", $$ ); } -%printer { fprintf(yyo, "%s '%s'", +%printer { fprintf(stderr, "'%s'", $$ ); } +%printer { fprintf(stderr, "'%s'", $$? "true" : "false" ); } +%printer { fprintf(stderr, "%s '%s'", keyword_str($$.token), $$.string? $$.string : "" ); } -/* cppcheck-suppress invalidPrintfArgType_sint */ -%printer { fprintf(yyo, HOST_SIZE_T_PRINT_DEC " '%s'", - (fmt_size_t)$$.number, $$.string? $$.string : "" ); } - +// cppcheck-suppress invalidPrintfArgType_sint +%printer { fprintf(stderr, "%ld '%s'", + (long)$$.number, $$.string? $$.string : "" ); } + %type NAME NUMSTR LITERAL PSEUDOTEXT %type LSUB RSUB SUBSCRIPT %type namelit name_any name_one @@ -265,7 +336,10 @@ apply_cdf_turn( const exception_turn_t& turn ) { %left '*' '/' %right NEG 958 -%define api.prefix {ydf} +%require "3.8.2" // for C++ output +%language "c++" + +%define api.prefix {cdf} %define api.token.prefix{YDF_} %locations @@ -314,9 +388,11 @@ cdf_display: CDF_DISPLAY strings { } ; strings: LITERAL { + USED_TOKEN(LITERAL); display_msg = xstrdup($1); } | strings LITERAL { + USED_TOKEN(LITERAL); char *p = display_msg; display_msg = xasprintf("%s %s", p, $2); free(p); @@ -333,11 +409,11 @@ partials: partial } ; partial: cdf_if /* text */ - | CDF_ELSE { scanner_parsing_toggle(); } - | CDF_END_IF { scanner_parsing_pop(); } + | CDF_ELSE { USED_TOKEN(CDF_ELSE); scanner_parsing_toggle(); } + | CDF_END_IF { USED_TOKEN(CDF_END_IF); scanner_parsing_pop(); } | cdf_evaluate /* text */ | cdf_eval_when /* text */ - | CDF_END_EVALUATE { scanner_parsing_pop(); } + | CDF_END_EVALUATE { USED_TOKEN(CDF_END_EVALUATE); scanner_parsing_pop(); } ; cdf_define: CDF_DEFINE cdf_constant NAME as cdf_expr[value] override @@ -358,10 +434,7 @@ cdf_define: CDF_DEFINE cdf_constant NAME as cdf_expr[value] override } YYERROR; } - if( symbols_begin() < symbols_end() ) { - cbl_field_t field = cdf_literalize(@NAME, $NAME, $value); - symbol_field_add(current_program_index(), &field); - } + cdf_field_add( @NAME, $NAME, $value ); } | CDF_DEFINE cdf_constant NAME EQ cdf_expr[value] override @@ -372,6 +445,7 @@ cdf_define: CDF_DEFINE cdf_constant NAME as cdf_expr[value] override } | CDF_DEFINE cdf_constant NAME as OFF { + USED_TOKEN(OFF); cdfval_off( $NAME); } | CDF_DEFINE cdf_constant NAME as PARAMETER_kw override @@ -390,6 +464,7 @@ cdf_define: CDF_DEFINE cdf_constant NAME as cdf_expr[value] override } } | CDF_DEFINE FEATURE as ON { + USED_TOKEN(ON); auto feature = cbl_gcobol_feature_t($2); if( ! cobol_gcobol_feature_set(feature, true) ) { error_msg(@FEATURE, @@ -397,6 +472,7 @@ cdf_define: CDF_DEFINE cdf_constant NAME as cdf_expr[value] override } } | CDF_DEFINE FEATURE as OFF { + USED_TOKEN(OFF); auto feature = cbl_gcobol_feature_t($2); if( ! cobol_gcobol_feature_set(feature, false) ) { error_msg(@FEATURE, @@ -405,10 +481,12 @@ cdf_define: CDF_DEFINE cdf_constant NAME as cdf_expr[value] override } ; cdf_constant: %empty - | CONSTANT - ; + | CONSTANT { + USED_TOKEN(CONSTANT); + } + ; override: %empty { $$ = false; } - | OVERRIDE { $$ = true; } + | OVERRIDE { $$ = true; USED_TOKEN(OVERRIDE); } ; cdf_turn: TURN except_names except_check @@ -420,41 +498,43 @@ cdf_turn: TURN except_names except_check cdf_call_convention: CALL_COBOL { + USED_TOKEN(CALL_COBOL); current_call_convention(cbl_call_cobol_e); } | CALL_VERBATIM { + USED_TOKEN(CALL_VERBATIM); current_call_convention(cbl_call_verbatim_e); } ; cdf_push: CDF_PUSH cdf_stackable { switch( $cdf_stackable ) { - case YDF_ALL: cdf_push(); break; - case YDF_CALL_CONVENTION: cdf_push_call_convention(); break; - case YDF_CDF_DEFINE: cdf_push_dictionary(); break; - case YDF_COBOL_WORDS: cdf_push_current_tokens(); break; - case YDF_SOURCE_FORMAT: cdf_push_source_format(); break; - default: gcc_unreachable(); + case parser::token::YDF_ALL: cdf_push(); break; + case parser::token::YDF_CALL_CONVENTION: cdf_push_call_convention(); break; + case parser::token::YDF_CDF_DEFINE: cdf_push_dictionary(); break; + case parser::token::YDF_COBOL_WORDS: cdf_push_current_tokens(); break; + case parser::token::YDF_SOURCE_FORMAT: cdf_push_source_format(); break; + default: cdf_unreachable(); } } ; cdf_pop: CDF_POP cdf_stackable { switch( $cdf_stackable ) { - case YDF_ALL: cdf_pop(); break; - case YDF_CALL_CONVENTION: cdf_pop_call_convention(); break; - case YDF_CDF_DEFINE: cdf_pop_dictionary(); break; - case YDF_COBOL_WORDS: cdf_pop_current_tokens(); break; - case YDF_SOURCE_FORMAT: cdf_pop_source_format(); break; - default: gcc_unreachable(); + case parser::token::YDF_ALL: cdf_pop(); break; + case parser::token::YDF_CALL_CONVENTION: cdf_pop_call_convention(); break; + case parser::token::YDF_CDF_DEFINE: cdf_pop_dictionary(); break; + case parser::token::YDF_COBOL_WORDS: cdf_pop_current_tokens(); break; + case parser::token::YDF_SOURCE_FORMAT: cdf_pop_source_format(); break; + default: cdf_unreachable(); } } ; -cdf_stackable: ALL { $$ = YDF_ALL; } - | CALL_CONVENTION { $$ = YDF_CALL_CONVENTION; } - | COBOL_WORDS { $$ = YDF_COBOL_WORDS; } - | CDF_DEFINE { $$ = YDF_CDF_DEFINE; } - | SOURCE_FORMAT { $$ = YDF_SOURCE_FORMAT; } +cdf_stackable: ALL { $$ = parser::token::YDF_ALL; } + | CALL_CONVENTION { $$ = parser::token::YDF_CALL_CONVENTION; } + | COBOL_WORDS { $$ = parser::token::YDF_COBOL_WORDS; } + | CDF_DEFINE { $$ = parser::token::YDF_CDF_DEFINE; } + | SOURCE_FORMAT { $$ = parser::token::YDF_SOURCE_FORMAT; } ; except_names: except_name @@ -472,48 +552,55 @@ except_name: EXCEPTION_NAME[ec] { ; except_check: CHECKING on { $$ = exception_turn.enable(true); } - | CHECKING OFF { $$ = exception_turn.enable(false); } + | CHECKING OFF { + USED_TOKEN(OFF); + $$ = exception_turn.enable(false); + } | CHECKING on with LOCATION { + USED_TOKEN(LOCATION); $$ = exception_turn.enable(true, true); } ; filenames: filename { $$ = new std::set; - $$->insert(symbol_index(symbol_elem_of($1))); + $$->insert(cdf_file_index($1)); } | filenames filename { $$ = $1; - auto inserted = $$->insert(symbol_index(symbol_elem_of($2))); + auto inserted = $$->insert(cdf_file_index($2)); if( ! inserted.second ) { - error_msg(@2, "%s: No file-name shall be specified more than " - "once for one exception condition", $filename->name); + error_msg(@2, "%s: No file-name shall be specified more than once " + "for one exception condition", + cdf_file_name($filename)); } } ; filename: NAME { - struct symbol_elem_t *e = symbol_file(PROGRAM, $1); - if( !(e && e->type == SymFile) ) { + USED_TOKEN(NAME); + if( ($$ = cdf_file(PROGRAM, $1)) == nullptr ) { error_msg(@NAME, "invalid file name '%s'", $NAME); YYERROR; } - $$ = cbl_file_of(e); } ; cdf_if: CDF_IF cdf_cond_expr { - scanner_parsing(YDF_CDF_IF, $2); + scanner_parsing(parser::token::YDF_CDF_IF, $2); } | CDF_IF error { } CDF_END_IF { // not pushed, don't pop + USED_TOKEN(CDF_END_IF); if( ! scanner_parsing() ) YYACCEPT; } ; cdf_evaluate: CDF_EVALUATE cdf_expr - | CDF_EVALUATE TRUE_kw + | CDF_EVALUATE TRUE_kw { + USED_TOKEN(TRUE_kw); + } ; cdf_eval_when: CDF_WHEN cdf_eval_obj @@ -521,20 +608,26 @@ cdf_eval_when: CDF_WHEN cdf_eval_obj cdf_eval_obj: cdf_cond_expr | cdf_expr THRU cdf_expr - | OTHER + | OTHER { + USED_TOKEN(OTHER); + } ; -cdf_cond_expr: BOOL +cdf_cond_expr: BOOL { + USED_TOKEN(BOOL); + } | NAME DEFINED { + USED_TOKEN(DEFINED); cdf_values_t& dictionary( cdf_dictionary() ); auto p = dictionary.find($1); bool found = p != dictionary.end(); if( !$DEFINED ) found = ! found; $$ = found; if( found ) { - dbgmsg("CDF: %s found in dictionary (result %s)", - $1, $$? "true" : "false"); + const char *aint = $DEFINED? "" : "not "; + dbgmsg("CDF: %s %sfound in dictionary (result %s)", + $1, aint, $$? "true" : "false"); } else { dbgmsg("CDF: %s not found in dictionary (result %s)", $1, $$? "true" : "false"); @@ -542,6 +635,7 @@ cdf_cond_expr: BOOL } | cdf_bool_expr { $$ = $1(@1) == 0? false : true; } | FEATURE DEFINED { + USED_TOKEN(DEFINED); const auto& feature($1); $$ = (feature == int(feature & cbl_gcobol_features)); dbgmsg("CDF: feature 0x%02x is %s", $1, $$? "ON" : "OFF"); @@ -609,6 +703,7 @@ cdf_expr: cdf_expr '+' cdf_expr { $$ = $1(@1) + $3(@3); } ; cdf_factor: NAME { + USED_TOKEN(NAME); cdf_values_t& dictionary( cdf_dictionary() ); auto that = dictionary.find($1); if( that != dictionary.end() ) { @@ -623,9 +718,17 @@ cdf_factor: NAME { $$ = cdfval_t(); } } - | NUMBER { $$ = cdfval_t($1); } - | LITERAL { $$ = cdfval_t($1); } + | NUMBER + { + USED_TOKEN(NUMBER); + $$ = cdfval_t($1); + } + | LITERAL { + USED_TOKEN(LITERAL); + $$ = cdfval_t($1); + } | NUMSTR { + USED_TOKEN(NUMSTR); auto value = integer_literal($NUMSTR); if( !value.second ) { error_msg(@1, "CDF error: parsed %qs as %lld", @@ -669,16 +772,16 @@ replace_by: name_any[a] BY name_any[b] bool add_whitespace = false; replace_type_t type = {}; switch($a.token) { - case YDF_NUMSTR: - case YDF_LITERAL: + case parser::token::YDF_NUMSTR: + case parser::token::YDF_LITERAL: type = string_e; break; - case YDF_NAME: + case parser::token::YDF_NAME: type = token_e; break; - case YDF_PSEUDOTEXT: + case parser::token::YDF_PSEUDOTEXT: type = pseudo_e; - add_whitespace = $b.token != YDF_PSEUDOTEXT; + add_whitespace = $b.token != parser::token::YDF_PSEUDOTEXT; break; default: cbl_err("%s:%d: logic error on token %s", @@ -698,20 +801,23 @@ replace_by: name_any[a] BY name_any[b] suppress: %empty | SUPPRESS { + USED_TOKEN(SUPPRESS); copybook.suppress(); } ; name_any: namelit | PSEUDOTEXT { - $$ = cdf_arg_t{YDF_PSEUDOTEXT, $1}; + USED_TOKEN(PSEUDOTEXT); + $$ = cdf_arg_t{parser::token::YDF_PSEUDOTEXT, $1}; } ; name_one: NAME { + USED_TOKEN(NAME); cdf_values_t& dictionary( cdf_dictionary() ); - cdf_arg_t arg = { YDF_NAME, $1 }; + cdf_arg_t arg = { parser::token::YDF_NAME, $1 }; auto p = dictionary.find($1); if( p != dictionary.end() ) { @@ -719,14 +825,20 @@ name_one: NAME } $$ = arg; } - | NUMSTR { $$ = cdf_arg_t{YDF_NUMSTR, $1}; } - | LITERAL { $$ = cdf_arg_t{YDF_LITERAL, $1}; } + | NUMSTR { + USED_TOKEN(NUMSTR); + $$ = cdf_arg_t{parser::token::YDF_NUMSTR, $1}; + } + | LITERAL { + USED_TOKEN(LITERAL); + $$ = cdf_arg_t{parser::token::YDF_LITERAL, $1}; + } ; namelit: name { cdf_values_t& dictionary( cdf_dictionary() ); - cdf_arg_t arg = { YDF_NAME, $1 }; + cdf_arg_t arg = { parser::token::YDF_NAME, $1 }; auto p = dictionary.find($1); if( p != dictionary.end() ) { @@ -740,16 +852,19 @@ namelit: name free(const_cast($1)); free(const_cast($2)); - cdf_arg_t arg = { YDF_NAME, s }; + cdf_arg_t arg = { parser::token::YDF_NAME, s }; $$ = arg; } - | NUMSTR { $$ = cdf_arg_t{YDF_NUMSTR, $1}; } - | LITERAL { $$ = cdf_arg_t{YDF_LITERAL, $1}; } + | NUMSTR { $$ = cdf_arg_t{parser::token::YDF_NUMSTR, $1}; } + | LITERAL { $$ = cdf_arg_t{parser::token::YDF_LITERAL, $1}; } ; -name: NAME +name: NAME { + USED_TOKEN(NAME); + } | name inof NAME { + USED_TOKEN(NAME); char *s = xasprintf( "%s %s %s", $1, $2, $3 ); assert($$ == $1); free(const_cast($1)); @@ -757,13 +872,18 @@ name: NAME $$ = s; } ; -inof: IN { static const char in[] = "IN"; $$ = in; } - | OF { static const char of[] = "OF"; $$ = of; } +inof: IN { + USED_TOKEN(IN); + static const char in[] = "IN"; $$ = in; + } + | OF { + USED_TOKEN(OF); + static const char of[] = "OF"; $$ = of; + } ; subscripts: subscript - | subscripts subscript - { + | subscripts subscript { char *s = xasprintf("%s%s", $1, $2 ); if( $$ != $1 ) free(const_cast($$)); free(const_cast($1)); @@ -771,9 +891,12 @@ subscripts: subscript $$ = s; } ; -subscript: SUBSCRIPT +subscript: SUBSCRIPT { + USED_TOKEN(SUBSCRIPT); + } | LSUB subscript RSUB { + USED_TOKEN(RSUB); char *s = xasprintf( "%s%s%s", $1, $2, $3 ); free(const_cast($1)); free(const_cast($2)); @@ -783,23 +906,29 @@ subscript: SUBSCRIPT ; as: %empty - | AS + | AS { + USED_TOKEN(AS); + } ; on: %empty - | ON + | ON { + USED_TOKEN(ON); + } ; with: %empty - | WITH + | WITH { + USED_TOKEN(WITH); + } ; %% -static YYLTYPE cdf_location; +static cbl_loc_t cdf_location; -static YYLTYPE -location_set( const YYLTYPE& loc ) { +static cbl_loc_t +location_set( const cbl_loc_t& loc ) { return cdf_location = loc; } @@ -829,8 +958,8 @@ defined_cmd( const char arg[] ) if( yydebug ) { if( cdf_name->second.is_numeric() ) { - dbgmsg("%s: added -D %s = " HOST_SIZE_T_PRINT_DEC, - __func__, name, (fmt_size_t)cdf_name->second.as_number()); + dbgmsg("%s: added -D %s = %ld", + __func__, name, (long)cdf_name->second.as_number()); } else { dbgmsg("%s: added -D %s = \"%s\"", __func__, name, cdf_name->second.string); } @@ -921,13 +1050,6 @@ cdfval_t negate( cdfval_base_t lhs ) { return lhs; } -#undef yylex -int yylex(void); - -static int ydflex(void) { - return yylex(); -} - bool cdf_value( const char name[], const cdfval_t& value ) { cdf_values_t& dictionary( cdf_dictionary() ); @@ -950,7 +1072,7 @@ cdf_value( const char name[] ) { } static bool -verify_integer( const YDFLTYPE& loc, const cdfval_base_t& val ) { +verify_integer( const cbl_loc_t& loc, const cdfval_base_t& val ) { if( val.string ) { error_msg(loc, "'%s' is not an integer", val.string); return false; @@ -959,10 +1081,16 @@ verify_integer( const YDFLTYPE& loc, const cdfval_base_t& val ) { } const cdfval_base_t& -cdfval_base_t::operator()( const YDFLTYPE& loc ) { +cdfval_base_t::operator()( const cbl_loc_t& loc ) { static cdfval_t zero(0); // cppcheck-suppress returnTempReference return verify_integer(loc, *this) ? *this : zero; } - +namespace cdf { + void + parser::error(cbl_loc_t const& loc, std::string const& msg) { + error_msg(loc, msg.c_str()); + } +} + diff --git a/gcc/cobol/cdfval.h b/gcc/cobol/cdfval.h index b9d66002370..60428f5dcb8 100644 --- a/gcc/cobol/cdfval.h +++ b/gcc/cobol/cdfval.h @@ -46,12 +46,14 @@ bool scanner_parsing(); * We use the derived type cdfval_t, which can be properly constructed and * operated on, but tell Bison only about its POD base class. */ -struct YDFLTYPE; + +struct cbl_loc_t; + struct cdfval_base_t { bool off; const char *string; int64_t number; - const cdfval_base_t& operator()( const YDFLTYPE& loc ); + const cdfval_base_t& operator()( const cbl_loc_t& loc ); }; struct cdf_arg_t { @@ -101,6 +103,7 @@ struct cdfval_t : public cdfval_base_t { cdfval_base_t::string = NULL; cdfval_base_t::number = value; } +#if GCC_TYPES explicit cdfval_t( const REAL_VALUE_TYPE& r ) : lineno(yylineno), filename(cobol_filename()) { @@ -109,6 +112,7 @@ struct cdfval_t : public cdfval_base_t { HOST_WIDE_INT value = real_to_integer(&r); cdfval_base_t::number = value; } +#endif cdfval_t( const cdfval_base_t& value ) // cppcheck-suppress noExplicitConstructor : lineno(yylineno), filename(cobol_filename()) { diff --git a/gcc/cobol/copybook.h b/gcc/cobol/copybook.h index bead78eef74..9688ab789bf 100644 --- a/gcc/cobol/copybook.h +++ b/gcc/cobol/copybook.h @@ -33,6 +33,11 @@ #else #define _COPYBOOK_H +#if defined(CDF_Y) +#define gcc_assert(x) assert(x) +void gcc_unreachable(void); +#endif + FILE * copy_mode_start(); const char * cobol_filename(); @@ -60,7 +65,7 @@ class copybook_t; class copybook_elem_t { friend copybook_t; struct copybook_loc_t { - YYLTYPE loc; + cbl_loc_t loc; const char *name; copybook_loc_t() : loc(), name(NULL) {} } source, library; @@ -126,6 +131,11 @@ private: char *regex_text; }; +#ifndef TOUPPER +#define CTOUPPER(S) ::toupper(S) +#define TOUPPER(S) CTOUPPER(S) +#endif + class uppername_t { std::string upper; public: @@ -136,6 +146,11 @@ class uppername_t { const char *data() const { return upper.data(); } }; +#ifdef CTOUPPER +#undef CTOUPPER +#undef TOUPPER +#endif + class copybook_t { std::list directories; copybook_elem_t book; @@ -156,13 +171,13 @@ class copybook_t { void suppress( bool tf = true ) { book.suppress = tf; } bool suppressed() { return book.suppress; } - void source( const YYLTYPE& loc, const char name[] ) { + void source( const cbl_loc_t& loc, const char name[] ) { book.source.loc = loc; book.literally.source = copybook_elem_t::quoted(name); book.source.name = book.literally.source? copybook_elem_t::dequote(name) : transform_name(name); } - void library( const YYLTYPE& loc, const char name[] ) { + void library( const cbl_loc_t& loc, const char name[] ) { book.library.loc = loc; book.literally.library = copybook_elem_t::quoted(name); book.library.name = book.literally.library? @@ -177,7 +192,7 @@ class copybook_t { const char *source() const { return book.source.name; } const char *library() const { return book.library.name; } - int open(YYLTYPE loc, const char name[]) { + int open(cbl_loc_t loc, const char name[]) { int fd = -1; book.clear(); this->source(loc, name); diff --git a/gcc/cobol/exceptg.h b/gcc/cobol/exceptg.h index 80432a04eb7..815c9b42577 100644 --- a/gcc/cobol/exceptg.h +++ b/gcc/cobol/exceptg.h @@ -36,6 +36,8 @@ extern const char * ec_type_str( ec_type_t type ); extern ec_disposition_t ec_type_disposition( ec_type_t type ); +struct cbl_label_t; + extern void declarative_runtime_match( const std::list& declaratives, cbl_label_t *lave ); diff --git a/gcc/cobol/gcobc b/gcc/cobol/gcobc index 8bc78f79aaf..754a2b4da49 100755 --- a/gcc/cobol/gcobc +++ b/gcc/cobol/gcobc @@ -200,8 +200,6 @@ do continue fi - #cho "next arg: $opt" >&2 - case $opt in # pass next parameter to GCC @@ -233,7 +231,7 @@ do -echo) echo="echo" ;; - -fec=*) + -fec=* | -fno-ec=*) opt="$(echo "$opt" | sed -E 's/-f(no-)?ec=/-f\1cobol-exceptions=EC-/g')" opts="$opts $opt" ;; diff --git a/gcc/cobol/gcobol.1 b/gcc/cobol/gcobol.1 index 2fed7b713ce..97426966b52 100644 --- a/gcc/cobol/gcobol.1 +++ b/gcc/cobol/gcobol.1 @@ -157,9 +157,9 @@ output to indicate where copybook files were included. For line-number consistency with the input, blank lines are retained. .Pp Unlike the C compiler, This option does not prevent compilation. -To prevent compilation, use the option -.D1 Fl Sy fsyntax-only -also. +To prevent compilation, use the +.Fl Sy fsyntax-only +option. .It Fl fdefaultbyte Ns Li = Ns Ar value Use .Ar value , diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc index a02d7df4692..f883ab41f6e 100644 --- a/gcc/cobol/genapi.cc +++ b/gcc/cobol/genapi.cc @@ -7379,7 +7379,7 @@ parser_see_stop_run(struct cbl_refer_t exit_status, void parser_label_label(struct cbl_label_t *label) { - label->lain = yylineno; + label->lain = cobol_location().first_line; Analyze(); SHOW_PARSE { diff --git a/gcc/cobol/lang.opt b/gcc/cobol/lang.opt index f72277da1ca..faf657be8aa 100644 --- a/gcc/cobol/lang.opt +++ b/gcc/cobol/lang.opt @@ -22,6 +22,13 @@ ; Please try to keep this file in ASCII collating order. +; After modifying any *.opt file, including this one, also update the +; documentation with: +; +; make regenerate-opt-urls +; +; and include the *.opt.urls changes in the patch. + Language Cobol diff --git a/gcc/cobol/lexio.cc b/gcc/cobol/lexio.cc index d537e3f3fdb..40219955ba6 100644 --- a/gcc/cobol/lexio.cc +++ b/gcc/cobol/lexio.cc @@ -520,7 +520,7 @@ struct replacing_term_t { {} }; -extern YYLTYPE yylloc; +extern cbl_loc_t yylloc; static const char * last_newline (const char *p, const char *pend ) { @@ -934,9 +934,9 @@ struct copy_descr_t { : parsed(false), fd(-1), nreplace(0), partial_line(line, eol) {} }; -static YYLTYPE +static cbl_loc_t location_in( const filespan_t& mfile, const csub_match& cm ) { - YYLTYPE loc { + cbl_loc_t loc { int(mfile.lineno() + 1), int(mfile.colno() + 1), int(mfile.lineno() + 1), int(mfile.colno() + 1) }; @@ -1024,10 +1024,10 @@ parse_copy_directive( filespan_t& mfile ) { bool replacing = !cm[20].matched; if( library_name.matched ) { - YYLTYPE loc = location_in( mfile, library_name ); + cbl_loc_t loc = location_in( mfile, library_name ); copybook.library( loc, xstrndup(library_name.first, library_name.length()) ); } - YYLTYPE loc = location_in( mfile, copybook_name ); + cbl_loc_t loc = location_in( mfile, copybook_name ); outcome.fd = copybook.open( loc, xstrndup(copybook_name.first, copybook_name.length()) ); if( outcome.fd == -1 ) { // let parser report missing copybook diff --git a/gcc/cobol/lexio.h b/gcc/cobol/lexio.h index 03d97550f2b..4a7496ef9ee 100644 --- a/gcc/cobol/lexio.h +++ b/gcc/cobol/lexio.h @@ -181,8 +181,8 @@ struct filespan_t : public bytespan_t { return p == eol; } - YYLTYPE as_location() const { - YYLTYPE loc; + cbl_loc_t as_location() const { + cbl_loc_t loc; loc.first_line = loc.last_line = 1 + iline; loc.first_column = loc.last_column = 1 + icol; diff --git a/gcc/cobol/messages.cc b/gcc/cobol/messages.cc index 1c572307b4f..a6178e57420 100644 --- a/gcc/cobol/messages.cc +++ b/gcc/cobol/messages.cc @@ -285,7 +285,7 @@ cbl_diagnostic_option( cbl_diag_id_t id ) { * the framework. */ extern int yychar; -extern YYLTYPE yylloc; +extern cbl_loc_t yylloc; static const diagnostics::option_id option_zero; @@ -326,10 +326,7 @@ bool cbl_message( cbl_loc_t loc, cbl_diag_id_t id, const char gmsgid[], ... ) { gcc_location_set(yylloc); // use lookahead location } - explicit temp_loc_t( const YYLTYPE& loc) : orig(current_token_location()) { - gcc_location_set(loc); - } - explicit temp_loc_t( const YDFLTYPE& loc) : orig(current_token_location()) { + explicit temp_loc_t( const cbl_loc_t& loc) : orig(current_token_location()) { gcc_location_set(loc); } ~temp_loc_t() { diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y index e0d1620a772..04a6c966c7a 100644 --- a/gcc/cobol/parse.y +++ b/gcc/cobol/parse.y @@ -329,7 +329,13 @@ class locale_tgt_t { #include "inspect.h" } +%define api.location.type {cbl_loc_t} + %{ +// yyssa never freed: +// https://lists.nongnu.org/archive/html/help-bison/2021-01/msg00021.html +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" + #include "config.h" #include // Before cobol-system because it uses poisoned functions #include "cobol-system.h" @@ -934,7 +940,7 @@ class locale_tgt_t { declarative_list_t* dcl_list_t; isym_list_t* isym_list; struct { bool is_float; radix_t radix; char *string; } numstr; - struct { YYLTYPE loc; int token; literal_t name; } prog_end; + struct { cbl_loc_base_t loc; int token; literal_t name; } prog_end; struct { int token; special_name_t id; } special_type; struct { char locale_type; const char * name; } locale_phrase; coll_alphanat_t char_class_locales; @@ -1005,13 +1011,13 @@ class locale_tgt_t { struct cbl_ffi_arg_t *ffi_arg; struct ffi_args_t *ffi_args; - struct { YYLTYPE loc; cbl_refer_t *ffi_name, *ffi_returning; + struct { cbl_loc_base_t loc; cbl_refer_t *ffi_name, *ffi_returning; ffi_args_t *using_params; } ffi_impl; struct { bool common, initial, recursive; } comminit; struct { enum select_clause_t clause; cbl_file_t *file; } select_clause; struct { size_t clauses; cbl_file_t *file; } select_clauses; - struct { YYLTYPE loc; char *on, *off; } switches; + struct { cbl_loc_base_t loc; char *on, *off; } switches; struct { cbl_encoding_t encoding; cbl_domain_t *domain; } false_domain; struct { size_t also; unsigned char *low, *high; } colseq; struct { cbl_field_attr_t attr; int nbyte; } pic_part; @@ -1543,7 +1549,7 @@ class locale_tgt_t { cbl_field_t * new_literal( const cbl_loc_t loc, const literal_t& lit, enum cbl_field_attr_t attr ); - static YYLTYPE first_line_of( YYLTYPE loc ); + static cbl_loc_t first_line_of( cbl_loc_t loc ); %} %locations @@ -3308,8 +3314,7 @@ file_descrs: file_descr | file_descrs file_descr ; file_descr: fd_name '.' { field_done(); } fields - | fd_name fd_clauses '.' { field_done(); } - fields + | fd_name fd_clauses '.' { field_done(); } fields ; fd_name: FD NAME { $$ = file_section_fd_set(fd_e, $2, @2); } @@ -4383,8 +4388,7 @@ data_descr1: level_name $field->blank_initial($field->char_capacity()); } $field->encode_numeric($field->data.original(), - data_clause_locations[value_clause_e], - $field->data.original_numeric()); + data_clause_locations[value_clause_e]); } } } else { // no VALUE clause @@ -5526,7 +5530,9 @@ declaratives: %empty parser_label_label($label); enabled_exceptions = current.enabled_exception_cache; current.enabled_exception_cache.clear(); - ast_enter_section(implicit_section()); + cbl_loc_t loc(@4); // the dot + loc.first_line++; + ast_enter_section(loc, implicit_section()); } ; @@ -5542,7 +5548,7 @@ sentences: sentence { if( !label ) { YYERROR; } - ast_enter_paragraph(label); + ast_enter_paragraph(@para, label); current.new_paragraph(label); apply_declaratives(); } @@ -5559,7 +5565,7 @@ sentences: sentence { if( !label ) { YYERROR; } - ast_enter_paragraph(label); + ast_enter_paragraph(@para, label); current.new_paragraph(label); apply_declaratives(); } @@ -7905,14 +7911,14 @@ section_name: NAME section_kw '.' { statement_begin(@1, SECTION); $$ = label_add(@1, LblSection, $1); - ast_enter_section($$); + ast_enter_section(@1, $$); apply_declaratives(); } | NAME section_kw // lexer swallows '.' before USE