options.texi: Document that Var and Init are required if CPP is given.

gcc/ChangeLog:

2014-09-04  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* doc/options.texi: Document that Var and Init are required if CPP
	is given.
	* optc-gen.awk: Require Var and Init if CPP is given.
	* common.opt (Wpedantic): Use Init.

libcpp/ChangeLog:

2014-09-04  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* macro.c (replace_args): Use cpp_pedwarning, cpp_warning and
	CPP_W flags.
	* include/cpplib.h: Add CPP_W_C90_C99_COMPAT and CPP_W_PEDANTIC.
	* init.c (cpp_create_reader): Do not init to -1 here.
	* expr.c (num_binary_op): Use cpp_pedwarning.

gcc/c-family/ChangeLog:

2014-09-04  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* c.opt (Wc90-c99-compat,Wc++-compat,Wcomment,Wendif-labels,
	Winvalid-pch,Wlong-long,Wmissing-include-dirs,Wmultichar,Wpedantic,
	(Wdate-time,Wtraditional,Wundef,Wvariadic-macros): Add CPP, Var
	and Init.
	* c-opts.c (c_common_handle_option): Do not handle here.
	(sanitize_cpp_opts): Likewise.
	* c-common.c (struct reason_option_codes_t): Handle
	CPP_W_C90_C99_COMPAT and CPP_W_PEDANTIC.

gcc/testsuite/ChangeLog:

2014-09-04  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* gcc.dg/cpp/endif-pedantic2.c: More general options do not
	override specific ones, but specific ones do.

From-SVN: r214904
This commit is contained in:
Manuel López-Ibáñez 2014-09-04 15:13:40 +00:00
parent 6bf5ce8f85
commit 2b71f4a4f8
15 changed files with 100 additions and 78 deletions

View File

@ -1,3 +1,10 @@
2014-09-04 Manuel López-Ibáñez <manu@gcc.gnu.org>
* doc/options.texi: Document that Var and Init are required if CPP
is given.
* optc-gen.awk: Require Var and Init if CPP is given.
* common.opt (Wpedantic): Use Init.
2014-09-04 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
* config/rs6000/rs6000.c (special_handling_values): Add

View File

@ -1,3 +1,14 @@
2014-09-04 Manuel López-Ibáñez <manu@gcc.gnu.org>
* c.opt (Wc90-c99-compat,Wc++-compat,Wcomment,Wendif-labels,
Winvalid-pch,Wlong-long,Wmissing-include-dirs,Wmultichar,Wpedantic,
(Wdate-time,Wtraditional,Wundef,Wvariadic-macros): Add CPP, Var
and Init.
* c-opts.c (c_common_handle_option): Do not handle here.
(sanitize_cpp_opts): Likewise.
* c-common.c (struct reason_option_codes_t): Handle
CPP_W_C90_C99_COMPAT and CPP_W_PEDANTIC.
2014-09-03 Marek Polacek <polacek@redhat.com>
* c.opt (Wlogical-not-parentheses): Enable by -Wall.

View File

@ -9676,6 +9676,7 @@ struct reason_option_codes_t
static const struct reason_option_codes_t option_codes[] = {
{CPP_W_BUILTIN_MACRO_REDEFINED, OPT_Wbuiltin_macro_redefined},
{CPP_W_C90_C99_COMPAT, OPT_Wc90_c99_compat},
{CPP_W_COMMENTS, OPT_Wcomment},
{CPP_W_CXX_OPERATOR_NAMES, OPT_Wc___compat},
{CPP_W_DATE_TIME, OPT_Wdate_time},
@ -9687,6 +9688,7 @@ static const struct reason_option_codes_t option_codes[] = {
{CPP_W_MISSING_INCLUDE_DIRS, OPT_Wmissing_include_dirs},
{CPP_W_MULTICHAR, OPT_Wmultichar},
{CPP_W_NORMALIZE, OPT_Wnormalized_},
{CPP_W_PEDANTIC, OPT_Wpedantic},
{CPP_W_TRADITIONAL, OPT_Wtraditional},
{CPP_W_TRIGRAPHS, OPT_Wtrigraphs},
{CPP_W_UNDEF, OPT_Wundef},

View File

@ -384,14 +384,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
cpp_opts->warn_num_sign_change = value;
break;
case OPT_Wc___compat:
cpp_opts->warn_cxx_operator_names = value;
break;
case OPT_Wlong_long:
cpp_opts->cpp_warn_long_long = value;
break;
case OPT_Wnormalized_:
/* FIXME: Move all this to c.opt. */
if (kind == DK_ERROR)
@ -415,10 +407,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
break;
}
case OPT_Wtraditional:
cpp_opts->cpp_warn_traditional = value;
break;
case OPT_Wunknown_pragmas:
/* Set to greater than 1, so that even unknown pragmas in
system headers will be warned about. */
@ -634,14 +622,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
error ("output filename specified twice");
break;
/* We need to handle the -Wpedantic switch here, rather than in
c_common_post_options, so that a subsequent -Wno-endif-labels
is not overridden. */
case OPT_Wpedantic:
cpp_opts->cpp_pedantic = 1;
cpp_opts->warn_endif_labels = 1;
break;
case OPT_print_objc_runtime_info:
print_struct_values = 1;
break;
@ -1269,20 +1249,19 @@ sanitize_cpp_opts (void)
cpp_opts->unsigned_char = !flag_signed_char;
cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
cpp_opts->cpp_warn_c90_c99_compat = warn_c90_c99_compat;
/* Wlong-long is disabled by default. It is enabled by:
[-Wpedantic | -Wtraditional] -std=[gnu|c]++98 ; or
[-Wpedantic | -Wtraditional] -std=non-c99 ; or
-Wc90-c99-compat, if specified.
[-Wpedantic | -Wtraditional] -std=non-c99
Either -Wlong-long or -Wno-long-long override any other settings. */
if (warn_long_long == -1 && warn_c90_c99_compat != -1)
warn_long_long = warn_c90_c99_compat;
else if (warn_long_long == -1)
warn_long_long = ((pedantic || warn_traditional)
&& (c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99));
cpp_opts->cpp_warn_long_long = warn_long_long;
Either -Wlong-long or -Wno-long-long override any other settings.
??? These conditions should be handled in c.opt. */
if (warn_long_long == -1)
{
warn_long_long = ((pedantic || warn_traditional)
&& (c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99));
cpp_opts->cpp_warn_long_long = warn_long_long;
}
/* If we're generating preprocessor output, emit current directory
if explicitly requested or if debugging information is enabled.

View File

@ -296,7 +296,7 @@ C ObjC C++ ObjC++ CPP(warn_builtin_macro_redefined) Var(cpp_warn_builtin_macro_r
Warn when a built-in preprocessor macro is undefined or redefined
Wc90-c99-compat
C ObjC Var(warn_c90_c99_compat) Init(-1) Warning
C ObjC CPP(cpp_warn_c90_c99_compat) Var(warn_c90_c99_compat) Init(-1) Warning
Warn about features not present in ISO C90, but present in ISO C99
Wc99-c11-compat
@ -304,7 +304,7 @@ C ObjC Var(warn_c99_c11_compat) Init(-1) Warning
Warn about features not present in ISO C99, but present in ISO C11
Wc++-compat
C ObjC Var(warn_cxx_compat) Warning
C ObjC Var(warn_cxx_compat) CPP(warn_cxx_operator_names) Init(0) Warning
Warn about C constructs that are not in the common subset of C and C++
Wc++0x-compat
@ -328,7 +328,7 @@ C ObjC C++ ObjC++ Var(warn_clobbered) Warning EnabledBy(Wextra)
Warn about variables that might be changed by \"longjmp\" or \"vfork\"
Wcomment
C ObjC C++ ObjC++ CPP(warn_comments) Var(cpp_warn_comment) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
C ObjC C++ ObjC++ CPP(warn_comments) Var(cpp_warn_comment) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
Warn about possibly nested block comments, and C++ comments spanning more than one physical line
Wcomments
@ -392,7 +392,7 @@ C ObjC C++ ObjC++ Var(warn_empty_body) Warning EnabledBy(Wextra)
Warn about an empty body in an if or else statement
Wendif-labels
C ObjC C++ ObjC++ CPP(warn_endif_labels) Var(cpp_warn_endif_labels) Init(1) Warning
C ObjC C++ ObjC++ CPP(warn_endif_labels) Var(cpp_warn_endif_labels) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
Warn about stray tokens after #elif and #endif
Wenum-compare
@ -503,7 +503,7 @@ C++ ObjC++ Var(warn_invalid_offsetof) Init(1) Warning
Warn about invalid uses of the \"offsetof\" macro
Winvalid-pch
C ObjC C++ ObjC++ CPP(warn_invalid_pch) Var(cpp_warn_invalid_pch) Warning
C ObjC C++ ObjC++ CPP(warn_invalid_pch) Var(cpp_warn_invalid_pch) Init(0) Warning
Warn about PCH files that are found but not used
Wjump-misses-init
@ -523,7 +523,7 @@ C ObjC C++ ObjC++ Var(warn_logical_not_paren) Warning LangEnabledBy(C ObjC C++ O
Warn when logical not is used on the left hand side operand of a comparison
Wlong-long
C ObjC C++ ObjC++ Var(warn_long_long) Init(-1) Warning
C ObjC C++ ObjC++ CPP(cpp_warn_long_long) Var(warn_long_long) Init(-1) Warning LangEnabledBy(C ObjC,Wc90-c99-compat)
Do not warn about using \"long long\" when -pedantic
Wmain
@ -583,7 +583,7 @@ C ObjC C++ ObjC++ Alias(Wsuggest-attribute=format)
;
Wmissing-include-dirs
C ObjC C++ ObjC++ CPP(warn_missing_include_dirs) Var(cpp_warn_missing_include_dirs) Warning
C ObjC C++ ObjC++ CPP(warn_missing_include_dirs) Var(cpp_warn_missing_include_dirs) Init(0) Warning
Warn about user-specified include directories that do not exist
Wmissing-parameter-type
@ -598,7 +598,7 @@ Wmudflap
C ObjC C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
Wmultichar
C ObjC C++ ObjC++ CPP(warn_multichar) Var(cpp_warn_multichar) Warning
C ObjC C++ ObjC++ CPP(warn_multichar) Var(cpp_warn_multichar) Init(0) Warning
Warn about use of multi-character character constants
Wnarrowing
@ -674,7 +674,7 @@ C ObjC C++ ObjC++ Var(warn_parentheses) Warning LangEnabledBy(C ObjC C++ ObjC++,
Warn about possibly missing parentheses
Wpedantic
C ObjC C++ ObjC++ Warning
C ObjC C++ ObjC++ CPP(cpp_pedantic) Warning
; Documented in common.opt
Wpmf-conversions
@ -702,7 +702,7 @@ C ObjC C++ ObjC++ Var(warn_pragmas) Init(1) Warning
Warn about misuses of pragmas
Wdate-time
C ObjC C++ ObjC++ CPP(warn_date_time) Var(cpp_warn_date_time) Warning
C ObjC C++ ObjC++ CPP(warn_date_time) Var(cpp_warn_date_time) Init(0) Warning
Warn about __TIME__, __DATE__ and __TIMESTAMP__ usage
Wproperty-assign-default
@ -786,7 +786,7 @@ C ObjC C++ ObjC++ Warning
; Documented in common.opt
Wtraditional
C ObjC Var(warn_traditional) Warning
C ObjC CPP(cpp_warn_traditional) Var(warn_traditional) Init(0) Warning
Warn about features not present in traditional C
Wtraditional-conversion
@ -802,7 +802,7 @@ ObjC ObjC++ Var(warn_undeclared_selector) Warning
Warn about @selector()s without previously declared methods
Wundef
C ObjC C++ ObjC++ CPP(warn_undef) Var(cpp_warn_undef) Warning
C ObjC C++ ObjC++ CPP(warn_undef) Var(cpp_warn_undef) Init(0) Warning
Warn if an undefined macro is used in an #if directive
Wuninitialized
@ -838,7 +838,7 @@ C ObjC C++ ObjC++ Var(warn_unused_result) Init(1) Warning
Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value
Wvariadic-macros
C ObjC C++ ObjC++ CPP(warn_variadic_macros) Var(cpp_warn_variadic_macros) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
C ObjC C++ ObjC++ CPP(warn_variadic_macros) Var(cpp_warn_variadic_macros) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
Warn about using variadic macros
Wvariadic-macros

View File

@ -604,7 +604,7 @@ Common Var(warn_padded) Warning
Warn when padding is required to align structure members
Wpedantic
Common Var(pedantic) Warning
Common Var(pedantic) Init(0) Warning
Issue warnings needed for strict compliance to the standard
Wreturn-local-addr

View File

@ -485,6 +485,7 @@ to determine if a precompiled header file matches.
@item CPP(@var{var})
The state of this option should be kept in sync with the preprocessor
option @var{var}.
option @var{var}. If this property is set, then properties @code{Var}
and @code{Init} must be set as well.
@end table

View File

@ -500,11 +500,20 @@ for (i = 0; i < n_opts; i++) {
}
cpp_option = nth_arg(0, opt_args("CPP", flags[i]));
opt_var_name = var_name(flags[i]);
if (cpp_option != "" && opt_var_name != "") {
print " case " opt_enum(opts[i]) ":"
print " cpp_opts->" cpp_option " = opts->x_" opt_var_name ";"
print " break;"
if (cpp_option != "") {
opt_var_name = var_name(flags[i]);
init = opt_args("Init", flags[i])
if (opt_var_name != "" && init != "") {
print " case " opt_enum(opts[i]) ":"
print " cpp_opts->" cpp_option " = opts->x_" opt_var_name ";"
print " break;"
} else if (opt_var_name == "" && init == "") {
print "#error CPP() requires setting Init() and Var() for " opts[i]
} else if (opt_var_name != "") {
print "#error CPP() requires setting Init() for " opts[i]
} else {
print "#error CPP() requires setting Var() for " opts[i]
}
}
}
print " default: "

View File

@ -1,3 +1,8 @@
2014-09-04 Manuel López-Ibáñez <manu@gcc.gnu.org>
* gcc.dg/cpp/endif-pedantic2.c: More general options do not
override specific ones, but specific ones do.
2014-09-04 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
* gcc.target/powerpc/swaps-p8-13.c: New test.

View File

@ -1,7 +1,7 @@
/* Copyright (C) 2002 Free Software Foundation, Inc. */
/* { dg-do preprocess } */
/* { dg-options "-Wno-endif-labels -pedantic-errors" } */
/* { dg-options "-Wno-endif-labels -pedantic-errors -Wendif-labels" } */
/* Tests combinations of -pedantic and -Wno-endif-labels; see extratokens2.c
for more general tests. */

View File

@ -1,3 +1,11 @@
2014-09-04 Manuel López-Ibáñez <manu@gcc.gnu.org>
* macro.c (replace_args): Use cpp_pedwarning, cpp_warning and
CPP_W flags.
* include/cpplib.h: Add CPP_W_C90_C99_COMPAT and CPP_W_PEDANTIC.
* init.c (cpp_create_reader): Do not init to -1 here.
* expr.c (num_binary_op): Use cpp_pedwarning.
2014-08-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
* directives.c (check_eol_1): New.

View File

@ -1880,8 +1880,8 @@ num_binary_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op)
default: /* case CPP_COMMA: */
if (CPP_PEDANTIC (pfile) && (!CPP_OPTION (pfile, c99)
|| !pfile->state.skip_eval))
cpp_error (pfile, CPP_DL_PEDWARN,
"comma operator in operand of #if");
cpp_pedwarning (pfile, CPP_W_PEDANTIC,
"comma operator in operand of #if");
lhs = rhs;
break;
}

View File

@ -939,7 +939,9 @@ enum {
CPP_W_INVALID_PCH,
CPP_W_WARNING_DIRECTIVE,
CPP_W_LITERAL_SUFFIX,
CPP_W_DATE_TIME
CPP_W_DATE_TIME,
CPP_W_PEDANTIC,
CPP_W_C90_C99_COMPAT
};
/* Output a diagnostic of some kind. */

View File

@ -185,6 +185,7 @@ cpp_create_reader (enum c_lang lang, cpp_hash_table *table,
CPP_OPTION (pfile, operator_names) = 1;
CPP_OPTION (pfile, warn_trigraphs) = 2;
CPP_OPTION (pfile, warn_endif_labels) = 1;
CPP_OPTION (pfile, cpp_warn_c90_c99_compat) = -1;
CPP_OPTION (pfile, cpp_warn_deprecated) = 1;
CPP_OPTION (pfile, cpp_warn_long_long) = 0;
CPP_OPTION (pfile, dollars_in_ident) = 1;

View File

@ -1776,35 +1776,32 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro,
paste_flag =
(const cpp_token **) tokens_buff_last_token_ptr (buff);
}
else if (CPP_PEDANTIC (pfile) && ! macro->syshdr
&& ! CPP_OPTION (pfile, c99)
&& ! cpp_in_system_header (pfile))
else if (CPP_PEDANTIC (pfile) && ! CPP_OPTION (pfile, c99)
&& ! macro->syshdr && ! cpp_in_system_header (pfile))
{
if (CPP_OPTION (pfile, cplusplus))
cpp_error (pfile, CPP_DL_PEDWARN,
"invoking macro %s argument %d: "
"empty macro arguments are undefined"
" in ISO C++98",
NODE_NAME (node),
src->val.macro_arg.arg_no);
cpp_pedwarning (pfile, CPP_W_PEDANTIC,
"invoking macro %s argument %d: "
"empty macro arguments are undefined"
" in ISO C++98",
NODE_NAME (node), src->val.macro_arg.arg_no);
else if (CPP_OPTION (pfile, cpp_warn_c90_c99_compat))
cpp_error (pfile, CPP_DL_PEDWARN,
"invoking macro %s argument %d: "
"empty macro arguments are undefined"
" in ISO C90",
NODE_NAME (node),
src->val.macro_arg.arg_no);
cpp_pedwarning (pfile,
CPP_OPTION (pfile, cpp_warn_c90_c99_compat) > 0
? CPP_W_C90_C99_COMPAT : CPP_W_PEDANTIC,
"invoking macro %s argument %d: "
"empty macro arguments are undefined"
" in ISO C90",
NODE_NAME (node), src->val.macro_arg.arg_no);
}
else if (CPP_OPTION (pfile, cpp_warn_c90_c99_compat) > 0
&& ! macro->syshdr
&& ! cpp_in_system_header (pfile)
&& ! CPP_OPTION (pfile, cplusplus))
cpp_error (pfile, CPP_DL_WARNING,
"invoking macro %s argument %d: "
"empty macro arguments are undefined"
" in ISO C90",
NODE_NAME (node),
src->val.macro_arg.arg_no);
&& ! CPP_OPTION (pfile, cplusplus)
&& ! macro->syshdr && ! cpp_in_system_header (pfile))
cpp_warning (pfile, CPP_W_C90_C99_COMPAT,
"invoking macro %s argument %d: "
"empty macro arguments are undefined"
" in ISO C90",
NODE_NAME (node), src->val.macro_arg.arg_no);
/* Avoid paste on RHS (even case count == 0). */
if (!pfile->state.in_directive && !(src->flags & PASTE_LEFT))