c-opts.c (warn_variadic_macros): New.

* c-opts.c (warn_variadic_macros): New.
        (c_common_handle_option): Set it.
        (sanitize_cpp_opts): Copy it to cpp_opts.
        * c.opt (Wvariadic-macros): New.
        * cpplib.h (struct cpp_options): Add warn_variadic_macros.
        * cppinit.c (cpp_create_reader): Initialize it.
        * cppmacro.c (parse_params): Check it.

From-SVN: r78125
This commit is contained in:
Richard Henderson 2004-02-19 14:18:50 -08:00 committed by Richard Henderson
parent 2df93cf3c4
commit e5b7921933
6 changed files with 36 additions and 2 deletions

View File

@ -1,3 +1,13 @@
2004-02-19 Richard Henderson <rth@redhat.com>
* c-opts.c (warn_variadic_macros): New.
(c_common_handle_option): Set it.
(sanitize_cpp_opts): Copy it to cpp_opts.
* c.opt (Wvariadic-macros): New.
* cpplib.h (struct cpp_options): Add warn_variadic_macros.
* cppinit.c (cpp_create_reader): Initialize it.
* cppmacro.c (parse_params): Check it.
2004-02-19 David Daney <ddaney@avtrex.com>
PR preprocessor/14198

View File

@ -88,6 +88,9 @@ static bool quote_chain_split;
/* If -Wunused-macros. */
static bool warn_unused_macros;
/* If -Wvariadic-macros. */
static bool warn_variadic_macros = true;
/* Number of deferred options. */
static size_t deferred_count;
@ -646,6 +649,10 @@ c_common_handle_option (size_t scode, const char *arg, int value)
warn_unused_macros = value;
break;
case OPT_Wvariadic_macros:
warn_variadic_macros = value;
break;
case OPT_Wwrite_strings:
if (!c_dialect_cxx ())
flag_const_strings = value;
@ -1360,6 +1367,11 @@ sanitize_cpp_opts (void)
cpp_opts->warn_long_long
= warn_long_long && ((!flag_isoc99 && pedantic) || warn_traditional);
/* Similarly with -Wno-variadic-macros. No check for c99 here, since
this also turns off warnings about GCCs extension. */
cpp_opts->warn_variadic_macros
= warn_variadic_macros && (pedantic || warn_traditional);
/* If we're generating preprocessor output, emit current directory
if explicitly requested or if debugging information is enabled.
??? Maybe we should only do it for debugging formats that

View File

@ -399,6 +399,10 @@ Wunused-macros
C ObjC C++ ObjC++
Warn about macros defined in the main file that are not used
Wvariadic-macros
C ObjC C++ ObjC++
Do not warn about using variadic macros when -pedantic
Wwrite-strings
C ObjC C++ ObjC++
Give strings the type \"array of char\"

View File

@ -147,6 +147,7 @@ cpp_create_reader (enum c_lang lang, hash_table *table,
CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99);
CPP_OPTION (pfile, dollars_in_ident) = 1;
CPP_OPTION (pfile, warn_dollars) = 1;
CPP_OPTION (pfile, warn_variadic_macros) = 1;
/* Default CPP arithmetic to something sensible for the host for the
benefit of dumb users like fix-header. */

View File

@ -283,6 +283,10 @@ struct cpp_options
promotions. */
unsigned char warn_num_sign_change;
/* Zero means don't warn about __VA_ARGS__ usage in c89 pedantic mode.
Presumably the usage is protected by the appropriate #ifdef. */
unsigned char warn_variadic_macros;
/* Nonzero means turn warnings into errors. */
unsigned char warnings_are_errors;

View File

@ -1327,11 +1327,14 @@ parse_params (cpp_reader *pfile, cpp_macro *macro)
_cpp_save_parameter (pfile, macro,
pfile->spec_nodes.n__VA_ARGS__);
pfile->state.va_args_ok = 1;
if (! CPP_OPTION (pfile, c99) && CPP_OPTION (pfile, pedantic))
if (! CPP_OPTION (pfile, c99)
&& CPP_OPTION (pfile, pedantic)
&& CPP_OPTION (pfile, warn_variadic_macros))
cpp_error (pfile, CPP_DL_PEDWARN,
"anonymous variadic macros were introduced in C99");
}
else if (CPP_OPTION (pfile, pedantic))
else if (CPP_OPTION (pfile, pedantic)
&& CPP_OPTION (pfile, warn_variadic_macros))
cpp_error (pfile, CPP_DL_PEDWARN,
"ISO C does not permit named variadic macros");