Hi! On Wed, Aug 13, 2025 at 03:29:24PM +0200, Jakub Jelinek wrote: > My r16-3059 PR120778 change which introduced the -Wkeyword-macro option > and made it a default for C++26 -pedantic broke quite a few tests on > powerpc*. The problem is that the backend predefines bool and _Bool as > macros
The AltiVec PIM required this (or one of a few other options that get bool defined). > (unclear why _Bool for C++ because in C++ _Bool is not a keyword) Dunno. What does git history say? Hrm, you added it yourself, in 58195b740ddf :-) It has something to do with PR40017. "I'd say handling _Bool the same way as bool after vector would be a good idea." :-) > to make it a NODE_CONDITIONAL macro, so for e.g. -std=c++26 -pedantic-errors > we diagnose it on every TU as an error. > C++26 says that The AltiVec PIM was published in 1999. Quite a bit earlier :-) > PR target/121520 > * config/rs6000/rs6000-c.cc (rs6000_cpu_cpp_builtins): Temporarily > clear NODE_WARN flag on "bool" or "_Bool" around builtin_define > of those keywords if warn_keyword_macro. > > --- gcc/config/rs6000/rs6000-c.cc.jj 2025-04-08 14:08:49.819301801 +0200 > +++ gcc/config/rs6000/rs6000-c.cc 2025-08-13 09:00:07.115878529 +0200 > @@ -636,8 +636,30 @@ rs6000_cpu_cpp_builtins (cpp_reader *pfi > { > builtin_define ("vector=vector"); > builtin_define ("pixel=pixel"); > - builtin_define ("bool=bool"); > - builtin_define ("_Bool=_Bool"); > + if (warn_keyword_macro) > + { > + cpp_lookup (parse_in, > + (const unsigned char *) "bool", > + sizeof ("bool") - 1)->flags &= ~NODE_WARN; > + builtin_define ("bool=bool"); > + cpp_lookup (parse_in, > + (const unsigned char *) "bool", > + sizeof ("bool") - 1)->flags |= NODE_WARN; > + } > + else > + builtin_define ("bool=bool"); Hrm. Is there no more obvious way to do this? If you really want to bit-twiddle things here, can't you at least use sizeof ("bool") - 1)->flags ^= NODE_WARN; twice? It works correctly way more often (what you have does not always restore the original!) And a comment would help, of course. Why put this inside an "if" anyway, can't you disable the warning even if it won't ever fire anyway? > + if (warn_keyword_macro && !c_dialect_cxx ()) The warn_ flag at least seems superfluous. You might want a comment that this is what this is for though :-) Segher