flang-compiler / f18

F18 is a front-end for Fortran intended to replace the existing front-end in the Flang compiler
230 stars 48 forks source link

f18 build failure: "type 'const parser::DoConstruct *' cannot be narrowed to 'bool' in initializer list" #1079

Closed bcfriesen closed 4 years ago

bcfriesen commented 4 years ago

Hi,

a buildbot at NERSC choked on the following warning (upgraded to error with -Werror) when compiling f18 from a development version of clang 11:

[ 71%] Building CXX object lib/Semantics/CMakeFiles/FortranSemantics.dir/check-do-forall.cpp.o
cd /tmp.xF3Mbcy9gv/f18.git/build_f18/lib/Semantics && /tmp.K5QADP0XN0/llvm
/bin/clang++   -I/tmp.xF3Mbcy9gv/f18.git/include -I/tmp.xF3Mbcy9gv/f18.git
/build_f18/include -isystem /tmp.K5QADP0XN0/llvm/include  -std=c++17 -fno-rtti -fno-exceptions -pedant
ic -Wall -Wextra -Werror -Wcast-qual -Wimplicit-fallthrough -Wdelete-non-virtual-dtor -g -DDEBUGF18   -D_GNU_SOURCE -D_DEBUG -D__S
TDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -o CMakeFiles/FortranSemantics.dir/check-do-forall.cpp.o -c /tmp.xF3Mbcy9gv/f18.git/lib/Semantics/check-do-forall.cpp
/tmp.xF3Mbcy9gv/f18.git/lib/Semantics/check-do-forall.cpp:915:22: error: type 'const parser::DoConstru
ct *' cannot be narrowed to 'bool' in initializer list [-Wc++11-narrowing]
  bool inDoConstruct{MaybeGetDoConstruct(construct)};
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp.xF3Mbcy9gv/f18.git/lib/Semantics/check-do-forall.cpp:915:22: note: insert an explicit cast to sil
ence this issue
  bool inDoConstruct{MaybeGetDoConstruct(construct)};
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     static_cast<bool>(            )

The function in question is this one from check-do-forall.cpp:

 static bool StmtMatchesConstruct(const parser::Name *stmtName,
    StmtType stmtType, const parser::Name *constructName,
    const ConstructNode &construct) {
  bool inDoConstruct{MaybeGetDoConstruct(construct)};
  if (!stmtName) {
    return inDoConstruct;  // Unlabeled statements match all DO constructs
  } else if (constructName && constructName->source == stmtName->source) {
    return stmtType == StmtType::EXIT || inDoConstruct;
  } else {
    return false;
  }
}

The version of clang used to build f18:

clang version 11.0.0 (https://github.com/llvm/llvm-project.git 378b1e60809df7cc72436093f160b7ed228dad5a)
Target: x86_64-unknown-linux-gnu
Thread model: posix