diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp --- a/flang/lib/Semantics/mod-file.cpp +++ b/flang/lib/Semantics/mod-file.cpp @@ -861,13 +861,13 @@ parser::Message &ModFileReader::Say(const SourceName &name, const std::string &ancestor, parser::MessageFixedText &&msg, const std::string &arg) { - return context_ - .Say(name, - ancestor.empty() - ? "Error reading module file for module '%s'"_err_en_US - : "Error reading module file for submodule '%s' of module '%s'"_err_en_US, - name, ancestor) - .Attach(name, std::move(msg), arg); + return context_.Say(name, "Cannot read module file for %s: %s"_err_en_US, + parser::MessageFormattedText{ancestor.empty() + ? "module '%s'"_en_US + : "submodule '%s' of module '%s'"_en_US, + name, ancestor} + .MoveString(), + parser::MessageFormattedText{std::move(msg), arg}.MoveString()); } // program was read from a .mod file for a submodule; return the name of the diff --git a/flang/test/Flang-Driver/include-module.f90 b/flang/test/Flang-Driver/include-module.f90 --- a/flang/test/Flang-Driver/include-module.f90 +++ b/flang/test/Flang-Driver/include-module.f90 @@ -31,8 +31,8 @@ !----------------------------------------- ! EXPECTED OUTPUT FOR MISSING MODULE FILE !----------------------------------------- -! SINGLEINCLUDE:Error reading module file for module 'basictestmoduletwo' -! SINGLEINCLUDE-NOT:Error reading module file for module 'basictestmoduletwo' +! SINGLEINCLUDE:error: Cannot read module file for module 'basictestmoduletwo' +! SINGLEINCLUDE-NOT:error: Cannot read module file for module 'basictestmoduletwo' ! SINGLEINCLUDE-NOT:error: Derived type 't1' not found ! SINGLEINCLUDE:error: Derived type 't2' not found @@ -44,7 +44,7 @@ !--------------------------------------- ! EXPECTED OUTPUT FOR ALL MODULES FOUND !--------------------------------------- -! INCLUDED-NOT:Error reading module file +! INCLUDED-NOT:error: Cannot read module file ! INCLUDED-NOT:error: Derived type 't1' not found ! INCLUDED:error: Derived type 't2' not found diff --git a/flang/test/Semantics/resolve12.f90 b/flang/test/Semantics/resolve12.f90 --- a/flang/test/Semantics/resolve12.f90 +++ b/flang/test/Semantics/resolve12.f90 @@ -6,7 +6,7 @@ end use m1 -!ERROR: Error reading module file for module 'm2' +!ERROR: Cannot read module file for module 'm2': Source file 'm2.mod' was not found use m2 !ERROR: 'sub' is not a module use sub diff --git a/flang/test/Semantics/resolve26.f90 b/flang/test/Semantics/resolve26.f90 --- a/flang/test/Semantics/resolve26.f90 +++ b/flang/test/Semantics/resolve26.f90 @@ -16,10 +16,10 @@ submodule(m1) s1 end -!ERROR: Error reading module file for submodule 's1' of module 'm2' +!ERROR: Cannot read module file for submodule 's1' of module 'm2': Source file 'm2-s1.mod' was not found submodule(m2:s1) s2 end -!ERROR: Error reading module file for module 'm3' +!ERROR: Cannot read module file for module 'm3': Source file 'm3.mod' was not found submodule(m3:s1) s3 end