[flang] Response to Steve Scalpone's suggestion to improve a message
authorPete Steinfeld <psteinfeld@nvidia.com>
Wed, 6 May 2020 19:23:05 +0000 (12:23 -0700)
committerPete Steinfeld <psteinfeld@nvidia.com>
Wed, 6 May 2020 19:28:21 +0000 (12:28 -0700)
Summary: I updated the code that produces the message and the associated test.

Reviewers: sscalpone, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79514

flang/lib/Evaluate/check-expression.cpp
flang/test/Semantics/resolve89.f90

index 4368681..bf2432d 100644 (file)
@@ -207,8 +207,8 @@ public:
       return std::nullopt;
     } else if (scope_.IsDerivedType() && IsVariableName(symbol) &&
         specExprContext_ == SpecificationExprContext::BOUND) { // C750
-      return "reference to variable '"s + symbol.name().ToString() +
-          "' not allowed for derived type components";
+      return "derived type component not allowed to reference to variable '"s +
+          symbol.name().ToString() + "'";
     } else if (symbol.IsDummy()) {
       if (symbol.attrs().test(semantics::Attr::OPTIONAL)) {
         return "reference to OPTIONAL dummy argument '"s +
index 883970f..9583bfa 100644 (file)
@@ -58,7 +58,7 @@ subroutine s(iArg, allocArg, pointerArg, arrayArg, ioArg, optionalArg)
   real, dimension(iabs(iArg)) :: arrayVarWithIntrinsic
 
   type arrayType
-    !ERROR: Invalid specification expression: reference to variable 'var' not allowed for derived type components
+    !ERROR: Invalid specification expression: derived type component not allowed to reference to variable 'var'
     real, dimension(var) :: varField
     !ERROR: Invalid specification expression: reference to impure function 'ivolatilestmtfunc'
     real, dimension(iVolatileStmtFunc()) :: arrayFieldWithVolatile
@@ -66,7 +66,7 @@ subroutine s(iArg, allocArg, pointerArg, arrayArg, ioArg, optionalArg)
     real, dimension(iImpureStmtFunc()) :: arrayFieldWithImpureFunction
     !ERROR: Invalid specification expression: reference to statement function 'ipurestmtfunc'
     real, dimension(iPureStmtFunc()) :: arrayFieldWithPureFunction
-    !ERROR: Invalid specification expression: reference to variable 'iarg' not allowed for derived type components
+    !ERROR: Invalid specification expression: derived type component not allowed to reference to variable 'iarg'
     real, dimension(iabs(iArg)) :: arrayFieldWithIntrinsic
     !ERROR: Invalid specification expression: reference to intrinsic 'allocated' not allowed for derived type components
     real, dimension(merge(1, 2, allocated(allocArg))) :: realField1
@@ -74,7 +74,7 @@ subroutine s(iArg, allocArg, pointerArg, arrayArg, ioArg, optionalArg)
     real, dimension(merge(1, 2, associated(pointerArg))) :: realField2
     !ERROR: Invalid specification expression: non-constant reference to inquiry intrinsic 'is_contiguous' not allowed for derived type components
     real, dimension(merge(1, 2, is_contiguous(arrayArg))) :: realField3
-    !ERROR: Invalid specification expression: reference to variable 'ioarg' not allowed for derived type components
+    !ERROR: Invalid specification expression: derived type component not allowed to reference to variable 'ioarg'
     real, dimension(ioArg) :: realField4
     !ERROR: Invalid specification expression: reference to intrinsic 'present' not allowed for derived type components
     real, dimension(merge(1, 2, present(optionalArg))) :: realField5