Skip to content

Commit

Permalink
Add test that triggers a SEGFAULT in prototype checking
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Jan 31, 2024
1 parent 2ff35a3 commit 473a26c
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/testsuite.src/syn_misc.at
Original file line number Diff line number Diff line change
Expand Up @@ -5776,6 +5776,8 @@ prog.cob:8: error: syntax error, unexpected Literal
])
AT_CLEANUP

# Let's add a double quote here " to match the one in the error and
# please emacs coloring...

# normal register extension,
# active for lax and standard configurations
Expand Down Expand Up @@ -8348,3 +8350,43 @@ AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [1])

AT_CLEANUP


AT_SETUP([PROTOTYPE parameter validation])
AT_KEYWORDS([prototypes VALUE])

AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. f PROTOTYPE.
DATA DIVISION.
LINKAGE SECTION.
01 a PIC X(20).
01 b ANY LENGTH.
*> BINARY-C-INT usage does not exist: error on purpose to
*> trigger an error below
01 c USAGE BINARY-C-INT.
*> This one should also trigger an error, but does not...
78 d-const VALUE "abc".
PROCEDURE DIVISION
USING a
BY REFERENCE b
BY VALUE b
c
d-const
RETURNING OMITTED.
END PROGRAM f.
])

AT_CHECK([$COMPILE_ONLY -Wno-unfinished prog.cob], [134], [],
[prog.cob:10: error: unknown USAGE: BINARY-C-INT
prog.cob:16: error: ANY LENGTH items may only be BY REFERENCE formal parameters

cobc: ../../cobc/parser.y:11030: invalid cast from 'internal error node' type CONSTANT to type FIELD

cobc: aborting compile of prog.cob at line 18 (PROGRAM-ID: f)

cobc: Please report this!
Aborted (core dumped)
])

AT_CLEANUP

0 comments on commit 473a26c

Please sign in to comment.