directives.c (check_eol_1): New.

libcpp/ChangeLog:

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

	* directives.c (check_eol_1): New.
	(check_eol_endif_labels): New.
	(check_eol): Call check_eol_1.
	(do_else,do_endif): Call check_eol_endif_labels.

gcc/c-family/ChangeLog:

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

	* c.opt (Wbuiltin-macro-redefined,Wdeprecated,Wendif-labels,
	Winvalid-pch,Wliteral-suffix,Wmissing-include-dirs,Wtrigraphs,
	Wundef): Use CPP, Var and Init.
	* c-opts.c (c_common_handle_option): Do not handle the above flags here.

From-SVN: r214735
parent f71f9d3f
2014-08-29 Manuel López-Ibáñez <manu@gcc.gnu.org> 2014-08-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
* c.opt (Wbuiltin-macro-redefined,Wdeprecated,Wendif-labels,
Winvalid-pch,Wliteral-suffix,Wmissing-include-dirs,Wtrigraphs,
Wundef): Use CPP, Var and Init.
* c-opts.c (c_common_handle_option): Do not handle the above flags here.
2014-08-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
* c.opt (Wbuiltin-macro-redefined): Use CPP, Var and Init. * c.opt (Wbuiltin-macro-redefined): Use CPP, Var and Init.
* c-opts.c (c_common_handle_option): Do not handle here. * c-opts.c (c_common_handle_option): Do not handle here.
......
...@@ -381,7 +381,6 @@ c_common_handle_option (size_t scode, const char *arg, int value, ...@@ -381,7 +381,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
case OPT_Wall: case OPT_Wall:
/* ??? Don't add new options here. Use LangEnabledBy in c.opt. */ /* ??? Don't add new options here. Use LangEnabledBy in c.opt. */
cpp_opts->warn_trigraphs = value;
cpp_opts->warn_num_sign_change = value; cpp_opts->warn_num_sign_change = value;
break; break;
...@@ -389,29 +388,10 @@ c_common_handle_option (size_t scode, const char *arg, int value, ...@@ -389,29 +388,10 @@ c_common_handle_option (size_t scode, const char *arg, int value,
cpp_opts->warn_cxx_operator_names = value; cpp_opts->warn_cxx_operator_names = value;
break; break;
case OPT_Wdeprecated:
cpp_opts->cpp_warn_deprecated = value;
break;
case OPT_Wendif_labels:
cpp_opts->warn_endif_labels = value;
break;
case OPT_Winvalid_pch:
cpp_opts->warn_invalid_pch = value;
break;
case OPT_Wliteral_suffix:
cpp_opts->warn_literal_suffix = value;
break;
case OPT_Wlong_long: case OPT_Wlong_long:
cpp_opts->cpp_warn_long_long = value; cpp_opts->cpp_warn_long_long = value;
break; break;
case OPT_Wmissing_include_dirs:
cpp_opts->warn_missing_include_dirs = value;
break;
case OPT_Wnormalized_: case OPT_Wnormalized_:
/* FIXME: Move all this to c.opt. */ /* FIXME: Move all this to c.opt. */
if (kind == DK_ERROR) if (kind == DK_ERROR)
...@@ -439,14 +419,6 @@ c_common_handle_option (size_t scode, const char *arg, int value, ...@@ -439,14 +419,6 @@ c_common_handle_option (size_t scode, const char *arg, int value,
cpp_opts->cpp_warn_traditional = value; cpp_opts->cpp_warn_traditional = value;
break; break;
case OPT_Wtrigraphs:
cpp_opts->warn_trigraphs = value;
break;
case OPT_Wundef:
cpp_opts->warn_undef = value;
break;
case OPT_Wunknown_pragmas: case OPT_Wunknown_pragmas:
/* Set to greater than 1, so that even unknown pragmas in /* Set to greater than 1, so that even unknown pragmas in
system headers will be warned about. */ system headers will be warned about. */
......
...@@ -368,7 +368,7 @@ LangEnabledBy(C++ ObjC++,Weffc++) ...@@ -368,7 +368,7 @@ LangEnabledBy(C++ ObjC++,Weffc++)
; ;
Wdeprecated Wdeprecated
C C++ ObjC ObjC++ Var(warn_deprecated) Init(1) Warning C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) Var(warn_deprecated) Init(1) Warning
Warn if a deprecated compiler feature, class, method, or field is used Warn if a deprecated compiler feature, class, method, or field is used
Wdesignated-init Wdesignated-init
...@@ -392,7 +392,7 @@ C ObjC C++ ObjC++ Var(warn_empty_body) Warning EnabledBy(Wextra) ...@@ -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 Warn about an empty body in an if or else statement
Wendif-labels Wendif-labels
C ObjC C++ ObjC++ Warning C ObjC C++ ObjC++ CPP(warn_endif_labels) Var(cpp_warn_endif_labels) Init(1) Warning
Warn about stray tokens after #elif and #endif Warn about stray tokens after #elif and #endif
Wenum-compare Wenum-compare
...@@ -503,7 +503,7 @@ C++ ObjC++ Var(warn_invalid_offsetof) Init(1) Warning ...@@ -503,7 +503,7 @@ C++ ObjC++ Var(warn_invalid_offsetof) Init(1) Warning
Warn about invalid uses of the \"offsetof\" macro Warn about invalid uses of the \"offsetof\" macro
Winvalid-pch Winvalid-pch
C ObjC C++ ObjC++ Warning C ObjC C++ ObjC++ CPP(warn_invalid_pch) Var(cpp_warn_invalid_pch) Warning
Warn about PCH files that are found but not used Warn about PCH files that are found but not used
Wjump-misses-init Wjump-misses-init
...@@ -511,7 +511,7 @@ C ObjC Var(warn_jump_misses_init) Warning LangEnabledby(C ObjC,Wc++-compat) ...@@ -511,7 +511,7 @@ C ObjC Var(warn_jump_misses_init) Warning LangEnabledby(C ObjC,Wc++-compat)
Warn when a jump misses a variable initialization Warn when a jump misses a variable initialization
Wliteral-suffix Wliteral-suffix
C++ ObjC++ Warning C++ ObjC++ CPP(warn_literal_suffix) Var(cpp_warn_literal_suffix) Init(1) Warning
Warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore. Warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore.
Wlogical-op Wlogical-op
...@@ -583,7 +583,7 @@ C ObjC C++ ObjC++ Alias(Wsuggest-attribute=format) ...@@ -583,7 +583,7 @@ C ObjC C++ ObjC++ Alias(Wsuggest-attribute=format)
; ;
Wmissing-include-dirs Wmissing-include-dirs
C ObjC C++ ObjC++ Warning C ObjC C++ ObjC++ CPP(warn_missing_include_dirs) Var(cpp_warn_missing_include_dirs) Warning
Warn about user-specified include directories that do not exist Warn about user-specified include directories that do not exist
Wmissing-parameter-type Wmissing-parameter-type
...@@ -794,7 +794,7 @@ C ObjC Var(warn_traditional_conversion) Warning ...@@ -794,7 +794,7 @@ C ObjC Var(warn_traditional_conversion) Warning
Warn of prototypes causing type conversions different from what would happen in the absence of prototype Warn of prototypes causing type conversions different from what would happen in the absence of prototype
Wtrigraphs Wtrigraphs
C ObjC C++ ObjC++ Warning C ObjC C++ ObjC++ CPP(warn_trigraphs) Var(cpp_warn_trigraphs) Init(2) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
Warn if trigraphs are encountered that might affect the meaning of the program Warn if trigraphs are encountered that might affect the meaning of the program
Wundeclared-selector Wundeclared-selector
...@@ -802,7 +802,7 @@ ObjC ObjC++ Var(warn_undeclared_selector) Warning ...@@ -802,7 +802,7 @@ ObjC ObjC++ Var(warn_undeclared_selector) Warning
Warn about @selector()s without previously declared methods Warn about @selector()s without previously declared methods
Wundef Wundef
C ObjC C++ ObjC++ Warning C ObjC C++ ObjC++ CPP(warn_undef) Var(cpp_warn_undef) Warning
Warn if an undefined macro is used in an #if directive Warn if an undefined macro is used in an #if directive
Wuninitialized Wuninitialized
......
2014-08-29 Manuel López-Ibáñez <manu@gcc.gnu.org> 2014-08-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
* directives.c (check_eol_1): New.
(check_eol_endif_labels): New.
(check_eol): Call check_eol_1.
(do_else,do_endif): Call check_eol_endif_labels.
2014-08-29 Manuel López-Ibáñez <manu@gcc.gnu.org>
* macro.c (warn_of_redefinition): Suppress warnings for builtins * macro.c (warn_of_redefinition): Suppress warnings for builtins
that lack the NODE_WARN flag, unless Wbuiltin-macro-redefined. that lack the NODE_WARN flag, unless Wbuiltin-macro-redefined.
(_cpp_create_definition): Use Wbuiltin-macro-redefined for (_cpp_create_definition): Use Wbuiltin-macro-redefined for
......
...@@ -213,16 +213,33 @@ skip_rest_of_line (cpp_reader *pfile) ...@@ -213,16 +213,33 @@ skip_rest_of_line (cpp_reader *pfile)
; ;
} }
/* Ensure there are no stray tokens at the end of a directive. If /* Helper function for check_oel. */
EXPAND is true, tokens macro-expanding to nothing are allowed. */
static void static void
check_eol (cpp_reader *pfile, bool expand) check_eol_1 (cpp_reader *pfile, bool expand, int reason)
{ {
if (! SEEN_EOL () && (expand if (! SEEN_EOL () && (expand
? cpp_get_token (pfile) ? cpp_get_token (pfile)
: _cpp_lex_token (pfile))->type != CPP_EOF) : _cpp_lex_token (pfile))->type != CPP_EOF)
cpp_error (pfile, CPP_DL_PEDWARN, "extra tokens at end of #%s directive", cpp_pedwarning (pfile, reason, "extra tokens at end of #%s directive",
pfile->directive->name); pfile->directive->name);
}
/* Variant of check_eol used for Wendif-labels warnings. */
static void
check_eol_endif_labels (cpp_reader *pfile)
{
check_eol_1 (pfile, false, CPP_W_ENDIF_LABELS);
}
/* Ensure there are no stray tokens at the end of a directive. If
EXPAND is true, tokens macro-expanding to nothing are allowed. */
static void
check_eol (cpp_reader *pfile, bool expand)
{
check_eol_1 (pfile, expand, CPP_W_NONE);
} }
/* Ensure there are no stray tokens other than comments at the end of /* Ensure there are no stray tokens other than comments at the end of
...@@ -1990,7 +2007,7 @@ do_else (cpp_reader *pfile) ...@@ -1990,7 +2007,7 @@ do_else (cpp_reader *pfile)
/* Only check EOL if was not originally skipping. */ /* Only check EOL if was not originally skipping. */
if (!ifs->was_skipping && CPP_OPTION (pfile, warn_endif_labels)) if (!ifs->was_skipping && CPP_OPTION (pfile, warn_endif_labels))
check_eol (pfile, false); check_eol_endif_labels (pfile);
} }
} }
...@@ -2051,7 +2068,7 @@ do_endif (cpp_reader *pfile) ...@@ -2051,7 +2068,7 @@ do_endif (cpp_reader *pfile)
{ {
/* Only check EOL if was not originally skipping. */ /* Only check EOL if was not originally skipping. */
if (!ifs->was_skipping && CPP_OPTION (pfile, warn_endif_labels)) if (!ifs->was_skipping && CPP_OPTION (pfile, warn_endif_labels))
check_eol (pfile, false); check_eol_endif_labels (pfile);
/* If potential control macro, we go back outside again. */ /* If potential control macro, we go back outside again. */
if (ifs->next == 0 && ifs->mi_cmacro) if (ifs->next == 0 && ifs->mi_cmacro)
......
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