+2010-05-06 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR 40989
+ * doc/invoke.texi (Wimplicit): Document as C only.
+ * opts.c (common_handle_option): Add argument kind.
+ (handle_option): Rename as read_cmdline_option. Factor out code to...
+ (handle_option): ... here. New.
+ (handle_options): Rename as read_cmdline_options.
+ (decode_options): Update call.
+ (set_option): Use option index instead of option pointer. Classify
+ diagnostics correctly.
+ (enable_warning_as_error): Call handle_option.
+ * opts.h (set_option): Update declaration.
+ (handle_option): Declare.
+ * langhooks.h (struct lang_hooks): Add argument kind to
+ handle_option.
+ * c.opt (Wimplicit,Wimplicit-int): Initialize to -1.
+ * c-opts.c (set_Wimplicit): Delete.
+ (c_family_lang_mask): New static constant.
+ (c_common_handle_option): Add argument kind. Use handle_option
+ instead of set_Wimplicit.
+ (c_common_post_options): warn_implicit and warn_implicit_int
+ are disabled by default.
+ * c-common.c (warn_implicit): Do not define here.
+ * c-common.h (warn_implicit): Do not declare here.
+ (c_common_handle_option): Update declaration.
+ * lto-opts.c (lto_reissue_options): Update call to set_option.
+
2010-05-06 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43571
+2010-05-06 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR 40989
+ * gcc-interface/misc.c (gnat_handle_option): Add argument kind.
+
2010-05-02 Giuseppe Scrivano <gscrivano@gnu.org>
* gnathtml.pl: Use 755 as mask for new directories.
static bool gnat_init (void);
static unsigned int gnat_init_options (unsigned int, const char **);
-static int gnat_handle_option (size_t, const char *, int);
+static int gnat_handle_option (size_t, const char *, int, int);
static bool gnat_post_options (const char **);
static alias_set_type gnat_get_alias_set (tree);
static void gnat_print_decl (FILE *, tree, int);
that have been successfully decoded or 0 on failure. */
static int
-gnat_handle_option (size_t scode, const char *arg, int value)
+gnat_handle_option (size_t scode, const char *arg, int value, int kind ATTRIBUTE_UNUSED)
{
const struct cl_option *option = &cl_options[scode];
enum opt_code code = (enum opt_code) scode;
int flag_pretty_templates = 1;
-/* Nonzero means warn about implicit declarations. */
-
-int warn_implicit = 1;
-
/* Maximum template instantiation depth. This limit exists to limit the
time it takes to notice infinite template instantiations; the default
value of 1024 is likely to be in the next C++ standard. */
extern int flag_pretty_templates;
-/* Nonzero means warn about implicit declarations. */
-
-extern int warn_implicit;
-
/* Warn about using __null (as NULL in C++) as sentinel. For code compiled
with GCC this doesn't matter as __null is guaranteed to have the right
size. */
extern tree handle_format_attribute (tree *, tree, tree, int, bool *);
extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
extern bool attribute_takes_identifier_p (const_tree);
-extern int c_common_handle_option (size_t code, const char *arg, int value);
+extern int c_common_handle_option (size_t code, const char *arg, int value, int kind);
extern bool c_common_missing_argument (const char *opt, size_t code);
extern tree c_common_type_for_mode (enum machine_mode, int);
extern tree c_common_type_for_size (unsigned int, int);
/* Number of deferred options scanned for -include. */
static size_t include_cursor;
-static void set_Wimplicit (int);
static void handle_OPT_d (const char *);
static void set_std_cxx98 (int);
static void set_std_cxx0x (int);
const char *arg;
} *deferred_opts;
+
+static const unsigned int
+c_family_lang_mask = (CL_C | CL_CXX | CL_ObjC | CL_ObjCXX);
+
/* Complain that switch CODE expects an argument but none was
provided. OPT was the command-line option. Return FALSE to get
the default message in opts.c, TRUE if we provide a specialized
invalid, a negative number to prevent language-independent
processing in toplev.c (a hack necessary for the short-term). */
int
-c_common_handle_option (size_t scode, const char *arg, int value)
+c_common_handle_option (size_t scode, const char *arg, int value,
+ int kind)
{
const struct cl_option *option = &cl_options[scode];
enum opt_code code = (enum opt_code) scode;
switch (code)
{
default:
- if (cl_options[code].flags & (CL_C | CL_CXX | CL_ObjC | CL_ObjCXX))
+ if (cl_options[code].flags & c_family_lang_mask)
{
if ((option->flags & CL_TARGET)
&& ! targetcm.handle_c_option (scode, arg, value))
case OPT_Wall:
warn_unused = value;
set_Wformat (value);
- set_Wimplicit (value);
+ handle_option (OPT_Wimplicit, value, NULL, c_family_lang_mask, kind);
warn_char_subscripts = value;
warn_missing_braces = value;
warn_parentheses = value;
break;
case OPT_Wimplicit:
- set_Wimplicit (value);
+ gcc_assert (value == 0 || value == 1);
+ if (warn_implicit_int == -1)
+ handle_option (OPT_Wimplicit_int, value, NULL,
+ c_family_lang_mask, kind);
+ if (warn_implicit_function_declaration == -1)
+ handle_option (OPT_Wimplicit_function_declaration, value, NULL,
+ c_family_lang_mask, kind);
break;
case OPT_Wimport:
"-Wformat-security ignored without -Wformat");
}
+ if (warn_implicit == -1)
+ warn_implicit = 0;
+
+ if (warn_implicit_int == -1)
+ warn_implicit_int = 0;
+
/* -Wimplicit-function-declaration is enabled by default for C99. */
if (warn_implicit_function_declaration == -1)
warn_implicit_function_declaration = flag_isoc99;
cxx_dialect = cxx0x;
}
-/* Handle setting implicit to ON. */
-static void
-set_Wimplicit (int on)
-{
- warn_implicit = on;
- warn_implicit_int = on;
- warn_implicit_function_declaration = on;
-}
-
/* Args to -d specify what to dump. Silently ignore
unrecognized options; they may be aimed at toplev.c. */
static void
Warn about variables which are initialized to themselves
Wimplicit
-C ObjC C++ ObjC++ Warning
+C ObjC Var(warn_implicit) Init(-1) Warning
+Warn about implicit declarations
Wimplicit-function-declaration
C ObjC Var(warn_implicit_function_declaration) Init(-1) Warning
Warn about implicit function declarations
Wimplicit-int
-C ObjC Var(warn_implicit_int) Warning
+C ObjC Var(warn_implicit_int) Init(-1) Warning
Warn when a declaration does not specify a type
Wimport
-Wc++0x-compat @gol
-Wchar-subscripts @gol
-Wenum-compare @r{(in C/Objc; this is on by default in C++)} @gol
--Wimplicit-int @gol
--Wimplicit-function-declaration @gol
+-Wimplicit-int @r{(C and Objective-C only)} @gol
+-Wimplicit-function-declaration @r{(C and Objective-C only)} @gol
-Wcomment @gol
-Wformat @gol
-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol
@option{-pedantic-errors}. This warning is also enabled by
@option{-Wall}.
-@item -Wimplicit
+@item -Wimplicit @r{(C and Objective-C only)}
@opindex Wimplicit
@opindex Wno-implicit
Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
-2010-05-0 Tobias Burnus <burnus@net-b.de>
+2010-05-06 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR 40989
+ * options.c (gfc_handle_option): Add argument kind.
+ * gfortran.h (gfc_handle_option): Update declaration.
+
+2010-05-06 Tobias Burnus <burnus@net-b.de>
PR fortran/43985
* trans-types.c (gfc_sym_type): Mark Cray pointees as
/* options.c */
unsigned int gfc_init_options (unsigned int, const char **);
-int gfc_handle_option (size_t, const char *, int);
+int gfc_handle_option (size_t, const char *, int, int);
bool gfc_post_options (const char **);
/* f95-lang.c */
recognized and handled. */
int
-gfc_handle_option (size_t scode, const char *arg, int value)
+gfc_handle_option (size_t scode, const char *arg, int value,
+ int kind ATTRIBUTE_UNUSED)
{
int result = 1;
enum opt_code code = (enum opt_code) scode;
+2010-05-06 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR 40989
+ * lang.c (java_handle_option): Add argument kind.
+
2010-04-18 Eric Botcazou <ebotcazou@adacore.com>
* decl.c (java_init_decl_processing): Remove argument in call to
static unsigned int java_init_options (unsigned int, const char **);
static bool java_post_options (const char **);
-static int java_handle_option (size_t scode, const char *arg, int value);
+static int java_handle_option (size_t scode, const char *arg, int value, int kind);
static void put_decl_string (const char *, int);
static void put_decl_node (tree, int);
static void java_print_error_function (diagnostic_context *, const char *,
* return 0, but do not complain if the option is not recognized.
*/
static int
-java_handle_option (size_t scode, const char *arg, int value)
+java_handle_option (size_t scode, const char *arg, int value,
+ int kind ATTRIBUTE_UNUSED)
{
enum opt_code code = (enum opt_code) scode;
Return 1 if the switch is valid, 0 if invalid, and -1 if it's
valid and should not be treated as language-independent too. */
- int (*handle_option) (size_t code, const char *arg, int value);
+ int (*handle_option) (size_t code, const char *arg, int value, int kind);
/* Return false to use the default complaint about a missing
argument, otherwise output a complaint and return true. */
const struct cl_option *option = &cl_options[o->code];
if (option->flag_var)
- set_option (option, o->value, o->arg);
+ set_option (o->code, o->value, o->arg, 0 /*DK_UNSPECIFIED*/);
if (o->type == CL_TARGET)
targetm.handle_option (o->code, o->arg, o->value);
unsigned num_in_fnames;
static int common_handle_option (size_t scode, const char *arg, int value,
- unsigned int lang_mask);
+ unsigned int lang_mask, int kind);
static void handle_param (const char *);
-static unsigned int handle_option (const char **argv, unsigned int lang_mask);
static char *write_langs (unsigned int lang_mask);
static void complain_wrong_lang (const char *, const struct cl_option *,
unsigned int lang_mask);
-static void handle_options (unsigned int, const char **, unsigned int);
static void set_debug_level (enum debug_info_type type, int extended,
const char *arg);
input_location = saved_loc;
}
+
+/* Handle option OPT_INDEX, and argument ARG, for the language
+ indicated by LANG_MASK. VALUE is true, unless no- form of an -f or
+ -W option was given. KIND is the diagnostic_t if this is a
+ diagnostics option, DK_UNSPECIFIED otherwise. Returns false if the
+ switch was invalid. */
+bool
+handle_option (int opt_index, int value, const char *arg,
+ unsigned int lang_mask, int kind)
+{
+ const struct cl_option *option = &cl_options[opt_index];
+
+ if (option->flag_var)
+ set_option (opt_index, value, arg, kind);
+
+ if (option->flags & lang_mask)
+ {
+ if (lang_hooks.handle_option (opt_index, arg, value, kind) == 0)
+ return false;
+ else
+ lto_register_user_option (opt_index, arg, value, lang_mask);
+ }
+
+ if (option->flags & CL_COMMON)
+ {
+ if (common_handle_option (opt_index, arg, value, lang_mask, kind) == 0)
+ return false;
+ else
+ lto_register_user_option (opt_index, arg, value, CL_COMMON);
+ }
+
+ if (option->flags & CL_TARGET)
+ {
+ if (!targetm.handle_option (opt_index, arg, value))
+ return false;
+ else
+ lto_register_user_option (opt_index, arg, value, CL_TARGET);
+ }
+ return true;
+}
+
/* Handle the switch beginning at ARGV for the language indicated by
LANG_MASK. Returns the number of switches consumed. */
static unsigned int
-handle_option (const char **argv, unsigned int lang_mask)
+read_cmdline_option (const char **argv, unsigned int lang_mask)
{
size_t opt_index;
const char *opt, *arg = 0;
}
}
- if (option->flag_var)
- set_option (option, value, arg);
-
- if (option->flags & lang_mask)
- {
- if (lang_hooks.handle_option (opt_index, arg, value) == 0)
- result = 0;
- else
- lto_register_user_option (opt_index, arg, value, lang_mask);
- }
-
- if (result && (option->flags & CL_COMMON))
- {
- if (common_handle_option (opt_index, arg, value, lang_mask) == 0)
- result = 0;
- else
- lto_register_user_option (opt_index, arg, value, CL_COMMON);
- }
-
- if (result && (option->flags & CL_TARGET))
- {
- if (!targetm.handle_option (opt_index, arg, value))
- result = 0;
- else
- lto_register_user_option (opt_index, arg, value, CL_TARGET);
- }
+ if (!handle_option (opt_index, value, arg, lang_mask, DK_UNSPECIFIED))
+ result = 0;
done:
if (dup)
contains has a single bit set representing the current
language. */
static void
-handle_options (unsigned int argc, const char **argv, unsigned int lang_mask)
+read_cmdline_options (unsigned int argc, const char **argv, unsigned int lang_mask)
{
unsigned int n, i;
continue;
}
- n = handle_option (argv + i, lang_mask);
+ n = read_cmdline_option (argv + i, lang_mask);
if (!n)
{
OPTIMIZATION_OPTIONS (optimize, optimize_size);
#endif
- handle_options (argc, argv, lang_mask);
+ read_cmdline_options (argc, argv, lang_mask);
if (dump_base_name && ! IS_ABSOLUTE_PATH (dump_base_name))
{
static int
common_handle_option (size_t scode, const char *arg, int value,
- unsigned int lang_mask)
+ unsigned int lang_mask, int kind ATTRIBUTE_UNUSED)
{
static bool verbose = false;
enum opt_code code = (enum opt_code) scode;
/* Set *OPTION according to VALUE and ARG. */
void
-set_option (const struct cl_option *option, int value, const char *arg)
+set_option (int opt_index, int value, const char *arg, int kind)
{
+ const struct cl_option *option = &cl_options[opt_index];
+
if (!option->flag_var)
return;
*(const char **) option->flag_var = arg;
break;
}
+
+ if ((diagnostic_t)kind != DK_UNSPECIFIED)
+ diagnostic_classify_diagnostic (global_dc, opt_index, (diagnostic_t)kind);
}
const struct cl_option * const option = cl_options + option_index;
/* -Werror=foo implies -Wfoo. */
- if (option->var_type == CLVC_BOOLEAN && option->flag_var)
- *(int *) option->flag_var = 1;
+ if (option->var_type == CLVC_BOOLEAN)
+ handle_option (option_index, value, arg, lang_mask, (int)kind);
if (warning_as_error_callback)
warning_as_error_callback (option_index);
extern void decode_options (unsigned int argc, const char **argv);
extern int option_enabled (int opt_idx);
extern bool get_option_state (int, struct cl_option_state *);
-extern void set_option (const struct cl_option *, int, const char *);
-
+extern void set_option (int opt_index, int value, const char *arg, int);
+bool handle_option (int opt_index, int value, const char *arg,
+ unsigned int lang_mask, int kind);
extern void register_warning_as_error_callback (void (*callback) (int));
extern void enable_warning_as_error (const char *arg, int value,
unsigned int lang_mask);
+2010-05-06 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR 40989
+ * gcc.dg/pr40989.c: New.
+
2010-05-06 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43934
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Werror=implicit" } */
+int main() {
+ return pippo(); /* { dg-error "" } */
+}
+/* { dg-message "warnings being treated as errors" "" { target *-*-* } 0 } */