Commit e5b79219 by Richard Henderson Committed by Richard Henderson

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
parent 2df93cf3
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> 2004-02-19 David Daney <ddaney@avtrex.com>
PR preprocessor/14198 PR preprocessor/14198
......
...@@ -88,6 +88,9 @@ static bool quote_chain_split; ...@@ -88,6 +88,9 @@ static bool quote_chain_split;
/* If -Wunused-macros. */ /* If -Wunused-macros. */
static bool warn_unused_macros; static bool warn_unused_macros;
/* If -Wvariadic-macros. */
static bool warn_variadic_macros = true;
/* Number of deferred options. */ /* Number of deferred options. */
static size_t deferred_count; static size_t deferred_count;
...@@ -646,6 +649,10 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -646,6 +649,10 @@ c_common_handle_option (size_t scode, const char *arg, int value)
warn_unused_macros = value; warn_unused_macros = value;
break; break;
case OPT_Wvariadic_macros:
warn_variadic_macros = value;
break;
case OPT_Wwrite_strings: case OPT_Wwrite_strings:
if (!c_dialect_cxx ()) if (!c_dialect_cxx ())
flag_const_strings = value; flag_const_strings = value;
...@@ -1360,6 +1367,11 @@ sanitize_cpp_opts (void) ...@@ -1360,6 +1367,11 @@ sanitize_cpp_opts (void)
cpp_opts->warn_long_long cpp_opts->warn_long_long
= warn_long_long && ((!flag_isoc99 && pedantic) || warn_traditional); = 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 we're generating preprocessor output, emit current directory
if explicitly requested or if debugging information is enabled. if explicitly requested or if debugging information is enabled.
??? Maybe we should only do it for debugging formats that ??? Maybe we should only do it for debugging formats that
......
...@@ -399,6 +399,10 @@ Wunused-macros ...@@ -399,6 +399,10 @@ Wunused-macros
C ObjC C++ ObjC++ C ObjC C++ ObjC++
Warn about macros defined in the main file that are not used 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 Wwrite-strings
C ObjC C++ ObjC++ C ObjC C++ ObjC++
Give strings the type \"array of char\" Give strings the type \"array of char\"
......
...@@ -147,6 +147,7 @@ cpp_create_reader (enum c_lang lang, hash_table *table, ...@@ -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, warn_long_long) = !CPP_OPTION (pfile, c99);
CPP_OPTION (pfile, dollars_in_ident) = 1; CPP_OPTION (pfile, dollars_in_ident) = 1;
CPP_OPTION (pfile, warn_dollars) = 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 /* Default CPP arithmetic to something sensible for the host for the
benefit of dumb users like fix-header. */ benefit of dumb users like fix-header. */
......
...@@ -283,6 +283,10 @@ struct cpp_options ...@@ -283,6 +283,10 @@ struct cpp_options
promotions. */ promotions. */
unsigned char warn_num_sign_change; 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. */ /* Nonzero means turn warnings into errors. */
unsigned char warnings_are_errors; unsigned char warnings_are_errors;
......
...@@ -1327,11 +1327,14 @@ parse_params (cpp_reader *pfile, cpp_macro *macro) ...@@ -1327,11 +1327,14 @@ parse_params (cpp_reader *pfile, cpp_macro *macro)
_cpp_save_parameter (pfile, macro, _cpp_save_parameter (pfile, macro,
pfile->spec_nodes.n__VA_ARGS__); pfile->spec_nodes.n__VA_ARGS__);
pfile->state.va_args_ok = 1; 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, cpp_error (pfile, CPP_DL_PEDWARN,
"anonymous variadic macros were introduced in C99"); "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, cpp_error (pfile, CPP_DL_PEDWARN,
"ISO C does not permit named variadic macros"); "ISO C does not permit named variadic macros");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment