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
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a10162d..a2db9c2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 43ae53b..0f2e6d1 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -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.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 16cc5f6..baa8415 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -9676,6 +9676,7 @@
 
 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 @@
   {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},
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 6093eb3..b701022 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -384,14 +384,6 @@
       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 @@
 	  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 @@
 	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 @@
 
   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.
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 643f256..d1c5c05 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -296,7 +296,7 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 ;
 
 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 @@
 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 @@
 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 @@
 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 @@
 ; 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 @@
 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 @@
 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
diff --git a/gcc/common.opt b/gcc/common.opt
index f7021102..7d78803 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -604,7 +604,7 @@
 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
diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi
index ac4452e..df52cdb 100644
--- a/gcc/doc/options.texi
+++ b/gcc/doc/options.texi
@@ -485,6 +485,7 @@
 
 @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
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index ef80c99..ecb225c 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -500,11 +500,20 @@
     }
 
     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:    "
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 462d1d3..2a7e605 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/cpp/endif-pedantic2.c b/gcc/testsuite/gcc.dg/cpp/endif-pedantic2.c
index 55cc5eb..fd014f6 100644
--- a/gcc/testsuite/gcc.dg/cpp/endif-pedantic2.c
+++ b/gcc/testsuite/gcc.dg/cpp/endif-pedantic2.c
@@ -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.  */
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index c1ac8c9..890b7fc 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -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.
diff --git a/libcpp/expr.c b/libcpp/expr.c
index 519bb87..003fcb0 100644
--- a/libcpp/expr.c
+++ b/libcpp/expr.c
@@ -1880,8 +1880,8 @@
     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;
     }
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 28fc0f8..28cb495 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -939,7 +939,9 @@
   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.  */
diff --git a/libcpp/init.c b/libcpp/init.c
index 2998d88..d612374 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -185,6 +185,7 @@
   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;
diff --git a/libcpp/macro.c b/libcpp/macro.c
index 8445ce3..8fa9770 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -1776,35 +1776,32 @@
 	    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))