From e11cd31fa0cce8210577ee46b6a33ee371f4fe64 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 5 Sep 2016 14:50:31 -0400 Subject: Fortran: Warn when dependency scanning fails to parse a source file We expect to handle all relevant statements and ignore those that we do not understand. Warn if this process ever fails. Otherwise dependency information may be silently left out. --- Source/cmDependsFortran.cxx | 6 ++++++ Source/cmFortranParser.h | 3 +++ Source/cmFortranParserImpl.cxx | 6 ++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 1eece98..b7e006d 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -130,6 +130,12 @@ bool cmDependsFortran::WriteDependencies(const std::set& sources, if (cmFortran_yyparse(parser.Scanner) != 0) { // Failed to parse the file. Report failure to write dependencies. okay = false; + /* clang-format off */ + std::cerr << + "warning: failed to parse dependencies from Fortran source " + "'" << src << "': " << parser.Error << std::endl + ; + /* clang-format on */ } } return okay; diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h index 5f1c7ac..57ad2af 100644 --- a/Source/cmFortranParser.h +++ b/Source/cmFortranParser.h @@ -146,6 +146,9 @@ struct cmFortranParser_s // Buffer for string literals. std::string TokenString; + // Error message text if a parser error occurs. + std::string Error; + // Flag for whether lexer is reading from inside an interface. bool InInterface; diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx index 71edf9f..d43d47c 100644 --- a/Source/cmFortranParserImpl.cxx +++ b/Source/cmFortranParserImpl.cxx @@ -164,11 +164,9 @@ int cmFortranParser_GetOldStartcond(cmFortranParser* parser) return parser->OldStartcond; } -void cmFortranParser_Error(cmFortranParser* /*unused*/, const char* /*unused*/) +void cmFortranParser_Error(cmFortranParser* parser, const char* msg) { - // If there is a parser error just ignore it. The source will not - // compile and the user will edit it. Then dependencies will have - // to be regenerated anyway. + parser->Error = msg ? msg : "unknown error"; } void cmFortranParser_RuleUse(cmFortranParser* parser, const char* name) -- cgit v0.12