diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-11-18 10:33:36 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-11-18 10:33:36 +0000 |
commit | 0f15bf2ebe4b001a06ab7869f0c7bcbb74b5469e (patch) | |
tree | 7393ac7f037f04ea997b60a08f0eba639c9798d6 /gcc/c-family | |
parent | 80135bd9bbf06da9d0214ece3c59c301d3af3a2b (diff) | |
download | gcc-0f15bf2ebe4b001a06ab7869f0c7bcbb74b5469e.tar.gz |
2010-11-18 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 166897
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@166899 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 67 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 27 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 7 | ||||
-rw-r--r-- | gcc/c-family/c-cppbuiltin.c | 10 | ||||
-rw-r--r-- | gcc/c-family/c-format.c | 235 | ||||
-rw-r--r-- | gcc/c-family/c-lex.c | 7 | ||||
-rw-r--r-- | gcc/c-family/c-opts.c | 158 | ||||
-rw-r--r-- | gcc/c-family/c-pragma.c | 19 | ||||
-rw-r--r-- | gcc/c-family/c.opt | 6 | ||||
-rw-r--r-- | gcc/c-family/stub-objc.c | 9 |
10 files changed, 289 insertions, 256 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 1164d919d0e..81e636c28f5 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,70 @@ +2010-11-17 Joseph Myers <joseph@codesourcery.com> + + * c-opts.c (c_common_parse_file): Take no arguments. + * c-common.h (c_common_parse_file): Update prototype. + +2010-11-16 Jakub Jelinek <jakub@redhat.com> + + PR c++/46401 + * c-common.c (warning_candidate_p): Don't track non-const calls + or STRING_CSTs. + +2010-11-15 Ian Lance Taylor <iant@google.com> + + * c-lex.c (init_c_lex): Set macro debug callbacks if + flag_dump_go_spec is set. + +2010-11-15 Nicola Pero <nicola.pero@meta-innovation.com> + + * c-common.h (objc_build_incr_expr_for_property_ref): New. + * stub-objc.c (objc_build_incr_expr_for_property_ref): New. + +2010-11-15 Nathan Froyd <froydnj@codesourcery.com> + + PR preprocessor/45038 + * c-cppbuiltin.c (c_cpp_builtins): Use different format for C++ + dialects. + +2010-11-12 Joseph Myers <joseph@codesourcery.com> + + * c-common.h (c_family_lang_mask): Declare. + * c-opts.c (c_family_lang_mask): Make extern. + * c-pragma.c (handle_pragma_diagnostic): Use + control_warning_option. + +2010-11-12 Joseph Myers <joseph@codesourcery.com> + + * c-common.c (parse_optimize_options): Update call to + decode_options. + * c-common.h (c_common_handle_option): Update prototype. + * c-opts.c (c_common_handle_option): Take location_t parameter and + pass it to other functions. + +2010-11-11 Joseph Myers <joseph@codesourcery.com> + + * c-opts.c (warning_as_error_callback): Remove. + (c_common_initialize_diagnostics): Don't call + register_warning_as_error_callback. + (c_common_handle_option): Handle -Werror=normalized= here. + +2010-11-10 Joseph Myers <joseph@codesourcery.com> + + * c-common.c (handle_mode_attribute): Use %' and word "signedness" + in diagnostic. + * c-opts.c (c_common_parse_file): Start diagnostics with lowercase + letter. + * c-pragma.c (handle_pragma_target, handle_pragma_optimize): + Remove trailing '.' from diagnostics. + * c.opt (Wwrite-strings_: Avoid '`' in help text. + +2010-11-10 Joseph Myers <joseph@codesourcery.com> + + * c-common.c (parse_optimize_options): Pass global_dc to + decode_options. + * c-opts.c (c_common_handle_option): Pass &global_options to + set_Wstrict_aliasing. + * c.opt (v): Don't mark Common or document here. + 2010-11-06 Iain Sandoe <iains@gcc.gnu.org> PR target/44981 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index ab050ab2e68..afe9b9d6e19 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -2324,10 +2324,26 @@ warn_for_collisions (struct tlist *list) static int warning_candidate_p (tree x) { - /* !VOID_TYPE_P (TREE_TYPE (x)) is workaround for cp/tree.c + if (DECL_P (x) && DECL_ARTIFICIAL (x)) + return 0; + + /* VOID_TYPE_P (TREE_TYPE (x)) is workaround for cp/tree.c (lvalue_p) crash on TRY/CATCH. */ - return !(DECL_P (x) && DECL_ARTIFICIAL (x)) - && TREE_TYPE (x) && !VOID_TYPE_P (TREE_TYPE (x)) && lvalue_p (x); + if (TREE_TYPE (x) == NULL_TREE || VOID_TYPE_P (TREE_TYPE (x))) + return 0; + + if (!lvalue_p (x)) + return 0; + + /* No point to track non-const calls, they will never satisfy + operand_equal_p. */ + if (TREE_CODE (x) == CALL_EXPR && (call_expr_flags (x) & ECF_CONST) == 0) + return 0; + + if (TREE_CODE (x) == STRING_CST) + return 0; + + return 1; } /* Return nonzero if X and Y appear to be the same candidate (or NULL) */ @@ -6408,7 +6424,7 @@ handle_mode_attribute (tree *node, tree name, tree args, if (ALL_FIXED_POINT_MODE_P (mode) && TYPE_UNSIGNED (type) != UNSIGNED_FIXED_POINT_MODE_P (mode)) { - error ("signness of type and machine mode %qs don't match", p); + error ("signedness of type and machine mode %qs don%'t match", p); return NULL_TREE; } /* For fixed-point modes, we need to pass saturating info. */ @@ -7804,7 +7820,8 @@ parse_optimize_options (tree args, bool attr_p) &decoded_options, &decoded_options_count); decode_options (&global_options, &global_options_set, - decoded_options, decoded_options_count); + decoded_options, decoded_options_count, + input_location, global_dc); targetm.override_options_after_change(); diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 58d3a321e0f..76842d2ded1 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -696,7 +696,7 @@ extern void set_Wformat (int); 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 bool c_common_handle_option (size_t, const char *, int, int, +extern bool c_common_handle_option (size_t, const char *, int, int, location_t, const struct cl_option_handlers *); extern tree c_common_type_for_mode (enum machine_mode, int); extern tree c_common_type_for_size (unsigned int, int); @@ -762,6 +762,7 @@ extern void set_compound_literal_name (tree decl); extern tree build_va_arg (location_t, tree, tree); +extern const unsigned int c_family_lang_mask; extern unsigned int c_common_option_lang_mask (void); extern void c_common_initialize_diagnostics (diagnostic_context *); extern bool c_common_complain_wrong_lang_p (const struct cl_option *); @@ -770,7 +771,7 @@ extern void c_common_init_options (unsigned int, struct cl_decoded_option *); extern bool c_common_post_options (const char **); extern bool c_common_init (void); extern void c_common_finish (void); -extern void c_common_parse_file (int); +extern void c_common_parse_file (void); extern alias_set_type c_common_get_alias_set (tree); extern void c_register_builtin_type (tree, const char*); extern bool c_promoting_integer_type_p (const_tree); @@ -1039,6 +1040,8 @@ extern void objc_add_property_declaration (location_t, tree, bool, bool, bool, extern tree objc_maybe_build_component_ref (tree, tree); extern tree objc_build_class_component_ref (tree, tree); extern tree objc_maybe_build_modify_expr (tree, tree); +extern tree objc_build_incr_expr_for_property_ref (location_t, enum tree_code, + tree, tree); extern void objc_add_synthesize_declaration (location_t, tree); extern void objc_add_dynamic_declaration (location_t, tree); extern const char * objc_maybe_printable_name (tree, int); diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 7b5a14dda11..ca779648b20 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -657,9 +657,13 @@ c_cpp_builtins (cpp_reader *pfile) /* Cast the double precision constants. This is needed when single precision constants are specified or when pragma FLOAT_CONST_DECIMAL64 is used. The correct result is computed by the compiler when using - macros that include a cast. */ - builtin_define_float_constants ("DBL", "L", "((double)%s)", "", - double_type_node); + macros that include a cast. We use a different cast for C++ to avoid + problems with -Wold-style-cast. */ + builtin_define_float_constants ("DBL", "L", + (c_dialect_cxx () + ? "double(%s)" + : "((double)%s)"), + "", double_type_node); builtin_define_float_constants ("LDBL", "L", "%s", "L", long_double_type_node); diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index a64717a5510..1ca181baebc 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -356,6 +356,20 @@ decode_format_attr (tree args, function_format_info *info, int validated_p) ? (warn_long_long ? STD_C99 : STD_C89) \ : (VER))) +/* Enum describing the kind of specifiers present in the format and + requiring an argument. */ +enum format_specifier_kind { + CF_KIND_FORMAT, + CF_KIND_FIELD_WIDTH, + CF_KIND_FIELD_PRECISION +}; + +static const char *kind_descriptions[] = { + N_("format"), + N_("field width specifier"), + N_("field precision specifier") +}; + /* Structure describing details of a type expected in format checking, and the type to check against it. */ typedef struct format_wanted_type @@ -377,11 +391,13 @@ typedef struct format_wanted_type /* Whether the argument, dereferenced once, is read from and so must not be a NULL pointer. */ int reading_from_flag; - /* If warnings should be of the form "field precision should have - type 'int'", the name to use (in this case "field precision"), - otherwise NULL, for "format expects type 'long'" type - messages. */ - const char *name; + /* The kind of specifier that this type is used for. */ + enum format_specifier_kind kind; + /* The starting character of the specifier. This never includes the + initial percent sign. */ + const char *format_start; + /* The length of the specifier. */ + int format_length; /* The actual parameter to check against the wanted type. */ tree param; /* The argument number of that parameter. */ @@ -957,9 +973,8 @@ static void finish_dollar_format_checking (format_check_results *, int); static const format_flag_spec *get_flag_spec (const format_flag_spec *, int, const char *); -static void check_format_types (format_wanted_type *, const char *, int); -static void format_type_warning (const char *, const char *, int, tree, - int, const char *, tree, int); +static void check_format_types (format_wanted_type *); +static void format_type_warning (format_wanted_type *, tree, tree); /* Decode a format type from a string, returning the type, or format_type_error if not valid, in which case the caller should print an @@ -1619,7 +1634,7 @@ check_format_info_main (format_check_results *res, init_dollar_format_checking (info->first_arg_num, first_fillin_param); - while (1) + while (*format_chars != 0) { int i; int suppressed = FALSE; @@ -1643,21 +1658,8 @@ check_format_info_main (format_check_results *res, char flag_chars[256]; int alloc_flag = 0; int scalar_identity_flag = 0; - const char *format_start = format_chars; - if (*format_chars == 0) - { - if (format_chars - orig_format_chars != format_length) - warning (OPT_Wformat_contains_nul, "embedded %<\\0%> in format"); - if (info->first_arg_num != 0 && params != 0 - && has_operand_number <= 0) - { - res->number_other--; - res->number_extra_args++; - } - if (has_operand_number > 0) - finish_dollar_format_checking (res, fki->flags & (int) FMT_FLAG_DOLLAR_GAP_POINTER_OK); - return; - } + const char *format_start; + if (*format_chars++ != '%') continue; if (*format_chars == 0) @@ -1762,16 +1764,16 @@ check_format_info_main (format_check_results *res, if (info->first_arg_num != 0) { if (params == 0) - { - warning (OPT_Wformat, "too few arguments for format"); - return; - } - cur_param = TREE_VALUE (params); - if (has_operand_number <= 0) - { - params = TREE_CHAIN (params); - ++arg_num; - } + cur_param = NULL; + else + { + cur_param = TREE_VALUE (params); + if (has_operand_number <= 0) + { + params = TREE_CHAIN (params); + ++arg_num; + } + } width_wanted_type.wanted_type = *fki->width_type; width_wanted_type.wanted_type_name = NULL; width_wanted_type.pointer_count = 0; @@ -1779,7 +1781,9 @@ check_format_info_main (format_check_results *res, width_wanted_type.scalar_identity_flag = 0; width_wanted_type.writing_in_flag = 0; width_wanted_type.reading_from_flag = 0; - width_wanted_type.name = _("field width"); + width_wanted_type.kind = CF_KIND_FIELD_WIDTH; + width_wanted_type.format_start = format_chars - 1; + width_wanted_type.format_length = 1; width_wanted_type.param = cur_param; width_wanted_type.arg_num = arg_num; width_wanted_type.next = NULL; @@ -1865,16 +1869,16 @@ check_format_info_main (format_check_results *res, if (info->first_arg_num != 0) { if (params == 0) - { - warning (OPT_Wformat, "too few arguments for format"); - return; - } - cur_param = TREE_VALUE (params); - if (has_operand_number <= 0) - { - params = TREE_CHAIN (params); - ++arg_num; - } + cur_param = NULL; + else + { + cur_param = TREE_VALUE (params); + if (has_operand_number <= 0) + { + params = TREE_CHAIN (params); + ++arg_num; + } + } precision_wanted_type.wanted_type = *fki->precision_type; precision_wanted_type.wanted_type_name = NULL; precision_wanted_type.pointer_count = 0; @@ -1882,8 +1886,10 @@ check_format_info_main (format_check_results *res, precision_wanted_type.scalar_identity_flag = 0; precision_wanted_type.writing_in_flag = 0; precision_wanted_type.reading_from_flag = 0; - precision_wanted_type.name = _("field precision"); + precision_wanted_type.kind = CF_KIND_FIELD_PRECISION; precision_wanted_type.param = cur_param; + precision_wanted_type.format_start = format_chars - 2; + precision_wanted_type.format_length = 2; precision_wanted_type.arg_num = arg_num; precision_wanted_type.next = NULL; if (last_wanted_type != 0) @@ -1903,6 +1909,7 @@ check_format_info_main (format_check_results *res, } } + format_start = format_chars; if (fki->alloc_char && fki->alloc_char == *format_chars) { i = strlen (flag_chars); @@ -2163,12 +2170,8 @@ check_format_info_main (format_check_results *res, /* Heuristic: skip one argument when an invalid length/type combination is encountered. */ arg_num++; - if (params == 0) - { - warning (OPT_Wformat, "too few arguments for format"); - return; - } - params = TREE_CHAIN (params); + if (params != 0) + params = TREE_CHAIN (params); continue; } else if (pedantic @@ -2229,13 +2232,12 @@ check_format_info_main (format_check_results *res, while (fci) { if (params == 0) - { - warning (OPT_Wformat, "too few arguments for format"); - return; - } - - cur_param = TREE_VALUE (params); - params = TREE_CHAIN (params); + cur_param = NULL; + else + { + cur_param = TREE_VALUE (params); + params = TREE_CHAIN (params); + } wanted_type_ptr->wanted_type = wanted_type; wanted_type_ptr->wanted_type_name = wanted_type_name; @@ -2257,9 +2259,11 @@ check_format_info_main (format_check_results *res, if (strchr (fci->flags2, 'R') != 0) wanted_type_ptr->reading_from_flag = 1; } - wanted_type_ptr->name = NULL; + wanted_type_ptr->kind = CF_KIND_FORMAT; wanted_type_ptr->param = cur_param; wanted_type_ptr->arg_num = arg_num; + wanted_type_ptr->format_start = format_start; + wanted_type_ptr->format_length = format_chars - format_start; wanted_type_ptr->next = NULL; if (last_wanted_type != 0) last_wanted_type->next = wanted_type_ptr; @@ -2280,17 +2284,26 @@ check_format_info_main (format_check_results *res, } if (first_wanted_type != 0) - check_format_types (first_wanted_type, format_start, - format_chars - format_start); + check_format_types (first_wanted_type); + } + + if (format_chars - orig_format_chars != format_length) + warning (OPT_Wformat_contains_nul, "embedded %<\\0%> in format"); + if (info->first_arg_num != 0 && params != 0 + && has_operand_number <= 0) + { + res->number_other--; + res->number_extra_args++; } + if (has_operand_number > 0) + finish_dollar_format_checking (res, fki->flags & (int) FMT_FLAG_DOLLAR_GAP_POINTER_OK); } /* Check the argument types from a single format conversion (possibly including width and precision arguments). */ static void -check_format_types (format_wanted_type *types, const char *format_start, - int format_length) +check_format_types (format_wanted_type *types) { for (; types != 0; types = types->next) { @@ -2301,12 +2314,7 @@ check_format_types (format_wanted_type *types, const char *format_start, int arg_num; int i; int char_type_flag; - cur_param = types->param; - cur_type = TREE_TYPE (cur_param); - if (cur_type == error_mark_node) - continue; - orig_cur_type = cur_type; - char_type_flag = 0; + wanted_type = types->wanted_type; arg_num = types->arg_num; @@ -2319,6 +2327,19 @@ check_format_types (format_wanted_type *types, const char *format_start, wanted_type = TYPE_MAIN_VARIANT (wanted_type); + cur_param = types->param; + if (!cur_param) + { + format_type_warning (types, wanted_type, NULL); + continue; + } + + cur_type = TREE_TYPE (cur_param); + if (cur_type == error_mark_node) + continue; + orig_cur_type = cur_type; + char_type_flag = 0; + STRIP_NOPS (cur_param); /* Check the types of any additional pointer arguments @@ -2382,10 +2403,7 @@ check_format_types (format_wanted_type *types, const char *format_start, } else { - format_type_warning (types->name, format_start, format_length, - wanted_type, types->pointer_count, - types->wanted_type_name, orig_cur_type, - arg_num); + format_type_warning (types, wanted_type, orig_cur_type); break; } } @@ -2437,33 +2455,34 @@ check_format_types (format_wanted_type *types, const char *format_start, && TYPE_PRECISION (cur_type) == TYPE_PRECISION (wanted_type)) continue; /* Now we have a type mismatch. */ - format_type_warning (types->name, format_start, format_length, - wanted_type, types->pointer_count, - types->wanted_type_name, orig_cur_type, arg_num); + format_type_warning (types, wanted_type, orig_cur_type); } } /* Give a warning about a format argument of different type from that - expected. DESCR is a description such as "field precision", or - NULL for an ordinary format. For an ordinary format, FORMAT_START - points to where the format starts in the format string and - FORMAT_LENGTH is its length. WANTED_TYPE is the type the argument - should have after POINTER_COUNT pointer dereferences. - WANTED_NAME_NAME is a possibly more friendly name of WANTED_TYPE, - or NULL if the ordinary name of the type should be used. ARG_TYPE - is the type of the actual argument. ARG_NUM is the number of that - argument. */ + expected. WANTED_TYPE is the type the argument should have, possibly + stripped of pointer dereferences. The description (such as "field + precision"), the placement in the format string, a possibly more + friendly name of WANTED_TYPE, and the number of pointer dereferences + are taken from TYPE. ARG_TYPE is the type of the actual argument, + or NULL if it is missing. */ static void -format_type_warning (const char *descr, const char *format_start, - int format_length, tree wanted_type, int pointer_count, - const char *wanted_type_name, tree arg_type, int arg_num) +format_type_warning (format_wanted_type *type, tree wanted_type, tree arg_type) { + int kind = type->kind; + const char *wanted_type_name = type->wanted_type_name; + const char *format_start = type->format_start; + int format_length = type->format_length; + int pointer_count = type->pointer_count; + int arg_num = type->arg_num; + char *p; /* If ARG_TYPE is a typedef with a misleading name (for example, size_t but not the standard size_t expected by printf %zu), avoid printing the typedef name. */ if (wanted_type_name + && arg_type && TYPE_NAME (arg_type) && TREE_CODE (TYPE_NAME (arg_type)) == TYPE_DECL && DECL_NAME (TYPE_NAME (arg_type)) @@ -2489,28 +2508,36 @@ format_type_warning (const char *descr, const char *format_start, memset (p + 1, '*', pointer_count); p[pointer_count + 1] = 0; } + if (wanted_type_name) { - if (descr) - warning (OPT_Wformat, "%s should have type %<%s%s%>, " - "but argument %d has type %qT", - descr, wanted_type_name, p, arg_num, arg_type); + if (arg_type) + warning (OPT_Wformat, "%s %<%s%.*s%> expects argument of type %<%s%s%>, " + "but argument %d has type %qT", + gettext (kind_descriptions[kind]), + (kind == CF_KIND_FORMAT ? "%" : ""), + format_length, format_start, + wanted_type_name, p, arg_num, arg_type); else - warning (OPT_Wformat, "format %q.*s expects type %<%s%s%>, " - "but argument %d has type %qT", - format_length, format_start, wanted_type_name, p, - arg_num, arg_type); + warning (OPT_Wformat, "%s %<%s%.*s%> expects a matching %<%s%s%> argument", + gettext (kind_descriptions[kind]), + (kind == CF_KIND_FORMAT ? "%" : ""), + format_length, format_start, wanted_type_name, p); } else { - if (descr) - warning (OPT_Wformat, "%s should have type %<%T%s%>, " - "but argument %d has type %qT", - descr, wanted_type, p, arg_num, arg_type); + if (arg_type) + warning (OPT_Wformat, "%s %<%s%.*s%> expects argument of type %<%T%s%>, " + "but argument %d has type %qT", + gettext (kind_descriptions[kind]), + (kind == CF_KIND_FORMAT ? "%" : ""), + format_length, format_start, + wanted_type, p, arg_num, arg_type); else - warning (OPT_Wformat, "format %q.*s expects type %<%T%s%>, " - "but argument %d has type %qT", - format_length, format_start, wanted_type, p, arg_num, arg_type); + warning (OPT_Wformat, "%s %<%s%.*s%> expects a matching %<%T%s%> argument", + gettext (kind_descriptions[kind]), + (kind == CF_KIND_FORMAT ? "%" : ""), + format_length, format_start, wanted_type, p); } } diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 851449fbac4..68a0fe04a5c 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -87,9 +87,10 @@ init_c_lex (void) cb->read_pch = c_common_read_pch; /* Set the debug callbacks if we can use them. */ - if (debug_info_level == DINFO_LEVEL_VERBOSE - && (write_symbols == DWARF2_DEBUG - || write_symbols == VMS_AND_DWARF2_DEBUG)) + if ((debug_info_level == DINFO_LEVEL_VERBOSE + && (write_symbols == DWARF2_DEBUG + || write_symbols == VMS_AND_DWARF2_DEBUG)) + || flag_dump_go_spec != NULL) { cb->define = cb_define; cb->undef = cb_undef; diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 8f60834aa48..3d70136ee0e 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -132,7 +132,7 @@ static struct deferred_opt } *deferred_opts; -static const unsigned int +extern const unsigned int c_family_lang_mask = (CL_C | CL_CXX | CL_ObjC | CL_ObjCXX); /* Defer option CODE with argument ARG. */ @@ -144,89 +144,6 @@ defer_opt (enum opt_code code, const char *arg) deferred_count++; } -/* -Werror= may set a warning option to enable a warning that is emitted - by the preprocessor. Set any corresponding flag in cpp_opts. */ - -static void -warning_as_error_callback (int option_index) -{ - switch (option_index) - { - default: - /* Ignore options not associated with the preprocessor. */ - break; - - case OPT_Wdeprecated: - cpp_opts->cpp_warn_deprecated = 1; - break; - - case OPT_Wcomment: - cpp_opts->warn_comments = 1; - break; - - case OPT_Wtrigraphs: - cpp_opts->warn_trigraphs = 1; - break; - - case OPT_Wmultichar: - cpp_opts->warn_multichar = 1; - break; - - case OPT_Wtraditional: - cpp_opts->cpp_warn_traditional = 1; - break; - - case OPT_Wlong_long: - cpp_opts->cpp_warn_long_long = 1; - break; - - case OPT_Wendif_labels: - cpp_opts->warn_endif_labels = 1; - break; - - case OPT_Wvariadic_macros: - /* Set the local flag that is used later to update cpp_opts. */ - warn_variadic_macros = 1; - break; - - case OPT_Wbuiltin_macro_redefined: - cpp_opts->warn_builtin_macro_redefined = 1; - break; - - case OPT_Wundef: - cpp_opts->warn_undef = 1; - break; - - case OPT_Wunused_macros: - /* Set the local flag that is used later to update cpp_opts. */ - warn_unused_macros = 1; - break; - - case OPT_Wc___compat: - /* Add warnings in the same way as c_common_handle_option below. */ - if (warn_enum_compare == -1) - warn_enum_compare = 1; - if (warn_jump_misses_init == -1) - warn_jump_misses_init = 1; - cpp_opts->warn_cxx_operator_names = 1; - break; - - case OPT_Wnormalized_: - inform (input_location, "-Werror=normalized=: Set -Wnormalized=nfc"); - cpp_opts->warn_normalize = normalized_C; - break; - - case OPT_Winvalid_pch: - cpp_opts->warn_invalid_pch = 1; - break; - - case OPT_Wcpp: - /* Handled by standard diagnostics using the option's associated - boolean variable. */ - break; - } -} - /* Return language mask for option parsing. */ unsigned int c_common_option_lang_mask (void) @@ -240,9 +157,6 @@ c_common_option_lang_mask (void) void c_common_initialize_diagnostics (diagnostic_context *context) { - /* Register callback for warnings enabled by -Werror=. */ - register_warning_as_error_callback (warning_as_error_callback); - /* This is conditionalized only because that is the way the front ends used to do it. Maybe this should be unconditional? */ if (c_dialect_cxx ()) @@ -327,7 +241,8 @@ c_common_init_options (unsigned int decoded_options_count, invalid, true if valid. Use HANDLERS in recursive handle_option calls. */ bool c_common_handle_option (size_t scode, const char *arg, int value, - int kind, const struct cl_option_handlers *handlers) + int kind, location_t loc, + const struct cl_option_handlers *handlers) { const struct cl_option *option = &cl_options[scode]; enum opt_code code = (enum opt_code) scode; @@ -443,7 +358,8 @@ c_common_handle_option (size_t scode, const char *arg, int value, set_Wformat (value); handle_generated_option (&global_options, &global_options_set, OPT_Wimplicit, NULL, value, - c_family_lang_mask, kind, handlers, global_dc); + c_family_lang_mask, kind, loc, + handlers, global_dc); warn_char_subscripts = value; warn_missing_braces = value; warn_parentheses = value; @@ -451,7 +367,7 @@ c_common_handle_option (size_t scode, const char *arg, int value, warn_sequence_point = value; /* Was C only. */ warn_switch = value; if (warn_strict_aliasing == -1) - set_Wstrict_aliasing (value); + set_Wstrict_aliasing (&global_options, value); warn_address = value; if (warn_strict_overflow == -1) warn_strict_overflow = value; @@ -538,19 +454,23 @@ c_common_handle_option (size_t scode, const char *arg, int value, if (warn_implicit_int == -1) handle_generated_option (&global_options, &global_options_set, OPT_Wimplicit_int, NULL, value, - c_family_lang_mask, kind, handlers, + c_family_lang_mask, kind, loc, handlers, global_dc); if (warn_implicit_function_declaration == -1) handle_generated_option (&global_options, &global_options_set, OPT_Wimplicit_function_declaration, NULL, - value, c_family_lang_mask, kind, handlers, - global_dc); + value, c_family_lang_mask, kind, loc, + handlers, global_dc); break; case OPT_Winvalid_pch: cpp_opts->warn_invalid_pch = value; break; + case OPT_Wlong_long: + cpp_opts->cpp_warn_long_long = value; + break; + case OPT_Wmissing_include_dirs: cpp_opts->warn_missing_include_dirs = value; break; @@ -560,17 +480,26 @@ c_common_handle_option (size_t scode, const char *arg, int value, break; case OPT_Wnormalized_: - if (!value || (arg && strcasecmp (arg, "none") == 0)) - cpp_opts->warn_normalize = normalized_none; - else if (!arg || strcasecmp (arg, "nfkc") == 0) - cpp_opts->warn_normalize = normalized_KC; - else if (strcasecmp (arg, "id") == 0) - cpp_opts->warn_normalize = normalized_identifier_C; - else if (strcasecmp (arg, "nfc") == 0) - cpp_opts->warn_normalize = normalized_C; + if (kind == DK_ERROR) + { + gcc_assert (!arg); + inform (input_location, "-Werror=normalized=: set -Wnormalized=nfc"); + cpp_opts->warn_normalize = normalized_C; + } else - error ("argument %qs to %<-Wnormalized%> not recognized", arg); - break; + { + if (!value || (arg && strcasecmp (arg, "none") == 0)) + cpp_opts->warn_normalize = normalized_none; + else if (!arg || strcasecmp (arg, "nfkc") == 0) + cpp_opts->warn_normalize = normalized_KC; + else if (strcasecmp (arg, "id") == 0) + cpp_opts->warn_normalize = normalized_identifier_C; + else if (strcasecmp (arg, "nfc") == 0) + cpp_opts->warn_normalize = normalized_C; + else + error ("argument %qs to %<-Wnormalized%> not recognized", arg); + break; + } case OPT_Wreturn_type: warn_return_type = value; @@ -1128,31 +1057,10 @@ c_common_init (void) /* Initialize the integrated preprocessor after debug output has been initialized; loop over each input file. */ void -c_common_parse_file (int set_yydebug) +c_common_parse_file (void) { unsigned int i; - if (set_yydebug) - switch (c_language) - { - case clk_c: - warning(0, "The C parser does not support -dy, option ignored"); - break; - case clk_objc: - warning(0, - "The Objective-C parser does not support -dy, option ignored"); - break; - case clk_cxx: - warning(0, "The C++ parser does not support -dy, option ignored"); - break; - case clk_objcxx: - warning(0, - "The Objective-C++ parser does not support -dy, option ignored"); - break; - default: - gcc_unreachable (); - } - i = 0; for (;;) { diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index 5aa209c8e64..9c00983596f 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -720,6 +720,7 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy)) enum cpp_ttype token; diagnostic_t kind; tree x; + struct cl_option_handlers handlers; token = pragma_lex (&x); if (token != CPP_NAME) @@ -748,18 +749,14 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy)) if (token != CPP_STRING) GCC_BAD ("missing option after %<#pragma GCC diagnostic%> kind"); option_string = TREE_STRING_POINTER (x); + set_default_handlers (&handlers); for (option_index = 0; option_index < cl_options_count; option_index++) if (strcmp (cl_options[option_index].opt_text, option_string) == 0) { - void *flag_var = option_flag_var (option_index, &global_options); - - /* This overrides -Werror, for example. */ - diagnostic_classify_diagnostic (global_dc, option_index, kind, input_location); - /* This makes sure the option is enabled, like -Wfoo would do. */ - if (cl_options[option_index].var_type == CLVC_BOOLEAN - && flag_var - && kind != DK_IGNORED) - *(int *) flag_var = 1; + control_warning_option (option_index, (int) kind, kind != DK_IGNORED, + input_location, c_family_lang_mask, &handlers, + &global_options, &global_options_set, + global_dc); return; } GCC_BAD ("unknown option after %<#pragma GCC diagnostic%> kind"); @@ -816,7 +813,7 @@ handle_pragma_target(cpp_reader *ARG_UNUSED(dummy)) token = pragma_lex (&x); else GCC_BAD ("%<#pragma GCC target (string [,string]...)%> does " - "not have a final %<)%>."); + "not have a final %<)%>"); } if (token != CPP_EOF) @@ -884,7 +881,7 @@ handle_pragma_optimize (cpp_reader *ARG_UNUSED(dummy)) token = pragma_lex (&x); else GCC_BAD ("%<#pragma GCC optimize (string [,string]...)%> does " - "not have a final %<)%>."); + "not have a final %<)%>"); } if (token != CPP_EOF) diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 01ce661aa72..868247168fe 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -667,7 +667,7 @@ Warn when a register variable is declared volatile Wwrite-strings C ObjC C++ ObjC++ Var(warn_write_strings) Warning -In C++, nonzero means warn about deprecated conversion from string literals to `char *'. In C, similar warning, except that the conversion is of course not deprecated by the ISO C standard. +In C++, nonzero means warn about deprecated conversion from string literals to 'char *'. In C, similar warning, except that the conversion is of course not deprecated by the ISO C standard. Wpointer-sign C ObjC Var(warn_pointer_sign) Init(-1) Warning @@ -1213,8 +1213,8 @@ C ObjC C++ ObjC++ Var(flag_undef) Do not predefine system-specific and GCC-specific macros v -Common C ObjC C++ ObjC++ -Enable verbose output +C ObjC C++ ObjC++ +; Documented in common.opt w C ObjC C++ ObjC++ diff --git a/gcc/c-family/stub-objc.c b/gcc/c-family/stub-objc.c index 9dd6ef52f89..5cd6e6d6e79 100644 --- a/gcc/c-family/stub-objc.c +++ b/gcc/c-family/stub-objc.c @@ -361,6 +361,15 @@ objc_maybe_build_modify_expr (tree ARG_UNUSED (lhs), tree ARG_UNUSED (rhs)) return 0; } +tree +objc_build_incr_expr_for_property_ref (location_t ARG_UNUSED (location), + enum tree_code ARG_UNUSED (code), + tree ARG_UNUSED (argument), + tree ARG_UNUSED (increment)) +{ + return 0; +} + void objc_add_synthesize_declaration (location_t ARG_UNUSED (start_locus), tree ARG_UNUSED (property_and_ivar_list)) |