Skip to content

Commit 78acf7b

Browse files
authored
[flang] Enforce C1503 (#128962)
Enforce an obscure constraint from the standard: an abstract interface is not allowed to have the same name as an intrinsic type keyword. I suspect this is meant to prevent a declaration like "PROCEDURE(REAL), POINTER :: P" from being ambiguous. Fixes #128744.
1 parent e843d51 commit 78acf7b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,14 @@ void CheckHelper::CheckSubprogram(
15621562
messages_.Say(details.result().name(),
15631563
"A function interface may not declare an assumed-length CHARACTER(*) result"_err_en_US);
15641564
}
1565+
if (symbol.attrs().test(Attr::ABSTRACT) &&
1566+
(symbol.name() == "integer" || symbol.name() == "unsigned" ||
1567+
symbol.name() == "real" || symbol.name() == "complex" ||
1568+
symbol.name() == "character" ||
1569+
symbol.name() == "logical")) { // F'2023 C1503
1570+
messages_.Say(
1571+
"An ABSTRACT interface may not have the same name as an intrinsic type"_err_en_US);
1572+
}
15651573
}
15661574
CheckExternal(symbol);
15671575
CheckModuleProcedureDef(symbol);

flang/test/Semantics/abstract02.f90

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ program test
44
abstract interface
55
subroutine abstract
66
end subroutine
7+
!ERROR: An ABSTRACT interface may not have the same name as an intrinsic type
8+
function integer()
9+
end
10+
!ERROR: An ABSTRACT interface may not have the same name as an intrinsic type
11+
subroutine logical
12+
end
713
end interface
814
procedure(abstract), pointer :: p
915
!ERROR: Abstract procedure interface 'abstract' may not be referenced

0 commit comments

Comments
 (0)