[PATCH] D117152: [flang] Allow initialization in blank COMMON

Peter Klausler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 13 15:07:55 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG63a2987d5111: [flang] Allow initialization in blank COMMON (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117152/new/

https://reviews.llvm.org/D117152

Files:
  flang/docs/Extensions.md
  flang/lib/Semantics/check-data.cpp
  flang/test/Semantics/data04.f90
  flang/test/Semantics/data14.f90


Index: flang/test/Semantics/data14.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/data14.f90
@@ -0,0 +1,16 @@
+! RUN: %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s
+! Verify varnings on nonconforming DATA statements
+! As a common extension, C876 violations are not errors.
+program main
+  type :: seqType
+    sequence
+    integer :: number
+  end type
+  type(seqType) :: x
+  integer :: j
+  common j, x, y
+  !CHECK: Blank COMMON object 'j' in a DATA statement is not standard
+  data j/1/
+  !CHECK: Blank COMMON object 'x' in a DATA statement is not standard
+  data x%number/2/
+end
Index: flang/test/Semantics/data04.f90
===================================================================
--- flang/test/Semantics/data04.f90
+++ flang/test/Semantics/data04.f90
@@ -134,19 +134,8 @@
 
   program new
     use m2
-    integer a
-    real    b,c
-    type seqType
-      sequence
-      integer number
-    end type
-    type(SeqType) num
-    COMMON b,a,c,num
     type(newType) m2_number2
     !C876
-    !ERROR: Blank COMMON object 'b' must not be initialized in a DATA statement
-    DATA b /1/
-    !C876
     !ERROR: USE-associated object 'm2_i' must not be initialized in a DATA statement
     DATA m2_i /1/
     !C876
@@ -155,7 +144,4 @@
     !C876
     !OK: m2_number2 is not associated through use association
     DATA m2_number2%number /1/
-    !C876
-    !ERROR: Blank COMMON object 'num' must not be initialized in a DATA statement
-    DATA num%number /1/
   end program
Index: flang/lib/Semantics/check-data.cpp
===================================================================
--- flang/lib/Semantics/check-data.cpp
+++ flang/lib/Semantics/check-data.cpp
@@ -63,7 +63,6 @@
                 : IsFunctionResult(symbol)     ? "Function result"
                 : IsAllocatable(symbol)        ? "Allocatable"
                 : IsInitialized(symbol, true)  ? "Default-initialized"
-                : IsInBlankCommon(symbol)      ? "Blank COMMON object"
                 : IsProcedure(symbol) && !IsPointer(symbol) ? "Procedure"
                 // remaining checks don't apply to components
                 : !isFirstSymbol                   ? nullptr
@@ -77,11 +76,17 @@
           "%s '%s' must not be initialized in a DATA statement"_err_en_US,
           whyNot, symbol.name());
       return false;
-    } else if (IsProcedurePointer(symbol)) {
+    }
+    if (IsProcedurePointer(symbol)) {
       context_.Say(source_,
           "Procedure pointer '%s' in a DATA statement is not standard"_en_US,
           symbol.name());
     }
+    if (IsInBlankCommon(symbol)) {
+      context_.Say(source_,
+          "Blank COMMON object '%s' in a DATA statement is not standard"_en_US,
+          symbol.name());
+    }
     return true;
   }
   bool operator()(const evaluate::Component &component) {
Index: flang/docs/Extensions.md
===================================================================
--- flang/docs/Extensions.md
+++ flang/docs/Extensions.md
@@ -196,6 +196,7 @@
   exactly one is unlimited polymorphic).
 * External unit 0 is predefined and connected to the standard error output,
   and defined as `ERROR_UNIT` in the intrinsic `ISO_FORTRAN_ENV` module.
+* Objects in blank COMMON may be initialized.
 
 ### Extensions supported when enabled by options
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117152.399804.patch
Type: text/x-patch
Size: 3361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220113/e8dc1a2b/attachment.bin>


More information about the llvm-commits mailing list