[flang] Simply use context_.Say. Update test with duplicate dealloc opts.
authorSteve Scalpone <sscalpone@nvidia.com>
Thu, 11 Apr 2019 16:39:32 +0000 (09:39 -0700)
committerSteve Scalpone <sscalpone@nvidia.com>
Thu, 11 Apr 2019 16:39:32 +0000 (09:39 -0700)
Original-commit: flang-compiler/f18@61b7461552e69be3dde1059f597bd5140d50da8c
Reviewed-on: https://github.com/flang-compiler/f18/pull/401

flang/lib/semantics/check-deallocate.cc
flang/test/semantics/deallocate04.f90

index e70de6f..b25d3de 100644 (file)
@@ -28,10 +28,10 @@ void DeallocateChecker::Leave(const parser::DeallocateStmt &deallocateStmt) {
             [&](const parser::Name &name) {
               auto const *symbol{name.symbol};
               if (!IsVariableName(*symbol)) {
-                context_.messages().Say(name.source,
+                context_.Say(name.source,
                     "name in DEALLOCATE statement must be a variable name"_err_en_US);
               } else if (!IsAllocatableOrPointer(*symbol)) {  // C932
-                context_.messages().Say(name.source,
+                context_.Say(name.source,
                     "name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute"_err_en_US);
               }
             },
@@ -40,7 +40,7 @@ void DeallocateChecker::Leave(const parser::DeallocateStmt &deallocateStmt) {
               if (MaybeExpr checked{analyzer.Analyze(structureComponent)}) {
                 if (!IsAllocatableOrPointer(
                         *structureComponent.component.symbol)) {  // C932
-                  context_.messages().Say(structureComponent.component.source,
+                  context_.Say(structureComponent.component.source,
                       "component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute"_err_en_US);
                 }
               }
@@ -48,7 +48,6 @@ void DeallocateChecker::Leave(const parser::DeallocateStmt &deallocateStmt) {
         },
         allocateObject.u);
   }
-  // The parser is catching dups too
   bool gotStat{false}, gotMsg{false};
   for (const parser::StatOrErrmsg &deallocOpt :
       std::get<std::list<parser::StatOrErrmsg>>(deallocateStmt.t)) {
index 52c6f93..68649cf 100644 (file)
@@ -66,4 +66,13 @@ Deallocate(x%p, stat=s, errmsg=e)
 !ERROR: Must have default CHARACTER type
 Deallocate(x%p, stat=r, errmsg=e)
 
+!ERROR: STAT may not be duplicated in a DEALLOCATE statement
+Deallocate(x, stat=s, stat=s)
+!ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
+Deallocate(x, errmsg=ee, errmsg=ee)
+!ERROR: STAT may not be duplicated in a DEALLOCATE statement
+Deallocate(x, stat=s, errmsg=ee, stat=s)
+!ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
+Deallocate(x, stat=s, errmsg=ee, errmsg=ee)
+
 End Program