+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
+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.
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},
{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},
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)
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. */
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;
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.
-
- 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;
+ [-Wpedantic | -Wtraditional] -std=non-c99
+
+ 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.
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
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
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
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
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
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
;
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
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
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
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
; 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
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
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
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
@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
}
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: "
+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.
/* 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. */
+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.
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;
}
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. */
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;
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))