Commit e11cd31f authored by Brad King's avatar Brad King
Browse files

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.
parent 8317ea01
......@@ -130,6 +130,12 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& 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;
......
......@@ -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;
......
......@@ -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)
......
  • mentioned in commit f506489d

    Toggle commit list
  • Hello,

    with CMake version: 3.10.2 we are getting these warnings, and we have no cluse why Fortran parsing failed:

    [ 64%] Building Fortran object src/reladc/CMakeFiles/reladc.dir/polprp_cousat.F.o
    [ 64%] Building Fortran object src/luciarel/CMakeFiles/luciarel.dir/vecmat_r.F.o
    [ 64%] Building Fortran object src/luciarel/CMakeFiles/luciarel.dir/io_ttss_r.F90.o
    [ 64%] Built target luciarel
    Scanning dependencies of target krcc
    warning: failed to parse dependencies from Fortran source '/builds/dirac/dirac/src/krcc/krcc_inp.F': syntax error, unexpected WORD
    [ 64%] Building Fortran object src/krcc/CMakeFiles/krcc.dir/cc_vec_fnc2.F.o
    [ 64%] Building Fortran object src/krcc/CMakeFiles/krcc.dir/optimization.F.o

    Wouldn't you any clue ? On local machine parsing works, but it has lower Cmake version.

  • @miro.ilias please open an issue for this. That will be a more suitable location for discussion.

  • mentioned in issue #18014 (closed)

    Toggle commit list
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment