[flang-commits] [flang] e66ff2a - [flang] Supply missing source location for a message
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Oct 6 14:45:14 PDT 2022
Author: Peter Klausler
Date: 2022-10-06T14:40:53-07:00
New Revision: e66ff2a284de9067e63f89f056d8075def139b0b
URL: https://github.com/llvm/llvm-project/commit/e66ff2a284de9067e63f89f056d8075def139b0b
DIFF: https://github.com/llvm/llvm-project/commit/e66ff2a284de9067e63f89f056d8075def139b0b.diff
LOG: [flang] Supply missing source location for a message
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.
Differential Revision: https://reviews.llvm.org/D135217
Added:
Modified:
flang/lib/Semantics/check-select-type.cpp
flang/test/Semantics/selecttype01.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-select-type.cpp b/flang/lib/Semantics/check-select-type.cpp
index aca687bae386..d1c867c25344 100644
--- a/flang/lib/Semantics/check-select-type.cpp
+++ b/flang/lib/Semantics/check-select-type.cpp
@@ -94,7 +94,8 @@ class TypeCaseValues {
}
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;
diff --git a/flang/test/Semantics/selecttype01.f90 b/flang/test/Semantics/selecttype01.f90
index b2da4e95cd5d..f0b3e6ea103e 100644
--- a/flang/test/Semantics/selecttype01.f90
+++ b/flang/test/Semantics/selecttype01.f90
@@ -50,6 +50,8 @@ subroutine CheckC1160( a )
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
More information about the flang-commits
mailing list