]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: Implement F2018 IMPORT statements [PR106135]
authorPaul Thomas <pault@gcc.gnu.org>
Fri, 11 Jul 2025 07:28:27 +0000 (08:28 +0100)
committerPaul Thomas <pault@gcc.gnu.org>
Fri, 11 Jul 2025 07:28:27 +0000 (08:28 +0100)
commit743c04db2f93612845e6baa7dabf9e511c3cfd85
tree2751d1e22d8df6093b99d74b04673dd6bc6a3eba
parent14076f15bf618d8febd1e4c6a86995f057408de8
Fortran:  Implement F2018 IMPORT statements [PR106135]

2025-09-09  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/106135
* decl.cc (build_sym): Emit an error if a symbol associated by
an IMPORT, ONLY or IMPORT, all statement is being redeclared.
(gfc_match_import): Parse and check the F2018 versions of the
IMPORT statement. For scopes other than and interface body, if
the symbol cannot be found in the host scope, generate it and
set it up such that gfc_fixup_sibling_symbols can transfer its
'imported attribute' if it turnes out to be a not yet parsed
procedure. Test for violations of C897-8100.
* gfortran.h : Add 'import_only' to the gfc_symtree structure.
Add the enum, 'importstate', which is used for values the new
field 'import_state' in gfc_namespace.
* parse.cc (gfc_fixup_sibling_symbols): Transfer the attribute
'imported' to the new symbol.
* resolve.cc (check_sym_import_status, check_import_status):
New functions to test symbols and expressions for violations of
F2018:C8102.
(resolve_call): Test the 'resolved_sym' against C8102 by a call
to 'check_sym_import_status'.
(gfc_resolve_expr): If the expression is OK and an IMPORT
statement has been registered in the current scope, test C102
by calling 'check_import_status'.
(resolve_select_type): Test the declared derived type in TYPE
IS and CLASS IS statements.

gcc/testsuite/
PR fortran/106135
* gfortran.dg/import3.f90: Use -std=f2008 and comment on change
in error message texts with f2018.
* gfortran.dg/import12.f90: New test.
gcc/fortran/decl.cc
gcc/fortran/gfortran.h
gcc/fortran/parse.cc
gcc/fortran/resolve.cc
gcc/testsuite/gfortran.dg/import12.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/import3.f90