diff --git a/flang/lib/Semantics/check-select-type.cpp b/flang/lib/Semantics/check-select-type.cpp --- a/flang/lib/Semantics/check-select-type.cpp +++ b/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; diff --git a/flang/test/Semantics/selecttype01.f90 b/flang/test/Semantics/selecttype01.f90 --- a/flang/test/Semantics/selecttype01.f90 +++ b/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