Hi Christoph, > Le 26 janv. 2021 à 20:10, Christoph Grüninger <f...@grueninger.de> a écrit : > > Dear Bisons! > > I am still giving CMake's Bison code some love. I regenerated the code > using Bison 3.7.4. But Clang 11 with manually set > -Wused-but-marked-unused warns: > >> [ 56%] Building CXX object >> Source/CMakeFiles/CMakeLib.dir/LexerParser/cmFortranParser.cxx.o >> cmExprParser.cxx:774:54: warning: 'yysymbol_name' was marked unused but was >> used [-Wused-but-marked-unused] >> yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
They got to be kidding me!!! Attribute "unused" does not mean "unused", it means "*might* be unused". That's the way you tell your compiler to STFU when you have stuff that might, or might not, be used. The whole point of this attribute is to avoid warnings about possibly unused symbols. Even their documentation states it: https://clang.llvm.org/docs/AttributeReference.html#maybe-unused-unused > The [[maybe_unused]] (or __attribute__((unused))) attribute can be used to > silence such diagnostics when the entity cannot be removed. So the idea of having a counter-warning is... counter-productive. We just don't know if the code will use symbol_name or not, that depends on the user. So the attribute is *always* there to mean that it's ok if it's there and unused. But apparently clang is so eager to be the most warning-bloated compiler that they are genuine PITN and introduce warnings that contradict each other. What can I say? Don't enable that warning. Or use a good compiler and pass it --warning-clang to be protected against accidental uses of clang. Cheers!