diff --git a/gcc/cobol/UAT/testsuite.src/syn_misc.at b/gcc/cobol/UAT/testsuite.src/syn_misc.at index 2e99aff04af9c3809399284ddaf223dc573024fe..2dac8355ebdf0d2268a940b84215e7ef7f82ef7a 100644 --- a/gcc/cobol/UAT/testsuite.src/syn_misc.at +++ b/gcc/cobol/UAT/testsuite.src/syn_misc.at @@ -195,9 +195,15 @@ AT_DATA([prog.cob], [ INITIALIZE C78, V. ]) AT_CHECK([$COMPILE_ONLY -dialect mf prog.cob], [1], [], -[prog.cob:10: error: 10 is a literal at 'CON' -prog.cob:12: error: 9 is a literal at '9' -prog.cob:13: error: C78 is a constant at 'V' +[prog.cob:10:23: error: 10 is a literal + 10 | INITIALIZE CON. + | ^ +prog.cob:12:26: error: 9 is a literal + 12 | INITIALIZE V, 9. + | ^ +prog.cob:13:23: error: C78 is a constant + 13 | INITIALIZE C78, V. + | ^ cobol1: error: failed compiling prog.cob ]) AT_CLEANUP @@ -216,8 +222,12 @@ AT_DATA([prog.cob], [ STOP RUN. ]) AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], -[[prog.cob:8: error: INSPECT cannot write to its argument -prog.cob:9: error: INSPECT cannot write to its argument +[[prog.cob:8:20: error: INSPECT cannot write to its argument + 8 | INSPECT FUNCTION TRIM(X) REPLACING ALL "ABC" BY "DEF". + | ^ +prog.cob:9:20: error: INSPECT cannot write to its argument + 9 | INSPECT FUNCTION TRIM(X) CONVERTING "ABC" TO "AAA". + | ^ cobol1: error: failed compiling prog.cob ]]) AT_CLEANUP @@ -321,15 +331,33 @@ AT_DATA([prog.cob], [ ]) AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], -[prog.cob:9: warning: section segment 49. ignored -prog.cob:12: warning: section segment 50. ignored -prog.cob:17: warning: section segment 00. ignored -prog.cob:20: warning: section segment 01. ignored -prog.cob:23: error: negative section segment -00. -prog.cob:26: warning: section segment 100. ignored -prog.cob:29: warning: section segment 49. ignored -prog.cob:32: warning: section segment 50. ignored -prog.cob:35: warning: section segment 99. ignored +[prog.cob:9:14: sorry, unimplemented: SECTION segment 49. was ignored + 9 | DEC-1 SECTION 49. + | ^ +prog.cob:12:14: sorry, unimplemented: SECTION segment 50. was ignored + 12 | DEC-2 SECTION 50. + | ^ +prog.cob:17:14: sorry, unimplemented: SECTION segment 00. was ignored + 17 | SEC-1 SECTION 00. + | ^ +prog.cob:20:14: sorry, unimplemented: SECTION segment 01. was ignored + 20 | SEC-2 SECTION 01. + | ^ +prog.cob:23:14: error: SECTION segment -00. is negative + 23 | SEC-3 SECTION -00. + | ^ +prog.cob:26:14: sorry, unimplemented: SECTION segment 100. was ignored + 26 | SEC-4 SECTION 100. + | ^ +prog.cob:29:14: sorry, unimplemented: SECTION segment 49. was ignored + 29 | SEC-5 SECTION 49. + | ^ +prog.cob:32:14: sorry, unimplemented: SECTION segment 50. was ignored + 32 | SEC-6 SECTION 50. + | ^ +prog.cob:35:14: sorry, unimplemented: SECTION segment 99. was ignored + 35 | SEC-7 SECTION 99. + | ^ cobol1: error: failed compiling prog.cob ]) AT_CLEANUP @@ -358,9 +386,15 @@ AT_DATA([prog.cob], [ ]) # cobc: compiles AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], -[prog.cob:9: no such environment mnemonic name: ESCAPE at 'ESCAPE' -prog.cob:11: no such environment mnemonic name: ESCAPE at 'ESCAPE' -prog.cob:13: syntax error at 'OMITTED' +[prog.cob:9:31: error: no such environment mnemonic name: ESCAPE + 9 | ACCEPT KEYNUM FROM ESCAPE KEY + | ^ +prog.cob:11:31: error: no such environment mnemonic name: ESCAPE + 11 | ACCEPT KEYNUM FROM ESCAPE + | ^ +prog.cob:13:19: error: syntax error, unexpected OMITTED + 13 | ACCEPT OMITTED + | ^ cobol1: error: failed compiling prog.cob ]) AT_CLEANUP @@ -428,13 +462,27 @@ AT_DATA([prog2.cob], [ ]) AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], -[prog.cob:11: error: symbol 'D3' not found at 'END-DISPLAY' -prog.cob:12: error: symbol '1E3' not found at 'END-DISPLAY' -prog.cob:13: error: symbol 'BLAH' not found at 'END-DISPLAY' -prog.cob:14: error: exponent includes decimal point at '1.0E3.0' -prog.cob:15: error: zero significand of -0.0E-0 cannot be negative at '-0.0E-0' -prog.cob:16: error: exponent 00003 more than 4 digits at '1.0E00003' -prog.cob:17: error: significand of .123456789012345678901234567890123456789E0 has more than 36 digits (39) +[prog.cob:11:23: error: DATA-ITEM 'D3' not found + 11 | DISPLAY 1.0D3 END-DISPLAY + | ^ +prog.cob:12:20: error: DATA-ITEM '1E3' not found + 12 | DISPLAY 1E3 END-DISPLAY + | ^ +prog.cob:13:27: error: DATA-ITEM 'BLAH' not found + 13 | DISPLAY '1.0E3'BLAH END-DISPLAY + | ^ +prog.cob:14:20: error: exponent includes decimal point + 14 | DISPLAY 1.0E3.0 END-DISPLAY + | ^ +prog.cob:15:20: error: zero significand of -0.0E-0 cannot be negative + 15 | DISPLAY -0.0E-0 END-DISPLAY + | ^ +prog.cob:16:20: error: exponent 00003 more than 4 digits + 16 | DISPLAY 1.0E00003 END-DISPLAY + | ^ +prog.cob:17:20: error: significand of .123456789012345678901234567890123456789E0 has more than 36 digits (39) + 17 | DISPLAY .123456789012345678901234567890123456789E0 + | ^ cobol1: error: failed compiling prog.cob ]) @@ -478,9 +526,10 @@ AT_DATA([prog2.cob], [ . ]) AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], -[prog.cob:7: error: ANY LENGTH valid only for 01 in LINKAGE SECTION of a function or contained program at 'LENGTH' -prog.cob:9: 1 errors in DATA DIVISION, compilation ceases at 'PROCEDURE DIVISION' -cobol1: error: failed compiling prog.cob +[prog2.cob:7:23: error: ANY LENGTH valid only for 01 in LINKAGE SECTION of a function or contained program + 7 | 01 str ANY LENGTH PIC X. + | ^ +cobol1: error: failed compiling prog2.cob ]) AT_CHECK([$COMPILE_ONLY prog2.cob], [1], [], [prog2.cob:7: error: ANY LENGTH valid only for 01 in LINKAGE SECTION of a function or contained program at 'LENGTH' @@ -506,8 +555,9 @@ AT_DATA([prog.cob], [ ]) AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], -[prog.cob:7: error: ANY LENGTH valid only for 01 in LINKAGE SECTION of a function or contained program at 'LENGTH' -prog.cob:9: 1 errors in DATA DIVISION, compilation ceases at 'PROCEDURE DIVISION' +[prog.cob:7:23: error: ANY LENGTH valid only for 01 in LINKAGE SECTION of a function or contained program + 7 | 01 str ANY LENGTH PIC X. + | ^ cobol1: error: failed compiling prog.cob ]) AT_CLEANUP @@ -530,7 +580,9 @@ AT_DATA([prog.cob], [ ]) AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], -[prog.cob:10: error: symbol 'CONVERSION' not found +[prog.cob:10:22: error: DATA-ITEM 'CONVERSION' not found + 10 | DISPLAY x CONVERSION. + | ^ cobol1: error: failed compiling prog.cob ]) AT_CLEANUP @@ -561,10 +613,18 @@ AT_DATA([prog.cob], [ END-EVALUATE. ]) AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], -[prog.cob:12: error: subject _stack2, type Conditional, cannot be compared a-variable, type NumericDisplay at 'CONTINUE' -prog.cob:14: error: WHEN clause incomplete, 1 of 2 evaluated at 'CONTINUE' -prog.cob:19: error: WHEN clause incomplete, 1 of 2 evaluated at 'CONTINUE' -prog.cob:21: error: WHEN clause incomplete, 1 of 2 evaluated at 'CONTINUE' +[prog.cob:11:20: error: subject _stack2, type Conditional, cannot be compared a-variable, type NumericDisplay + 11 | ALSO a-variable + | ^ +prog.cob:13:19: error: WHEN clause incomplete, 1 of 2 evaluated + 13 | WHEN 1 OR 2 + | ^ +prog.cob:18:19: error: WHEN clause incomplete, 1 of 2 evaluated + 18 | WHEN 3 + | ^ +prog.cob:20:19: error: WHEN clause incomplete, 1 of 2 evaluated + 20 | WHEN 5 + | ^ cobol1: error: failed compiling prog.cob ]) AT_CLEANUP @@ -606,13 +666,23 @@ AT_DATA([prog.cob], [ ]) AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], -[prog.cob:27: error: COUNT invalid-1 must be integer type at 'UNSTRING' -prog.cob:29: error: COUNT invalid-3 must be integer type at 'UNSTRING' -prog.cob:29: error: COUNT invalid-3 may not be P scaled at 'UNSTRING' -prog.cob:30: error: COUNT invalid-4 must be integer type at 'UNSTRING' -prog.cob:30: error: COUNT invalid-4 may not be P scaled at 'UNSTRING' -prog.cob:31: error: COUNT invalid-5 must be integer type at 'UNSTRING' -prog.cob:31: syntax error at 'invalid-6' +[prog.cob:26:36: error: COUNT invalid-1 must be integer type + 26 | UNSTRING x INTO y COUNT invalid-1 + | ^ +prog.cob:28:36: error: COUNT invalid-3 must be integer type + 28 | UNSTRING x INTO y COUNT invalid-3 + | ^ +prog.cob:28:36: error: COUNT invalid-3 may not be P scaled +prog.cob:29:36: error: COUNT invalid-4 must be integer type + 29 | UNSTRING x INTO y COUNT invalid-4 + | ^ +prog.cob:29:36: error: COUNT invalid-4 may not be P scaled +prog.cob:30:36: error: COUNT invalid-5 must be integer type + 30 | UNSTRING x INTO y COUNT invalid-5 + | ^ +prog.cob:31:36: error: syntax error, unexpected Level 88 NAME + 31 | UNSTRING x INTO y COUNT invalid-6 + | ^ cobol1: error: failed compiling prog.cob ]) AT_CLEANUP @@ -636,9 +706,12 @@ AT_DATA([prog.cob], [ ]) AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], -[prog.cob:12: error: invalid-1 must be signed for SIGN IS -prog.cob:13: error: invalid-2 is binary NUMERIC type, incompatible with SIGN IS -:14: 2 errors in DATA DIVISION, compilation ceases detected at end of file +[prog.cob:12:8: error: invalid-1 must be signed for SIGN IS + 12 | 01 invalid-1 PIC 99 SIGN LEADING. + | ^ +prog.cob:13:47: error: invalid-2 is binary NUMERIC type, incompatible with SIGN IS + 13 | 01 invalid-2 PIC S99 SIGN TRAILING, USAGE BINARY. + | ^ cobol1: error: failed compiling prog.cob ]) AT_CLEANUP @@ -688,7 +761,9 @@ AT_DATA([prog.cob], [ ]) AT_CHECK([$COMPILE prog.cob], [1], [], -[prog.cob:9: syntax error at ['('] +[prog.cob:9:23: error: syntax error, unexpected '(', expecting class name or OMITTED + 9 | IF num NOT (LESS OR EQUALS) 0 + | ^ cobol1: error: failed compiling prog.cob ]) AT_CLEANUP diff --git a/gcc/cobol/cdf.y b/gcc/cobol/cdf.y index 683f7e8c2c3550f368366b442d35665ab83a7ce4..cd96e963f70a73729ef0e45ab3d85728b2eb9bb8 100644 --- a/gcc/cobol/cdf.y +++ b/gcc/cobol/cdf.y @@ -319,7 +319,7 @@ complete: cdf_define */ cdf_display: CDF_DISPLAY strings { if( scanner_parsing() ) { - yywarn("%s", display_msg); + fprintf(stderr, "%s\n", display_msg); free(display_msg); display_msg = NULL; } diff --git a/gcc/cobol/scan_ante.h b/gcc/cobol/scan_ante.h index dd8293e0b4b00790d6b54673c35e329a8354e8cf..c071d8f316e2953a815d3b32d2c71bd76945e9c7 100644 --- a/gcc/cobol/scan_ante.h +++ b/gcc/cobol/scan_ante.h @@ -131,7 +131,7 @@ numstr_of( const char string[], radix_t radix = decimal_e ) { char *comma = strchr(yylval.numstr.string, ','); if( comma && comma[1] == '\0' ) *comma = '\0'; if( ! original_number(yylval.numstr.string) ) { - yyerror("input inconceivably long"); + error_msg(yylloc, "input inconceivably long"); return NO_CONDITION; } @@ -155,7 +155,7 @@ numstr_of( const char string[], radix_t radix = decimal_e ) { } auto nx = std::count_if(input, p, fisdigit); if( 36 < nx ) { - yyerror("significand of %s has more than 36 digits (%zu)", input, nx); + error_msg(yylloc, "significand of %s has more than 36 digits (%zu)", input, nx); return NO_CONDITION; } @@ -165,11 +165,11 @@ numstr_of( const char string[], radix_t radix = decimal_e ) { // exponent is implementor-defined." (We allow 9999.) nx = std::count_if(p, eoinput, fisdigit); if( 4 < nx ) { - yyerror("exponent %s more than 4 digits", ++p); + error_msg(yylloc, "exponent %s more than 4 digits", ++p); return NO_CONDITION; } if( eoinput != std::find(p, eoinput, symbol_decimal_point()) ) { - yyerror("exponent includes decimal point", ++p); + error_msg(yylloc, "exponent includes decimal point", ++p); return NO_CONDITION; } @@ -181,19 +181,19 @@ numstr_of( const char string[], radix_t radix = decimal_e ) { return !ISDIGIT(ch) || ch == '0'; } ); if( zero_signficand ) { if( p != std::find(input, p, '-') ) { - yyerror("zero significand of %s " + error_msg(yylloc, "zero significand of %s " "cannot be negative", input); return NO_CONDITION; } if( eoinput != std::find(p, eoinput, '-') ) { - yyerror("exponent of zero significand of %s " + error_msg(yylloc, "exponent of zero significand of %s " "cannot be negative", input); return NO_CONDITION; } } } if( 1 < std::count(input, eoinput, symbol_decimal_point()) ) { - yyerror("invalid numeric literal", ++p); + error_msg(yylloc, "invalid numeric literal", ++p); return NO_CONDITION; } @@ -307,7 +307,7 @@ void field_done() { orig_picture[0] = '\0'; parsing.need_level(true); } static int scanner_token() { if( parsing.empty() ) { - yyerror(">>ELSE or >>END-IF without >>IF"); + error_msg(yylloc, ">>ELSE or >>END-IF without >>IF"); return NO_CONDITION; } return parsing.top().token; @@ -326,7 +326,7 @@ void scanner_parsing( int token, bool tf ) { } void scanner_parsing_toggle() { if( parsing.empty() ) { - yyerror(">>ELSE without >>IF"); + error_msg(yylloc, ">>ELSE without >>IF"); return; } parsing.top().toggle(); @@ -337,7 +337,7 @@ void scanner_parsing_toggle() { } void scanner_parsing_pop() { if( parsing.empty() ) { - yyerror(">>END-IF without >>IF"); + error_msg(yylloc, ">>END-IF without >>IF"); return; } parsing.pop();