[flang-commits] [flang] 78acf7b - [flang] Enforce C1503 (#128962)

via flang-commits flang-commits at lists.llvm.org
Thu Feb 27 14:32:33 PST 2025


Author: Peter Klausler
Date: 2025-02-27T14:32:30-08:00
New Revision: 78acf7bb0a6e3a0948deece3d49f155cbc1ce891

URL: https://github.com/llvm/llvm-project/commit/78acf7bb0a6e3a0948deece3d49f155cbc1ce891
DIFF: https://github.com/llvm/llvm-project/commit/78acf7bb0a6e3a0948deece3d49f155cbc1ce891.diff

LOG: [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 https://github.com/llvm/llvm-project/issues/128744.

Added: 
    

Modified: 
    flang/lib/Semantics/check-declarations.cpp
    flang/test/Semantics/abstract02.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index bf4bb447c9526..c47f3d8aac99e 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -1562,6 +1562,14 @@ void CheckHelper::CheckSubprogram(
       messages_.Say(details.result().name(),
           "A function interface may not declare an assumed-length CHARACTER(*) result"_err_en_US);
     }
+    if (symbol.attrs().test(Attr::ABSTRACT) &&
+        (symbol.name() == "integer" || symbol.name() == "unsigned" ||
+            symbol.name() == "real" || symbol.name() == "complex" ||
+            symbol.name() == "character" ||
+            symbol.name() == "logical")) { // F'2023 C1503
+      messages_.Say(
+          "An ABSTRACT interface may not have the same name as an intrinsic type"_err_en_US);
+    }
   }
   CheckExternal(symbol);
   CheckModuleProcedureDef(symbol);

diff  --git a/flang/test/Semantics/abstract02.f90 b/flang/test/Semantics/abstract02.f90
index 29aad7b03e537..22183e445d5c6 100644
--- a/flang/test/Semantics/abstract02.f90
+++ b/flang/test/Semantics/abstract02.f90
@@ -4,6 +4,12 @@ program test
   abstract interface
     subroutine abstract
     end subroutine
+    !ERROR: An ABSTRACT interface may not have the same name as an intrinsic type
+    function integer()
+    end
+    !ERROR: An ABSTRACT interface may not have the same name as an intrinsic type
+    subroutine logical
+    end
   end interface
   procedure(abstract), pointer :: p
   !ERROR: Abstract procedure interface 'abstract' may not be referenced


        


More information about the flang-commits mailing list