This is a request to accept EXTERNAL AS literal in a file description entry, as cobc already does on a working-storage item, so that a file connector can be given an externalized name of its own. A patch is attached.
ext1.cob (attached, free format):
IDENTIFICATION DIVISION.
PROGRAM-ID. EXT1.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "ext1.dat"
ORGANIZATION IS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD F1 IS EXTERNAL AS "EXTF1".
01 F1-REC PIC X(4).
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
OPEN OUTPUT F1
MOVE "ABCD" TO F1-REC
WRITE F1-REC
CLOSE F1
OPEN INPUT F1
READ F1
DISPLAY F1-REC
CLOSE F1
STOP RUN.
cobc -x -free -std=cobol2014 -o ext1 ext1.cob
3.2.0 and 3.3-dev r5751 both stop with (source excerpts omitted)
ext1.cob:10: error: syntax error, unexpected AS, expecting EXTERNAL or GLOBAL
and exit 1, though FD F1 IS EXTERNAL. and 01 W1 PIC X(4) EXTERNAL AS "EXTW1". compile. The attached ext2.cob (three programs sharing one file under the externalized name SHARED, two of them through AS "SHARED") fails at both AS lines.
With the phrase supported, the program compiles and prints ABCD. ISO/IEC 1989:2023 13.4.5.2 and 13.18.22.2 give the entry as FD file-name-1 [ IS EXTERNAL [ AS literal-1 ] ] ..., and 13.18.22.4 general rule 5 says: "Literal-1, if specified, is the name of the file connector or record that is externalized to the operating environment." The same in 2002 and in the 2014 FCD.
In cobc/parser.y the EXTERNAL alternative of file_description_clause is _is EXTERNAL, without the _as_extname of the data items' external_clause, and code generation takes every externalized name from the file name: output_file_initialization uses f->cname for the connector and its status area, and output_internal_function names the record after the file name as written.
The attached n10-fd-external-as-literal.patch (against 3.3-dev r5751) adds the existing _as_literal rule after _is EXTERNAL and stores the literal, through cb_to_cname as for data items, in a new cb_file member ename, which code generation uses for the connector, its status and the record (ename, else cname). With the patch ext1 prints ABCD and ext2 prints
EXT2A: ABCD
EXT2B: EFGH
As for data items, the AS name is upper-cased, AS 123 is accepted, AS "" only warns (13.18.22.3 syntax rule 3), a duplicate externalized name in one program is not diagnosed (syntax rule 2), and a quotation mark in the literal breaks the generated C.
The patch also fixes a separate, existing bug without AS: FD SHARED-FILE IS EXTERNAL and FD shared-file IS EXTERNAL in two programs share the connector but not the record (13.18.22.4 general rule 4 b); the attached lc3.cob prints four NUL bytes between the brackets today (./lc3 | od -c) and LC3B: [ABCD] patched. Such a record, shared_file_Record today, is now externalized as SHARED_FILE_Record, so run units mixing modules compiled before and after the patch need recompiling. Nothing else changes in the C generated without AS.
It adds the testsuite case "EXTERNAL AS file" to run_file.at (one partner in lower case), with ChangeLog entries. make check: 1373 expected, 9 skipped, 0 failed (1372 unpatched); the new test fails without the patch.
bugs #212 (posts 7-8) agreed that a PROGRAM-ID's AS name should be case-sensitive, which bears on the upper-casing.
GnuCOBOL 3.2.0 (Ubuntu gnucobol3 3.2-4build1) and 3.3-dev r5751 (CI snapshot 3.3-dev.138 of 2026-10-29), x86_64 Linux, both run 2026-11-04. The error and the fix are the same without -std and with -std=cobol2002, ibm and mf; -std=cobol85, where AS is not reserved, is unchanged.