[flang] Change a user error to an internal error in ALLOCATE semantic check
authorJean Perier <jperier@nvidia.com>
Tue, 7 May 2019 15:28:24 +0000 (08:28 -0700)
committerJean Perier <jperier@nvidia.com>
Tue, 7 May 2019 15:28:24 +0000 (08:28 -0700)
Original-commit: flang-compiler/f18@d9a9b59634761b328e1540ba9ef2b04c19318fd8

flang/lib/semantics/check-allocate.cc

index 074ae476542efb74acd8aae6adc5dc170f5225f7..08988d3e2cb11fb2b5db60f6a2ceba38e5359241 100644 (file)
@@ -108,12 +108,12 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
   if (const auto &typeSpec{
           std::get<std::optional<parser::TypeSpec>>(allocateStmt.t)}) {
     info.typeSpec = typeSpec->declTypeSpec;
-    info.gotTypeSpec = true;
-    info.typeSpecLoc = parser::FindSourceLocation(*typeSpec);
     if (!info.typeSpec) {
       CHECK(context.AnyFatalError());
       return std::nullopt;
     }
+    info.gotTypeSpec = true;
+    info.typeSpecLoc = parser::FindSourceLocation(*typeSpec);
     if (const DerivedTypeSpec * derived{info.typeSpec->AsDerived()}) {
       // C937
       if (const Symbol *
@@ -193,10 +193,7 @@ static std::optional<AllocateCheckerInfo> CheckAllocateOptions(
     if (const auto *expr{GetExpr(*parserSourceExpr)}) {
       info.sourceExprType = expr->GetType();
       if (!info.sourceExprType.has_value()) {
-        if (!context.AnyFatalError()) {
-          context.Say(parserSourceExpr->source,
-              "Source expression in ALLOCATE must be a valid expression"_err_en_US);
-        }
+        CHECK(context.AnyFatalError());
         return std::nullopt;
       }
       info.sourceExprRank = expr->Rank();