[flang-commits] [PATCH] D135217: [flang] Supply missing source location for a message

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue Oct 4 15:12:33 PDT 2022


klausler created this revision.
klausler added a reviewer: clementval.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

An error message in semantic analysis of SELECT TYPE type guards
doesn't allow for the possibility of failure from FindSourceLocation(),
and that can happen when the type guard is just an intrinsic type
name like "type is (character)".  Deal with it.


https://reviews.llvm.org/D135217

Files:
  flang/lib/Semantics/check-select-type.cpp
  flang/test/Semantics/selecttype01.f90


Index: flang/test/Semantics/selecttype01.f90
===================================================================
--- flang/test/Semantics/selecttype01.f90
+++ flang/test/Semantics/selecttype01.f90
@@ -50,6 +50,8 @@
     select type ( a )
       !ERROR: The type specification statement must have LEN type parameter as assumed
       type is ( character(len=10) ) !<-- assumed length-type
+      !ERROR: The type specification statement must have LEN type parameter as assumed
+      type is ( character )
       ! OK
       type is ( character(len=*) )
       !ERROR: The type specification statement must have LEN type parameter as assumed
Index: flang/lib/Semantics/check-select-type.cpp
===================================================================
--- flang/lib/Semantics/check-select-type.cpp
+++ flang/lib/Semantics/check-select-type.cpp
@@ -94,7 +94,8 @@
                 }
                 if (spec->category() == DeclTypeSpec::Character &&
                     !guardDynamicType.IsAssumedLengthCharacter()) { // C1160
-                  context_.Say(parser::FindSourceLocation(typeSpec),
+                  auto location{parser::FindSourceLocation(typeSpec)};
+                  context_.Say(location.empty() ? stmt.source : location,
                       "The type specification statement must have "
                       "LEN type parameter as assumed"_err_en_US);
                   typeSpecRetVal = false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135217.465195.patch
Type: text/x-patch
Size: 1429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221004/9f772263/attachment-0001.bin>


More information about the flang-commits mailing list