This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH libcpp] Use CPP() for Wbuiltin-macro-redefined


The problem here is that builtin macros are marked with NO_WARN flag
depending on the value of Wbuiltin-macro-redefined, but this only
happens during libcpp initialization, so it doesn't work for #pragmas.
It neither works when using CPP(), since the default in the c.opt file
is set before libcpp initialization, overriding the default of libcpp.

The problem with #pragma is fixed in this patch by making NO_WARN
independent of the value of Wbuiltin-macro-redefined.

The problem with overriding the default in libcpp is fixed by setting
Init(1) in c.opt to match the default. However, it is too easy to
forget the Init(). It would be better if no Init() meant "use the
default of libcpp". This would require calling another generated
function just after initializing cpp_opts to set the defaults in
global_opts. Would that be ok? Or should I just set Init() explicitly
for every CPP()?

In any case, bootstrapped & regression tested x86_64-linux-gnu.


2014-08-23  Manuel López-Ibáñez  <>

    * macro.c (warn_of_redefinition): Suppress warnings for builtins
    that lack the NODE_WARN flag, unless Wbuiltin-macro-redefined.
    (_cpp_create_definition): Use Wbuiltin-macro-redefined for
    builtins that lack the NODE_WARN flag.
    * directives.c (do_undef): Likewise.
    * init.c (cpp_init_special_builtins): Do not change flags
    depending on Wbuiltin-macro-redefined.


2014-08-23  Manuel López-Ibáñez  <>

    * c.opt (Wbuiltin-macro-redefined): Use CPP, Var and Init.
    * c-opts.c (c_common_handle_option): Do not handle here.

Attachment: cpp_builtin_macro_redefined.diff
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]