[flang] Address review comments
authorpeter klausler <pklausler@nvidia.com>
Tue, 14 Jan 2020 19:24:49 +0000 (11:24 -0800)
committerpeter klausler <pklausler@nvidia.com>
Tue, 14 Jan 2020 19:24:49 +0000 (11:24 -0800)
Original-commit: flang-compiler/f18@d179c796bd7271916c52d8478e60a88bff809564
Reviewed-on: https://github.com/flang-compiler/f18/pull/926
Tree-same-pre-rewrite: false

flang/lib/semantics/check-declarations.cc
flang/test/semantics/altreturn05.f90 [new file with mode: 0644]

index 3791735..e688e3b 100644 (file)
@@ -361,8 +361,13 @@ void CheckHelper::CheckObjectEntity(
             "A variable in blank COMMON should not be initialized"_en_US);
       }
     } else if (symbol.owner().kind() == Scope::Kind::BlockData) {
-      messages_.Say(
-          "An initialized variable in BLOCK DATA must be in a COMMON block"_err_en_US);
+      if (IsAllocatable(symbol)) {
+        messages_.Say(
+            "An ALLOCATABLE variable may not appear in a BLOCK DATA subprogram"_err_en_US);
+      } else {
+        messages_.Say(
+            "An initialized variable in BLOCK DATA must be in a COMMON block"_err_en_US);
+      }
     }
   }
 }
diff --git a/flang/test/semantics/altreturn05.f90 b/flang/test/semantics/altreturn05.f90
new file mode 100644 (file)
index 0000000..6669942
--- /dev/null
@@ -0,0 +1,6 @@
+! Test extension: RETURN from main program
+
+return !ok
+!ERROR: RETURN with expression is only allowed in SUBROUTINE subprogram
+return 0
+end