[flang] Fix bug detecting intrinsic function
authorTim Keith <tkeith@nvidia.com>
Mon, 3 Aug 2020 19:21:57 +0000 (12:21 -0700)
committerTim Keith <tkeith@nvidia.com>
Mon, 3 Aug 2020 19:21:59 +0000 (12:21 -0700)
Don't set the INTRINSIC attribute on a dummy procedure.

Differential Revision: https://reviews.llvm.org/D85136

flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/symbol18.f90

index e85dfa9..c5b4247 100644 (file)
@@ -5749,7 +5749,8 @@ void ResolveNamesVisitor::HandleProcedureName(
     // error was reported
   } else {
     symbol = &Resolve(name, symbol)->GetUltimate();
-    if (ConvertToProcEntity(*symbol) && IsIntrinsic(symbol->name())) {
+    if (ConvertToProcEntity(*symbol) && IsIntrinsic(symbol->name()) &&
+        !IsDummy(*symbol)) {
       symbol->attrs().set(Attr::INTRINSIC);
       // 8.2(3): ignore type from intrinsic in type-declaration-stmt
       symbol->get<ProcEntityDetails>().set_interface(ProcInterface{});
index b7269b7..93987f6 100644 (file)
@@ -19,3 +19,13 @@ program p1
  !REF: /p1/x
  y = f(x)
 end program
+
+!DEF: /f2 (Function) Subprogram REAL(4)
+!DEF: /f2/cos EXTERNAL (Function, Implicit) ProcEntity REAL(4)
+!DEF: /f2/x (Implicit) ObjectEntity REAL(4)
+function f2(cos, x)
+ !DEF: /f2/f2 (Implicit) ObjectEntity REAL(4)
+ !REF: /f2/cos
+ !REF: /f2/x
+ f2 = cos(x)
+end function