[flang-commits] [PATCH] D143834: [flang] Catch repeated BIND(C) attribute specifications for a symbol

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Sat Feb 11 17:14:25 PST 2023


klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added subscribers: sunshaoce, jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

A BIND(C) attribute statement or type-declaration-stmt attribute, just
like most attributes, can only appear once.  Name resolution was excluding
the BIND(C) attribute from its check for duplicated attributes, but I
don't see a reason that remains to do so.


https://reviews.llvm.org/D143834

Files:
  flang/lib/Semantics/resolve-names.cpp
  flang/test/Semantics/bind-c02.f90
  flang/test/Semantics/declarations03.f90


Index: flang/test/Semantics/declarations03.f90
===================================================================
--- flang/test/Semantics/declarations03.f90
+++ flang/test/Semantics/declarations03.f90
@@ -32,6 +32,7 @@
   !ERROR: The entity 's1' has multiple BIND names
   integer :: s1
   bind(c, name="gg") :: s1
+  !ERROR: BIND_C attribute was already specified on 's1'
   bind(c, name="hh") :: s1
 
   !ERROR: Two entities have the same global name 'ii'
@@ -41,10 +42,12 @@
 
   !ERROR: The entity 's4' has multiple BIND names
   integer, bind(c, name="ss1") :: s4
+  !ERROR: BIND_C attribute was already specified on 's4'
   bind(c, name="jj") :: s4
 
   !ERROR: The entity 's5' has multiple BIND names
   bind(c, name="kk") :: s5
+  !ERROR: BIND_C attribute was already specified on 's5'
   integer, bind(c, name="ss2") :: s5
 
 end
Index: flang/test/Semantics/bind-c02.f90
===================================================================
--- flang/test/Semantics/bind-c02.f90
+++ flang/test/Semantics/bind-c02.f90
@@ -6,10 +6,10 @@
 module m
 
   interface
-    subroutine proc() bind(c)
+    subroutine proc()
     end
   end interface
-  procedure(proc), bind(c) :: pc1
+  procedure(proc) :: pc1
   !ERROR: Only variable and named common block can be in BIND statement
   bind(c) :: proc
   !ERROR: Only variable and named common block can be in BIND statement
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -2656,8 +2656,8 @@
 
 bool ScopeHandler::CheckDuplicatedAttr(
     SourceName name, const Symbol &symbol, Attr attr) {
-  if (attr == Attr::SAVE || attr == Attr::BIND_C) {
-    // these are checked elsewhere
+  if (attr == Attr::SAVE) {
+    // checked elsewhere
   } else if (symbol.attrs().test(attr)) { // C815
     if (symbol.implicitAttrs().test(attr)) {
       // Implied attribute is now confirmed explicitly


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143834.496726.patch
Type: text/x-patch
Size: 1991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230212/a25c6d01/attachment.bin>


More information about the flang-commits mailing list