diff options
190 files changed, 4340 insertions, 1081 deletions
diff --git a/ChangeLog.MELT b/ChangeLog.MELT index b50069c1e31..e736bfcf4e1 100644 --- a/ChangeLog.MELT +++ b/ChangeLog.MELT @@ -1,4 +1,8 @@ +2010-11-08 Basile Starynkevitch <basile@starynkevitch.net> + + MELT branch merged with trunk rev 166453 + 2010-11-05 Basile Starynkevitch <basile@starynkevitch.net> MELT branch merged with trunk rev 166377 diff --git a/contrib/ChangeLog b/contrib/ChangeLog index 4d46888e6ae..61478153915 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,8 @@ +2010-11-08 Eric Botcazou <ebotcazou@adacore.com> + + * make_sunver.pl: Ignore entries without symbol name first. Then do + not ignore symbols marked as 'R'. + 2010-10-18 Andi Kleen <ak@linux.intel.com> * gccbug.el: Remove. diff --git a/contrib/make_sunver.pl b/contrib/make_sunver.pl index d0875781dc6..bb45004c283 100644 --- a/contrib/make_sunver.pl +++ b/contrib/make_sunver.pl @@ -58,9 +58,11 @@ while (<NM>) { # nm prints out stuff at the start, ignore it. next if (/^$/); next if (/:$/); - # Ignore register (SPARC only), undefined and local symbols. The - # symbol name is optional; Sun nm emits none for local or .bss symbols. - next if (/^([^ ]+)?[ \t]+[RUa-z][ \t]+/); + # Ignore entries without symbol name. Sun nm emits those for local, .bss + # or scratch register (SPARC only) symbols for example. + next if (/^ /); + # Ignore undefined and local symbols. + next if (/^[^ ]+[ \t]+[Ua-z][ \t]+/); # Ignore objects without symbol table. Message goes to stdout with Sun # nm, while GNU nm emits the corresponding message to stderr. next if (/.* - No symbol table data/); diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 80f2ee31a6c..49378ae057d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,241 @@ +2010-11-08 Michael Meissner <meissner@linux.vnet.ibm.com> + + PR target/46378 + * config/rs6000/rs6000.c (rs6000_option_override_internal): Don't + turn on ISA 2.04 rounding instructions for power5. + + * config/rs6000/rs6000.md (friz): Friz is an ISA 2.04 instruciton, + not ISA 2.02. + + PR target/45585 + * config/rs6000/darwin.md (movdi_low): Allow DImode values to be + in FPR registers. + (movdi_low_st): Ditto. + +2010-11-08 Joern Rennecke <amylaar@spamcop.net> + Richard Henderson <rth@redhat.com> + + PR target/44758 + * config/frv/frv.md (attribute cpu): Cast value to enum attr_cpu. + (attribute acc_group): Cast value to enum attr_acc_group. + (*movdi_nodouble+6): Use gen_int_mode. + * config/frv/frv-protos.h (frv_trampoline_size): Declare no matter + if RTX_CODE is defined or not. + * config/frv/frv.c (enum frv_io_type): New enum, broken out of + struct frv_io. + (frv_handle_option): Mark parameter value with ATTRIBUTE_UNUSED. + (frv_frame_access, frv_expand_prologue): Remove unused variables. + (frv_expand_block_clear): Likewise. + (frv_trampoline_init): Use LCT_NORMAL. + (struct frv_packet_group): New struct, broken out of type of + frv_packet. + (frv_start_packet, frv_reorder_packet): Initialize group to GROUP_I, + use cast in loop counter increment. + (frv_extract_membar): Cast HOST_WIDE_INT to enum frv_io_type before + assigning to io->type. + (bdesc_set): Use rtx_code UNKNOWN in initializer. + (bdesc_1arg, bdesc_2arg, bdesc_int_void2arg): Likewise. + (bdesc_prefetches, bdesc_cut, bdesc_2argimm, bdesc_void2arg): Likewise. + (bdesc_void3arg, bdesc_voidacc, bdesc_loads, bdesc_stores): Likewise. + (frv_read_argument): Use expand_normal. + + PR target/44757 + * config/lm32/lm32.h (LEGITIMATE_CONSTANT_P): Call + lm32_legitimate_constant_p. + * config/lm32/lm32.md (ashlsi3): Remove unused variable. + * config/lm32/lm32.c (gen_int_relational): Make new block for + LE / LT / LEU / LTU case. Declare variables at start of block. + (lm32_block_move_inline): Use XALLOCAVEC. + +2010-11-08 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + * config/i386/i386.c (ix86_function_arg_boundary): Fix warning + message. + +2010-11-08 Basile Starynkevitch <basile@starynkevitch.net> + + * gengtype (get_output_file_for_structure): Ensure type is union + or struct. + (write_splay_tree_allocator_def): Use + get_output_file_with_visibility. + +2010-11-08 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> + + * config/s390/s390.c (s390_handle_arch_option): Set type and flags + to defined values in case of an error. + (s390_option_override): Skip further processing if the -march + parameter wasn't recognized. + +2010-11-08 Joern Rennecke <amylaar@spamcop.net> + + * caller-save.c (reg_save_code): After HARD_REGNO_MODE_OK check fails, + assert that REG is a hard register number before using it as an index. + + PR bootstrap/46358 + * config/i386/i386.c (ix86_expand_split_stack_prologue): + Avoid warnings when HOST_WIDE_INT is 32 bit. + +2010-11-08 Eric Botcazou <ebotcazou@adacore.com> + + PR target/46208 + * config/sparc/sparc.c (TARGET_PROMOTE_PROTOTYPES): Delete. + (sparc_promote_prototypes): Likewise. + (sparc_promote_function_mode): Promote in 32-bit mode as well. + (sparc_return_in_memory): Remove superfluous parentheses. + (sparc_struct_value_rtx): Fix long lines. + (sparc_function_value_1): Promote in 32-bit mode as well. + +2010-11-08 Andrey Belevantsev <abel@ispras.ru> + + PR rtl-optimization/45352 + * sel-sched.c (find_best_expr): Do not set pneed_stall when + the variable_issue hook is not implemented. + (fill_insns): Remove dead variable stall_iterations. + (init_seqno_1): Force EBB start for resetting sched cycles on any + successor blocks of the rescheduled region. + (sel_sched_region_1): Use bitmap_bit_p instead of bitmap_clear_bit. + (reset_sched_cycles_in_current_ebb): Add debug printing. + New variable issued_insns. Advance state when we have issued + issue_rate insns. + +2010-11-08 Basile Starynkevitch <basile@starynkevitch.net> + + * gengtype (main): Get here's position using POS_HERE macro for + do*typedef calls. + +2010-11-07 Ian Lance Taylor <iant@google.com> + + PR target/46089 + * config/i386/i386.c (split_stack_fn_large): New static variable. + (ix86_expand_split_stack_prologue): Handle large model. + +2010-11-07 Andreas Schwab <schwab@linux-m68k.org> + + * config/m68k/m68k.c (m68k_delegitimize_address): Update to handle + all possible addressing modes. + +2010-11-07 Uros Bizjak <ubizjak@gmail.com> + + PR tree-optimization/46346 + * tree-ssa-forwprop.c (rhs_to_tree): Handle GIMPLE_TERNARY_RHS. + +2010-11-07 Richard Sandiford <rdsandiford@googlemail.com> + + * config/mips/mips.c: Revert previous patch. + * config/mips/mips.md: Likewise. + +2010-11-07 Richard Sandiford <rdsandiford@googlemail.com> + + * config/mips/mips.c (mips_rtx_costs): Handle FMA. + * config/mips/mips.md (*madd4<mode>, *madd3<mode>, *msub4<mode>) + (*msub3<mode>, *nmadd4<mode>_fastmath, *nmadd3<mode>_fastmath) + (*nmsub4<mode>_fastmath, *nmsub3<mode>_fastmath): Delete. + (*nmadd4<mode>, *nmadd3<mode>. *nmsub4<mode>, *nmsub3<mode>): Redefine + to use FMA. + (fma<mode>4, *fma<mode>4_madd3, *fma<mode>4_madd4): New patterns. + (fms<mode>4, *fms<mode>4_msub3, *fms<mode>4_msub4): Likewise. + (fnms<mode>4, *fnms<mode>4_nmadd3, *fnms<mode>4_nmadd4): Likewise. + (fnma<mode>4, *fnma<mode>4_nmsub3, *fnma<mode>4_nmsub4): Likewise. + +2010-11-06 Simon Martin <simartin@users.sourceforge.net> + + PR c/43384 + * c-decl.c (lookup_label): Labels can only be referenced in a + function's scope. + (store_parm_decls_oldstyle): Skip erroneous parameters. + +2010-11-06 Anatoly Sokolov <aesok@post.ru> + + * config/fr30/fr30.h (FUNCTION_VALUE_REGNO_P, FUNCTION_VALUE, + LIBCALL_VALUE): Remove macros. + * config/fr30/fr30.c (TARGET_FUNCTION_VALUE, TARGET_LIBCALL_VALUE, + TARGET_FUNCTION_VALUE_REGNO_P): Define. + (fr30_function_value_regno_p, fr30_function_value, + fr30_libcall_value): New functions. + +2010-11-06 Joern Rennecke <amylaar@spamcop.net> + + PR middle-end/46314 + * target.def (generate_internal_label): New asm_out hook. + * output.h (default_generate_internal_label): Declare. + * varasm.c (default_generate_internal_label): Define. + +2010-11-06 Iain Sandoe <iains@gcc.gnu.org> + + PR target/44981 + * doc/extend.tex (format): Document NSString extension. + (format_arg): Likewise. + (Darwin Format Checks): New section. + * doc/tm.texi: Document string object hooks (generated). + * doc/tm.texi.in (TARGET_OBJC_CONSTRUCT_STRING_OBJECT) Rename. + (TARGET_STRING_OBJECT_REF_TYPE_P): New. + (TARGET_CHECK_STRING_OBJECT_FORMAT_ARG): New. + * target.def (objc_construct_string_object): Rename, amend + documentation. + (string_object_ref_type_p): New hook. + (check_string_object_format_arg): New hook. + * c-parser.c (c_parser_attributes): Allow objective-c class names as + attribute identifiers. + * config/darwin-c.c (darwin_cfstring_ref_p): New. + (darwin_check_cfstring_format_arg): New. + (darwin_additional_format_types): New. + * config/darwin-protos.h (darwin_cfstring_ref_p) New. + (darwin_check_cfstring_format_arg): New. + * config/darwin.h (TARGET_OBJC_CONSTRUCT_STRING_OBJECT) Renamed. + (TARGET_STRING_OBJECT_REF_TYPE_P): New. + (TARGET_N_FORMAT_TYPES): New. + (TARGET_CHECK_STRING_OBJECT_FORMAT_ARG): New. + +2010-11-06 Eric Botcazou <ebotcazou@adacore.com> + Pascal Obry <obry@adacore.com> + + * config/i386/cygming.h (DWARF_FRAME_REGISTERS): Redefine. Use 33 + in 64-bit mode and 17 otherwise. + +2010-11-06 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> + + PR debug/45939 + * var-tracking.c (emit_note_insn_var_location): Make sure that + call related var location notes come before the normal ones. + +2010-11-05 H.J. Lu <hongjiu.lu@intel.com> + + PR target/46326 + * config/i386/i386.c (ix86_delegitimize_address): Fix a typo + in the last change. + +2010-11-05 Ian Lance Taylor <iant@google.com> + + * explow.c (allocate_dynamic_stack_space): Check MALLOC_ABI_ALIGNMENT. + +2010-11-05 Jakub Jelinek <jakub@redhat.com> + + PR c/44772 + * c-decl.c (warn_cxx_compat_finish_struct): Don't call + pointer_set_contains if DECL_NAME is NULL. + +2010-11-05 Ian Lance Taylor <iant@google.com> + + PR target/46084 + * explow.c (allocate_dynamic_stack_space): If flag_split_stack, + request enough additional space for alignment, and force alignment. + +2010-11-05 Kai Tietz <kai.tietz@onevision.com> + + * config/i386/i386.c (legitimate_pic_address_disp_p): + Handle UNSPEC_PCREL. + (ix86_legitimate_address_p): Likewise. + (legitimize_pic_address): Likewise. + (output_pic_addr_const): Likewise. + (ix86_delegitimize_address): Likewise. + (ix86_find_base_term): Likewise. + (memory_address_length): Likewise. + (x86_output_mi_thunk): Handle special case x64 + for non local binding. + * config/i386/i386.md (UNSPEC_PCREL): New. + * config/i386/winnt.c (i386_pe_binds_local_p): + Allow weak symbol for x64 windows with non-local binding. + 2010-11-05 Jakub Jelinek <jakub@redhat.com> PR target/45670 @@ -90,8 +328,7 @@ 2010-11-05 Jakub Jelinek <jakub@redhat.com> - * cfgexpand.c (expand_debug_expr): Handle MEM_REF - with non-zero offset. + * cfgexpand.c (expand_debug_expr): Handle MEM_REF with non-zero offset. PR tree-optimization/46099 * tree-parloops.c (take_address_of): Add GSI argument. Return NULL diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 7fbcb63043e..c524464ce69 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20101105 +20101108 diff --git a/gcc/c-decl.c b/gcc/c-decl.c index bb7cf64553b..e1f14029b80 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -3013,7 +3013,7 @@ lookup_label (tree name) tree label; struct c_label_vars *label_vars; - if (current_function_decl == 0) + if (current_function_scope == 0) { error ("label %qE referenced outside of any function", name); return 0; @@ -6877,7 +6877,8 @@ warn_cxx_compat_finish_struct (tree fieldlist) for (x = fieldlist; x != NULL_TREE; x = DECL_CHAIN (x)) { - if (pointer_set_contains (tset, DECL_NAME (x))) + if (DECL_NAME (x) != NULL_TREE + && pointer_set_contains (tset, DECL_NAME (x))) { warning_at (DECL_SOURCE_LOCATION (x), OPT_Wc___compat, ("using %qD as both field and typedef name is " @@ -7846,6 +7847,9 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) if (b && B_IN_CURRENT_SCOPE (b)) { decl = b->decl; + /* Skip erroneous parameters. */ + if (decl == error_mark_node) + continue; /* If we got something other than a PARM_DECL it is an error. */ if (TREE_CODE (decl) != PARM_DECL) error_at (DECL_SOURCE_LOCATION (decl), diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index c613ab36b8b..1164d919d0e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,24 @@ +2010-11-06 Iain Sandoe <iains@gcc.gnu.org> + + PR target/44981 + * c-format.c (format_type): New type gcc_objc_string_format_type. + (valid_stringptr_type_p): New. + (handle_format_arg_attribute): Use valid_stringptr_type_p (). + (check_format_string): Pass expected type, use + valid_stringptr_type_p (), check that the format string types are + consistent with the format specification. + (decode_format_attr): Warn if NSString is used outside objective-c. + (format_types_orig): Add NSString. + (format_name): New. + (format_flags): New. + (check_format_arg): Handle format strings requiring an external parser. + first_target_format_type: New variable. + (handle_format_attribute): Set up first_target_format_type, pass the + expected format arg string type to check_format_string(). + * c-common.h (FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL): New flag. + * stub-objc.c (objc_string_ref_type_p): New. + (objc_check_format_arg): New. + 2010-11-04 Nicola Pero <nicola.pero@meta-innovation.com> Fixed using the Objective-C 2.0 dot-syntax with class names. diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 13d9227ddca..58d3a321e0f 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1043,6 +1043,8 @@ 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); extern bool objc_is_property_ref (tree); +extern bool objc_string_ref_type_p (tree); +extern void objc_check_format_arg (tree, tree); /* The following are provided by the C and C++ front-ends, and called by ObjC/ObjC++. */ diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index e7fd2295d52..a64717a5510 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "c-format.h" #include "alloc-pool.h" +#include "target.h" /* Set format warning options according to a -Wformat=n option. */ @@ -63,6 +64,7 @@ enum format_type { printf_format_type, asm_fprintf_format_type, gcc_diag_format_type, gcc_tdiag_format_type, gcc_cdiag_format_type, gcc_cxxdiag_format_type, gcc_gfc_format_type, + gcc_objc_string_format_type, format_type_error = -1}; typedef struct function_format_info @@ -77,12 +79,38 @@ static int decode_format_type (const char *); static bool check_format_string (tree argument, unsigned HOST_WIDE_INT format_num, - int flags, bool *no_add_attrs); + int flags, bool *no_add_attrs, + int expected_format_type); static bool get_constant (tree expr, unsigned HOST_WIDE_INT *value, int validated_p); static const char *convert_format_name_to_system_name (const char *attr_name); static bool cmp_attribs (const char *tattr_name, const char *attr_name); +static int first_target_format_type; +static const char *format_name (int format_num); +static int format_flags (int format_num); + +/* Check that we have a pointer to a string suitable for use as a format. + The default is to check for a char type. + For objective-c dialects, this is extended to include references to string + objects validated by objc_string_ref_type_p (). + Targets may also provide a string object type that can be used within c and + c++ and shared with their respective objective-c dialects. In this case the + reference to a format string is checked for validity via a hook. + + The function returns true if strref points to any string type valid for the + language dialect and target. */ + +static bool +valid_stringptr_type_p (tree strref) +{ + return (strref != NULL + && TREE_CODE (strref) == POINTER_TYPE + && (TYPE_MAIN_VARIANT (TREE_TYPE (strref)) == char_type_node + || objc_string_ref_type_p (strref) + || (*targetcm.string_object_ref_type_p) ((const_tree) strref))); +} + /* Handle a "format_arg" attribute; arguments as in struct attribute_spec.handler. */ tree @@ -104,13 +132,13 @@ handle_format_arg_attribute (tree *node, tree ARG_UNUSED (name), argument = TYPE_ARG_TYPES (type); if (argument) { - if (!check_format_string (argument, format_num, flags, no_add_attrs)) + /* The format arg can be any string reference valid for the language and + target. We cannot be more specific in this case. */ + if (!check_format_string (argument, format_num, flags, no_add_attrs, -1)) return NULL_TREE; } - if (TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE - || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))) - != char_type_node)) + if (!valid_stringptr_type_p (TREE_TYPE (type))) { if (!(flags & (int) ATTR_FLAG_BUILT_IN)) error ("function does not return string type"); @@ -121,13 +149,18 @@ handle_format_arg_attribute (tree *node, tree ARG_UNUSED (name), return NULL_TREE; } -/* Verify that the format_num argument is actually a string, in case - the format attribute is in error. */ +/* Verify that the format_num argument is actually a string reference suitable, + for the language dialect and target (in case the format attribute is in + error). When we know the specific reference type expected, this is also + checked. */ static bool check_format_string (tree argument, unsigned HOST_WIDE_INT format_num, - int flags, bool *no_add_attrs) + int flags, bool *no_add_attrs, int expected_format_type) { unsigned HOST_WIDE_INT i; + bool is_objc_sref, is_target_sref, is_char_ref; + tree ref; + int fmt_flags; for (i = 1; i != format_num; i++) { @@ -137,17 +170,78 @@ check_format_string (tree argument, unsigned HOST_WIDE_INT format_num, } if (!argument - || TREE_CODE (TREE_VALUE (argument)) != POINTER_TYPE - || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (argument))) - != char_type_node)) + || !(ref = TREE_VALUE (argument)) + || !valid_stringptr_type_p (ref)) { if (!(flags & (int) ATTR_FLAG_BUILT_IN)) - error ("format string argument not a string type"); + error ("format string argument is not a string type"); *no_add_attrs = true; return false; } - return true; + /* We only know that we want a suitable string reference. */ + if (expected_format_type < 0) + return true; + + /* Now check that the arg matches the expected type. */ + is_char_ref = + (TYPE_MAIN_VARIANT (TREE_TYPE (ref)) == char_type_node); + + fmt_flags = format_flags (expected_format_type); + is_objc_sref = is_target_sref = false; + if (!is_char_ref) + is_objc_sref = objc_string_ref_type_p (ref); + + if (!(fmt_flags & FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL)) + { + if (is_char_ref) + return true; /* OK, we expected a char and found one. */ + else + { + /* We expected a char but found an extended string type. */ + if (is_objc_sref) + error ("found a %<%s%> reference but the format argument should" + " be a string", format_name (gcc_objc_string_format_type)); + else + error ("found a %qT but the format argument should be a string", + ref); + *no_add_attrs = true; + return false; + } + } + + /* We expect a string object type as the format arg. */ + if (is_char_ref) + { + error ("format argument should be a %<%s%> reference but" + " a string was found", format_name (expected_format_type)); + *no_add_attrs = true; + return false; + } + + /* We will assert that objective-c will support either its own string type + or the target-supplied variant. */ + if (!is_objc_sref) + is_target_sref = (*targetcm.string_object_ref_type_p) ((const_tree) ref); + + if (expected_format_type == (int) gcc_objc_string_format_type + && (is_objc_sref || is_target_sref)) + return true; + + /* We will allow a target string ref to match only itself. */ + if (first_target_format_type + && expected_format_type >= first_target_format_type + && is_target_sref) + return true; + else + { + error ("format argument should be a %<%s%> reference", + format_name (expected_format_type)); + *no_add_attrs = true; + return false; + } + + gcc_unreachable (); } /* Verify EXPR is a constant, and store its value. @@ -195,6 +289,16 @@ decode_format_attr (tree args, function_format_info *info, int validated_p) p = convert_format_name_to_system_name (p); info->format_type = decode_format_type (p); + + if (!c_dialect_objc () + && info->format_type == gcc_objc_string_format_type) + { + gcc_assert (!validated_p); + warning (OPT_Wformat, "%qE is only allowed in Objective-C dialects", + format_type_id); + info->format_type = format_type_error; + return false; + } if (info->format_type == format_type_error) { @@ -750,6 +854,11 @@ static const format_kind_info format_types_orig[] = 0, 0, 0, 0, 0, 0, NULL, NULL }, + { "NSString", NULL, NULL, NULL, NULL, + NULL, NULL, + FMT_FLAG_ARG_CONVERT|FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL, 0, 0, 0, 0, 0, 0, + NULL, NULL + }, { "gnu_scanf", scanf_length_specs, scan_char_table, "*'I", NULL, scanf_flag_specs, scanf_flag_pairs, FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK, @@ -812,6 +921,26 @@ typedef struct tree params; } format_check_context; +/* Return the format name (as specified in the original table) for the format + type indicated by format_num. */ +static const char * +format_name (int format_num) +{ + if (format_num >= 0 && format_num < n_format_types) + return format_types[format_num].name; + gcc_unreachable (); +} + +/* Return the format flags (as specified in the original table) for the format + type indicated by format_num. */ +static int +format_flags (int format_num) +{ + if (format_num >= 0 && format_num < n_format_types) + return format_types[format_num].flags; + gcc_unreachable (); +} + static void check_format_info (function_format_info *, tree); static void check_format_arg (void *, tree, unsigned HOST_WIDE_INT); static void check_format_info_main (format_check_results *, @@ -1349,6 +1478,39 @@ check_format_arg (void *ctx, tree format_tree, return; } format_tree = TREE_OPERAND (format_tree, 0); + if (format_types[info->format_type].flags + & (int) FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL) + { + bool objc_str = (info->format_type == gcc_objc_string_format_type); + /* We cannot examine this string here - but we can check that it is + a valid type. */ + if (TREE_CODE (format_tree) != CONST_DECL + || !((objc_str && objc_string_ref_type_p (TREE_TYPE (format_tree))) + || (*targetcm.string_object_ref_type_p) + ((const_tree) TREE_TYPE (format_tree)))) + { + res->number_non_literal++; + return; + } + /* Skip to first argument to check. */ + while (arg_num + 1 < info->first_arg_num) + { + if (params == 0) + return; + params = TREE_CHAIN (params); + ++arg_num; + } + /* So, we have a valid literal string object and one or more params. + We need to use an external helper to parse the string into format + info. For Objective-C variants we provide the resource within the + objc tree, for target variants, via a hook. */ + if (objc_str) + objc_check_format_arg (format_tree, params); + else if (targetcm.check_string_object_format_arg) + (*targetcm.check_string_object_format_arg) (format_tree, params); + /* Else we can't handle it and retire quietly. */ + return; + } if (TREE_CODE (format_tree) == ARRAY_REF && host_integerp (TREE_OPERAND (format_tree, 1), 0) && (offset += tree_low_cst (TREE_OPERAND (format_tree, 1), 0)) >= 0) @@ -2785,6 +2947,8 @@ handle_format_attribute (tree *node, tree ARG_UNUSED (name), tree args, TARGET_N_FORMAT_TYPES * sizeof (dynamic_format_types[0])); format_types = dynamic_format_types; + /* Provide a reference for the first potential external type. */ + first_target_format_type = n_format_types; n_format_types += TARGET_N_FORMAT_TYPES; } #endif @@ -2799,7 +2963,7 @@ handle_format_attribute (tree *node, tree ARG_UNUSED (name), tree args, if (argument) { if (!check_format_string (argument, info.format_num, flags, - no_add_attrs)) + no_add_attrs, info.format_type)) return NULL_TREE; if (info.first_arg_num != 0) diff --git a/gcc/c-family/c-format.h b/gcc/c-family/c-format.h index 9d01f0af495..286219b16df 100644 --- a/gcc/c-family/c-format.h +++ b/gcc/c-family/c-format.h @@ -1,6 +1,6 @@ /* Check calls to formatted I/O functions (-Wformat). Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004, 2007, 2008, 2010 Free Software Foundation, Inc. This file is part of GCC. @@ -73,7 +73,10 @@ enum FMT_FLAG_EMPTY_PREC_OK = 64, /* Gaps are allowed in the arguments with $ operand numbers if all arguments are pointers (scanf). */ - FMT_FLAG_DOLLAR_GAP_POINTER_OK = 128 + FMT_FLAG_DOLLAR_GAP_POINTER_OK = 128, + /* The format arg is an opaque object that will be parsed by an external + facility. */ + FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL = 256 /* Not included here: details of whether width or precision may occur (controlled by width_char and precision_char); details of whether '*' can be used for these (width_type and precision_type); details diff --git a/gcc/c-family/stub-objc.c b/gcc/c-family/stub-objc.c index 1f3b854f0c0..9dd6ef52f89 100644 --- a/gcc/c-family/stub-objc.c +++ b/gcc/c-family/stub-objc.c @@ -2,7 +2,7 @@ that are called from within the C and C++ front-ends, respectively. Copyright (C) 1991, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2007, 2009 Free Software Foundation, Inc. + 2004, 2005, 2007, 2009, 2010 Free Software Foundation, Inc. This file is part of GCC. @@ -440,3 +440,15 @@ void objc_write_global_declarations (void) { } + +bool +objc_string_ref_type_p (tree ARG_UNUSED (strp)) +{ + return false; +} + +void +objc_check_format_arg (tree ARG_UNUSED (format_arg), + tree ARG_UNUSED (args_list)) +{ +} diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 78ccdd4ebfc..e7403b2b182 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -3278,9 +3278,12 @@ c_parser_attributes (c_parser *parser) /* Parse the attribute contents. If they start with an identifier which is followed by a comma or close parenthesis, then the arguments start with that - identifier; otherwise they are an expression list. */ + identifier; otherwise they are an expression list. + In objective-c the identifier may be a classname. */ if (c_parser_next_token_is (parser, CPP_NAME) - && c_parser_peek_token (parser)->id_kind == C_ID_ID + && (c_parser_peek_token (parser)->id_kind == C_ID_ID + || (c_dialect_objc () + && c_parser_peek_token (parser)->id_kind == C_ID_CLASSNAME)) && ((c_parser_peek_2nd_token (parser)->type == CPP_COMMA) || (c_parser_peek_2nd_token (parser)->type == CPP_CLOSE_PAREN))) diff --git a/gcc/caller-save.c b/gcc/caller-save.c index 9ca8592bf34..e10681ce527 100644 --- a/gcc/caller-save.c +++ b/gcc/caller-save.c @@ -116,11 +116,15 @@ reg_save_code (int reg, enum machine_mode mode) if (cached_reg_save_code[reg][mode]) return cached_reg_save_code[reg][mode]; if (!HARD_REGNO_MODE_OK (reg, mode)) - { - cached_reg_save_code[reg][mode] = -1; - cached_reg_restore_code[reg][mode] = -1; - return -1; - } + { + /* Depending on how HARD_REGNO_MODE_OK is defined, range propagation + might deduce here that reg >= FIRST_PSEUDO_REGISTER. So the assert + below silences a warning. */ + gcc_assert (reg < FIRST_PSEUDO_REGISTER); + cached_reg_save_code[reg][mode] = -1; + cached_reg_restore_code[reg][mode] = -1; + return -1; + } /* Update the register number and modes of the register and memory operand. */ diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c index ef3cfbc56b5..99b6db1637d 100644 --- a/gcc/config/darwin-c.c +++ b/gcc/config/darwin-c.c @@ -1,5 +1,5 @@ /* Darwin support needed only by C/C++ frontends. - Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008 + Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2010 Free Software Foundation, Inc. Contributed by Apple Computer Inc. @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "incpath.h" #include "c-family/c-common.h" #include "c-family/c-pragma.h" +#include "c-family/c-format.h" #include "diagnostic-core.h" #include "toplev.h" #include "flags.h" @@ -678,3 +679,37 @@ darwin_objc_construct_string (tree str) return darwin_build_constant_cfstring (str); } + +/* The string ref type is created as CFStringRef by <CFBase.h> therefore, we + must match for it explicitly, since it's outside the gcc code. */ + +bool +darwin_cfstring_ref_p (const_tree strp) +{ + tree tn; + if (!strp || TREE_CODE (strp) != POINTER_TYPE) + return false; + + tn = TYPE_NAME (strp); + if (tn) + tn = DECL_NAME (tn); + return (tn + && IDENTIFIER_POINTER (tn) + && !strncmp (IDENTIFIER_POINTER (tn), "CFStringRef", 8)); +} + +/* At present the behavior of this is undefined and it does nothing. */ +void +darwin_check_cfstring_format_arg (tree ARG_UNUSED (format_arg), + tree ARG_UNUSED (args_list)) +{ +} + +/* The extra format types we recognize. */ +const format_kind_info darwin_additional_format_types[] = { + { "CFString", NULL, NULL, NULL, NULL, + NULL, NULL, + FMT_FLAG_ARG_CONVERT|FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL, 0, 0, 0, 0, 0, 0, + NULL, NULL + } +}; diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h index 30b3f822c98..e70de1bee80 100644 --- a/gcc/config/darwin-protos.h +++ b/gcc/config/darwin-protos.h @@ -97,7 +97,9 @@ extern void darwin_init_cfstring_builtins (unsigned); extern tree darwin_fold_builtin (tree, int, tree *, bool); extern tree darwin_objc_construct_string (tree); extern bool darwin_cfstring_p (tree); -extern tree darwin_build_constant_cfstring (tree str); +extern bool darwin_cfstring_ref_p (const_tree); +extern void darwin_check_cfstring_format_arg (tree, tree); +extern tree darwin_build_constant_cfstring (tree); extern void darwin_enter_string_into_cfstring_table (tree); extern void darwin_asm_output_anchor (rtx symbol); diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 1974704d25a..ffed58a1300 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -1023,9 +1023,18 @@ __enable_execute_stack (void *addr) \ /* We have target-specific builtins. */ #define TARGET_FOLD_BUILTIN darwin_fold_builtin -#define TARGET_OBJC_CONSTRUCT_STRING \ +#define TARGET_OBJC_CONSTRUCT_STRING_OBJECT \ darwin_objc_construct_string +#define TARGET_STRING_OBJECT_REF_TYPE_P \ + darwin_cfstring_ref_p + +#define TARGET_N_FORMAT_TYPES 1 +#define TARGET_FORMAT_TYPES darwin_additional_format_types + +#define TARGET_CHECK_STRING_OBJECT_FORMAT_ARG \ + darwin_check_cfstring_format_arg + #define TARGET_HAS_TARGETCM 1 #ifndef CROSS_DIRECTORY_STRUCTURE diff --git a/gcc/config/fr30/fr30.c b/gcc/config/fr30/fr30.c index 95bbd61d260..6aad8504c71 100644 --- a/gcc/config/fr30/fr30.c +++ b/gcc/config/fr30/fr30.c @@ -124,6 +124,9 @@ static rtx fr30_function_arg (CUMULATIVE_ARGS *, enum machine_mode, static void fr30_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool); static bool fr30_frame_pointer_required (void); +static rtx fr30_function_value (const_tree, const_tree, bool); +static rtx fr30_libcall_value (enum machine_mode, const_rtx); +static bool fr30_function_value_regno_p (const unsigned int); static bool fr30_can_eliminate (const int, const int); static void fr30_asm_trampoline_template (FILE *); static void fr30_trampoline_init (rtx, tree, rtx); @@ -172,6 +175,13 @@ static const struct default_options fr30_option_optimization_table[] = #undef TARGET_FUNCTION_ARG_ADVANCE #define TARGET_FUNCTION_ARG_ADVANCE fr30_function_arg_advance +#undef TARGET_FUNCTION_VALUE +#define TARGET_FUNCTION_VALUE fr30_function_value +#undef TARGET_LIBCALL_VALUE +#define TARGET_LIBCALL_VALUE fr30_libcall_value +#undef TARGET_FUNCTION_VALUE_REGNO_P +#define TARGET_FUNCTION_VALUE_REGNO_P fr30_function_value_regno_p + #undef TARGET_SETUP_INCOMING_VARARGS #define TARGET_SETUP_INCOMING_VARARGS fr30_setup_incoming_varargs #undef TARGET_MUST_PASS_IN_STACK @@ -703,6 +713,34 @@ fr30_print_operand (FILE *file, rtx x, int code) } /*}}}*/ + +/* Implements TARGET_FUNCTION_VALUE. */ + +static rtx +fr30_function_value (const_tree valtype, + const_tree fntype_or_decli ATTRIBUTE_UNUSED, + bool outgoing ATTRIBUTE_UNUSED) +{ + return gen_rtx_REG (TYPE_MODE (valtype), RETURN_VALUE_REGNUM); +} + +/* Implements TARGET_LIBCALL_VALUE. */ + +static rtx +fr30_libcall_value (enum machine_mode mode, + const_rtx fun ATTRIBUTE_UNUSED) +{ + return gen_rtx_REG (mode, RETURN_VALUE_REGNUM); +} + +/* Implements TARGET_FUNCTION_VALUE_REGNO_P. */ + +static bool +fr30_function_value_regno_p (const unsigned int regno) +{ + return (regno == RETURN_VALUE_REGNUM); +} + /*{{{ Function arguments */ /* Return true if we should pass an argument on the stack rather than diff --git a/gcc/config/fr30/fr30.h b/gcc/config/fr30/fr30.h index ac42145f314..779887722fa 100644 --- a/gcc/config/fr30/fr30.h +++ b/gcc/config/fr30/fr30.h @@ -588,31 +588,6 @@ enum reg_class ((REGNO) >= FIRST_ARG_REGNUM && ((REGNO) < FIRST_ARG_REGNUM + FR30_NUM_ARG_REGS)) /*}}}*/ -/*{{{ How Scalar Function Values are Returned. */ - -#define FUNCTION_VALUE(VALTYPE, FUNC) \ - gen_rtx_REG (TYPE_MODE (VALTYPE), RETURN_VALUE_REGNUM) - -/* A C expression to create an RTX representing the place where a library - function returns a value of mode MODE. If the precise function being called - is known, FUNC is a tree node (`FUNCTION_DECL') for it; otherwise, FUNC is a - null pointer. This makes it possible to use a different value-returning - convention for specific functions when all their calls are known. - - Note that "library function" in this context means a compiler support - routine, used to perform arithmetic, whose name is known specially by the - compiler and was not mentioned in the C code being compiled. - - The definition of `LIBRARY_VALUE' need not be concerned aggregate data - types, because none of the library functions returns such types. */ -#define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, RETURN_VALUE_REGNUM) - -/* A C expression that is nonzero if REGNO is the number of a hard register in - which the values of called function may come back. */ - -#define FUNCTION_VALUE_REGNO_P(REGNO) ((REGNO) == RETURN_VALUE_REGNUM) - -/*}}}*/ /*{{{ How Large Values are Returned. */ /* Define this macro to be 1 if all structure and union return values must be diff --git a/gcc/config/frv/frv-protos.h b/gcc/config/frv/frv-protos.h index af9f1cdd7e2..3fd9d0c16d9 100644 --- a/gcc/config/frv/frv-protos.h +++ b/gcc/config/frv/frv-protos.h @@ -89,7 +89,6 @@ extern rtx frv_ifcvt_modify_insn (ce_if_block_t *, rtx, rtx); extern void frv_ifcvt_modify_final (ce_if_block_t *); extern void frv_ifcvt_modify_cancel (ce_if_block_t *); #endif -extern int frv_trampoline_size (void); extern enum reg_class frv_secondary_reload_class (enum reg_class, enum machine_mode, rtx); @@ -101,6 +100,7 @@ extern int frv_legitimate_constant_p (rtx); extern enum machine_mode frv_select_cc_mode (enum rtx_code, rtx, rtx); #endif /* RTX_CODE */ +extern int frv_trampoline_size (void); extern int direct_return_p (void); extern int frv_issue_rate (void); extern int frv_acc_group (rtx); diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c index adc69117c4b..fc127ac115a 100644 --- a/gcc/config/frv/frv.c +++ b/gcc/config/frv/frv.c @@ -109,13 +109,15 @@ static GTY(()) rtx frv_nops[NUM_NOP_PATTERNS]; /* The number of nop instructions in frv_nops[]. */ static unsigned int frv_num_nops; + /* The type of access. FRV_IO_UNKNOWN means the access can be either + a read or a write. */ +enum frv_io_type { FRV_IO_UNKNOWN, FRV_IO_READ, FRV_IO_WRITE }; + /* Information about one __builtin_read or __builtin_write access, or the combination of several such accesses. The most general value is all-zeros (an unknown access to an unknown address). */ struct frv_io { - /* The type of access. FRV_IO_UNKNOWN means the access can be either - a read or a write. */ - enum { FRV_IO_UNKNOWN, FRV_IO_READ, FRV_IO_WRITE } type; + enum frv_io_type type; /* The constant address being accessed, or zero if not known. */ HOST_WIDE_INT const_address; @@ -625,7 +627,7 @@ frv_cannot_force_const_mem (rtx x ATTRIBUTE_UNUSED) /* Implement TARGET_HANDLE_OPTION. */ static bool -frv_handle_option (size_t code, const char *arg, int value) +frv_handle_option (size_t code, const char *arg, int value ATTRIBUTE_UNUSED) { switch (code) { @@ -1720,9 +1722,10 @@ frv_frame_access (frv_frame_accessor_t *accessor, rtx reg, int stack_offset) && GET_CODE (XEXP (XEXP (mem, 0), 1)) == REG) { rtx temp = gen_rtx_REG (SImode, TEMP_REGNO); - rtx insn = emit_move_insn (temp, - gen_rtx_PLUS (SImode, XEXP (XEXP (mem, 0), 0), - XEXP (XEXP (mem, 0), 1))); + + emit_move_insn (temp, + gen_rtx_PLUS (SImode, XEXP (XEXP (mem, 0), 0), + XEXP (XEXP (mem, 0), 1))); mem = gen_rtx_MEM (DImode, temp); } emit_insn (gen_rtx_SET (VOIDmode, reg, mem)); @@ -1753,9 +1756,9 @@ frv_frame_access (frv_frame_accessor_t *accessor, rtx reg, int stack_offset) && GET_CODE (XEXP (XEXP (mem, 0), 1)) == REG) { rtx temp = gen_rtx_REG (SImode, TEMP_REGNO); - rtx insn = emit_move_insn (temp, - gen_rtx_PLUS (SImode, XEXP (XEXP (mem, 0), 0), - XEXP (XEXP (mem, 0), 1))); + emit_move_insn (temp, + gen_rtx_PLUS (SImode, XEXP (XEXP (mem, 0), 0), + XEXP (XEXP (mem, 0), 1))); mem = gen_rtx_MEM (DImode, temp); } @@ -1860,11 +1863,9 @@ frv_expand_prologue (void) accessor.op = FRV_STORE; if (frame_pointer_needed && info->total_size > 2048) { - rtx insn; - accessor.base = gen_rtx_REG (Pmode, OLD_SP_REGNO); accessor.base_offset = info->total_size; - insn = emit_insn (gen_movsi (accessor.base, sp)); + emit_insn (gen_movsi (accessor.base, sp)); } else { @@ -2393,7 +2394,6 @@ frv_expand_block_clear (rtx operands[]) int align; int bytes; int offset; - int num_reg; rtx dest_reg; rtx dest_addr; rtx dest_mem; @@ -2421,7 +2421,7 @@ frv_expand_block_clear (rtx operands[]) /* Move the address into a scratch register. */ dest_reg = copy_addr_to_reg (XEXP (orig_dest, 0)); - num_reg = offset = 0; + offset = 0; for ( ; bytes > 0; (bytes -= clear_bytes), (offset += clear_bytes)) { /* Calculate the correct offset for src/dest. */ @@ -6371,7 +6371,7 @@ frv_trampoline_init (rtx m_tramp, tree fndecl, rtx static_chain) rtx sc_reg = force_reg (Pmode, static_chain); emit_library_call (gen_rtx_SYMBOL_REF (SImode, "__trampoline_setup"), - FALSE, VOIDmode, 4, + LCT_NORMAL, VOIDmode, 4, addr, Pmode, GEN_INT (frv_trampoline_size ()), SImode, fnaddr, Pmode, @@ -7167,6 +7167,24 @@ frv_issues_to_branch_unit_p (rtx insn) return frv_unit_groups[frv_insn_unit (insn)] == GROUP_B; } +/* The instructions in the packet, partitioned into groups. */ +struct frv_packet_group { + /* How many instructions in the packet belong to this group. */ + unsigned int num_insns; + + /* A list of the instructions that belong to this group, in the order + they appear in the rtl stream. */ + rtx insns[ARRAY_SIZE (frv_unit_codes)]; + + /* The contents of INSNS after they have been sorted into the correct + assembly-language order. Element X issues to unit X. The list may + contain extra nops. */ + rtx sorted[ARRAY_SIZE (frv_unit_codes)]; + + /* The member of frv_nops[] to use in sorted[]. */ + rtx nop; +}; + /* The current state of the packing pass, implemented by frv_pack_insns. */ static struct { /* The state of the pipeline DFA. */ @@ -7192,22 +7210,7 @@ static struct { unsigned int issue_rate; /* The instructions in the packet, partitioned into groups. */ - struct frv_packet_group { - /* How many instructions in the packet belong to this group. */ - unsigned int num_insns; - - /* A list of the instructions that belong to this group, in the order - they appear in the rtl stream. */ - rtx insns[ARRAY_SIZE (frv_unit_codes)]; - - /* The contents of INSNS after they have been sorted into the correct - assembly-language order. Element X issues to unit X. The list may - contain extra nops. */ - rtx sorted[ARRAY_SIZE (frv_unit_codes)]; - - /* The member of frv_nops[] to use in sorted[]. */ - rtx nop; - } groups[NUM_GROUPS]; + struct frv_packet_group groups[NUM_GROUPS]; /* The instructions that make up the current packet. */ rtx insns[ARRAY_SIZE (frv_unit_codes)]; @@ -7380,7 +7383,8 @@ frv_start_packet (void) memset (frv_packet.regstate, 0, sizeof (frv_packet.regstate)); frv_packet.num_mems = 0; frv_packet.num_insns = 0; - for (group = 0; group < NUM_GROUPS; group++) + for (group = GROUP_I; group < NUM_GROUPS; + group = (enum frv_insn_group) (group + 1)) frv_packet.groups[group].num_insns = 0; } @@ -7729,7 +7733,8 @@ frv_reorder_packet (void) struct frv_packet_group *packet_group; /* First sort each group individually. */ - for (group = 0; group < NUM_GROUPS; group++) + for (group = GROUP_I; group < NUM_GROUPS; + group = (enum frv_insn_group) (group + 1)) { cursor[group] = 0; frv_sort_insn_group (group); @@ -7862,7 +7867,7 @@ static void frv_extract_membar (struct frv_io *io, rtx insn) { extract_insn (insn); - io->type = INTVAL (recog_data.operand[2]); + io->type = (enum frv_io_type) INTVAL (recog_data.operand[2]); io->const_address = INTVAL (recog_data.operand[1]); io->var_address = XEXP (recog_data.operand[0], 0); } @@ -8281,99 +8286,100 @@ struct builtin_description static struct builtin_description bdesc_set[] = { - { CODE_FOR_mhdsets, "__MHDSETS", FRV_BUILTIN_MHDSETS, 0, 0 } + { CODE_FOR_mhdsets, "__MHDSETS", FRV_BUILTIN_MHDSETS, UNKNOWN, 0 } }; /* Media intrinsics that take just one argument. */ static struct builtin_description bdesc_1arg[] = { - { CODE_FOR_mnot, "__MNOT", FRV_BUILTIN_MNOT, 0, 0 }, - { CODE_FOR_munpackh, "__MUNPACKH", FRV_BUILTIN_MUNPACKH, 0, 0 }, - { CODE_FOR_mbtoh, "__MBTOH", FRV_BUILTIN_MBTOH, 0, 0 }, - { CODE_FOR_mhtob, "__MHTOB", FRV_BUILTIN_MHTOB, 0, 0 }, - { CODE_FOR_mabshs, "__MABSHS", FRV_BUILTIN_MABSHS, 0, 0 }, - { CODE_FOR_scutss, "__SCUTSS", FRV_BUILTIN_SCUTSS, 0, 0 } + { CODE_FOR_mnot, "__MNOT", FRV_BUILTIN_MNOT, UNKNOWN, 0 }, + { CODE_FOR_munpackh, "__MUNPACKH", FRV_BUILTIN_MUNPACKH, UNKNOWN, 0 }, + { CODE_FOR_mbtoh, "__MBTOH", FRV_BUILTIN_MBTOH, UNKNOWN, 0 }, + { CODE_FOR_mhtob, "__MHTOB", FRV_BUILTIN_MHTOB, UNKNOWN, 0}, + { CODE_FOR_mabshs, "__MABSHS", FRV_BUILTIN_MABSHS, UNKNOWN, 0 }, + { CODE_FOR_scutss, "__SCUTSS", FRV_BUILTIN_SCUTSS, UNKNOWN, 0 } }; /* Media intrinsics that take two arguments. */ static struct builtin_description bdesc_2arg[] = { - { CODE_FOR_mand, "__MAND", FRV_BUILTIN_MAND, 0, 0 }, - { CODE_FOR_mor, "__MOR", FRV_BUILTIN_MOR, 0, 0 }, - { CODE_FOR_mxor, "__MXOR", FRV_BUILTIN_MXOR, 0, 0 }, - { CODE_FOR_maveh, "__MAVEH", FRV_BUILTIN_MAVEH, 0, 0 }, - { CODE_FOR_msaths, "__MSATHS", FRV_BUILTIN_MSATHS, 0, 0 }, - { CODE_FOR_msathu, "__MSATHU", FRV_BUILTIN_MSATHU, 0, 0 }, - { CODE_FOR_maddhss, "__MADDHSS", FRV_BUILTIN_MADDHSS, 0, 0 }, - { CODE_FOR_maddhus, "__MADDHUS", FRV_BUILTIN_MADDHUS, 0, 0 }, - { CODE_FOR_msubhss, "__MSUBHSS", FRV_BUILTIN_MSUBHSS, 0, 0 }, - { CODE_FOR_msubhus, "__MSUBHUS", FRV_BUILTIN_MSUBHUS, 0, 0 }, - { CODE_FOR_mqaddhss, "__MQADDHSS", FRV_BUILTIN_MQADDHSS, 0, 0 }, - { CODE_FOR_mqaddhus, "__MQADDHUS", FRV_BUILTIN_MQADDHUS, 0, 0 }, - { CODE_FOR_mqsubhss, "__MQSUBHSS", FRV_BUILTIN_MQSUBHSS, 0, 0 }, - { CODE_FOR_mqsubhus, "__MQSUBHUS", FRV_BUILTIN_MQSUBHUS, 0, 0 }, - { CODE_FOR_mpackh, "__MPACKH", FRV_BUILTIN_MPACKH, 0, 0 }, - { CODE_FOR_mcop1, "__Mcop1", FRV_BUILTIN_MCOP1, 0, 0 }, - { CODE_FOR_mcop2, "__Mcop2", FRV_BUILTIN_MCOP2, 0, 0 }, - { CODE_FOR_mwcut, "__MWCUT", FRV_BUILTIN_MWCUT, 0, 0 }, - { CODE_FOR_mqsaths, "__MQSATHS", FRV_BUILTIN_MQSATHS, 0, 0 }, - { CODE_FOR_mqlclrhs, "__MQLCLRHS", FRV_BUILTIN_MQLCLRHS, 0, 0 }, - { CODE_FOR_mqlmths, "__MQLMTHS", FRV_BUILTIN_MQLMTHS, 0, 0 }, - { CODE_FOR_smul, "__SMUL", FRV_BUILTIN_SMUL, 0, 0 }, - { CODE_FOR_umul, "__UMUL", FRV_BUILTIN_UMUL, 0, 0 }, - { CODE_FOR_addss, "__ADDSS", FRV_BUILTIN_ADDSS, 0, 0 }, - { CODE_FOR_subss, "__SUBSS", FRV_BUILTIN_SUBSS, 0, 0 }, - { CODE_FOR_slass, "__SLASS", FRV_BUILTIN_SLASS, 0, 0 }, - { CODE_FOR_scan, "__SCAN", FRV_BUILTIN_SCAN, 0, 0 } + { CODE_FOR_mand, "__MAND", FRV_BUILTIN_MAND, UNKNOWN, 0}, + { CODE_FOR_mor, "__MOR", FRV_BUILTIN_MOR, UNKNOWN, 0}, + { CODE_FOR_mxor, "__MXOR", FRV_BUILTIN_MXOR, UNKNOWN, 0}, + { CODE_FOR_maveh, "__MAVEH", FRV_BUILTIN_MAVEH, UNKNOWN, 0}, + { CODE_FOR_msaths, "__MSATHS", FRV_BUILTIN_MSATHS, UNKNOWN, 0}, + { CODE_FOR_msathu, "__MSATHU", FRV_BUILTIN_MSATHU, UNKNOWN, 0}, + { CODE_FOR_maddhss, "__MADDHSS", FRV_BUILTIN_MADDHSS, UNKNOWN, 0}, + { CODE_FOR_maddhus, "__MADDHUS", FRV_BUILTIN_MADDHUS, UNKNOWN, 0}, + { CODE_FOR_msubhss, "__MSUBHSS", FRV_BUILTIN_MSUBHSS, UNKNOWN, 0}, + { CODE_FOR_msubhus, "__MSUBHUS", FRV_BUILTIN_MSUBHUS, UNKNOWN, 0}, + { CODE_FOR_mqaddhss, "__MQADDHSS", FRV_BUILTIN_MQADDHSS, UNKNOWN, 0}, + { CODE_FOR_mqaddhus, "__MQADDHUS", FRV_BUILTIN_MQADDHUS, UNKNOWN, 0}, + { CODE_FOR_mqsubhss, "__MQSUBHSS", FRV_BUILTIN_MQSUBHSS, UNKNOWN, 0}, + { CODE_FOR_mqsubhus, "__MQSUBHUS", FRV_BUILTIN_MQSUBHUS, UNKNOWN, 0}, + { CODE_FOR_mpackh, "__MPACKH", FRV_BUILTIN_MPACKH, UNKNOWN, 0}, + { CODE_FOR_mcop1, "__Mcop1", FRV_BUILTIN_MCOP1, UNKNOWN, 0}, + { CODE_FOR_mcop2, "__Mcop2", FRV_BUILTIN_MCOP2, UNKNOWN, 0}, + { CODE_FOR_mwcut, "__MWCUT", FRV_BUILTIN_MWCUT, UNKNOWN, 0}, + { CODE_FOR_mqsaths, "__MQSATHS", FRV_BUILTIN_MQSATHS, UNKNOWN, 0}, + { CODE_FOR_mqlclrhs, "__MQLCLRHS", FRV_BUILTIN_MQLCLRHS, UNKNOWN, 0}, + { CODE_FOR_mqlmths, "__MQLMTHS", FRV_BUILTIN_MQLMTHS, UNKNOWN, 0}, + { CODE_FOR_smul, "__SMUL", FRV_BUILTIN_SMUL, UNKNOWN, 0}, + { CODE_FOR_umul, "__UMUL", FRV_BUILTIN_UMUL, UNKNOWN, 0}, + { CODE_FOR_addss, "__ADDSS", FRV_BUILTIN_ADDSS, UNKNOWN, 0}, + { CODE_FOR_subss, "__SUBSS", FRV_BUILTIN_SUBSS, UNKNOWN, 0}, + { CODE_FOR_slass, "__SLASS", FRV_BUILTIN_SLASS, UNKNOWN, 0}, + { CODE_FOR_scan, "__SCAN", FRV_BUILTIN_SCAN, UNKNOWN, 0} }; /* Integer intrinsics that take two arguments and have no return value. */ static struct builtin_description bdesc_int_void2arg[] = { - { CODE_FOR_smass, "__SMASS", FRV_BUILTIN_SMASS, 0, 0 }, - { CODE_FOR_smsss, "__SMSSS", FRV_BUILTIN_SMSSS, 0, 0 }, - { CODE_FOR_smu, "__SMU", FRV_BUILTIN_SMU, 0, 0 } + { CODE_FOR_smass, "__SMASS", FRV_BUILTIN_SMASS, UNKNOWN, 0}, + { CODE_FOR_smsss, "__SMSSS", FRV_BUILTIN_SMSSS, UNKNOWN, 0}, + { CODE_FOR_smu, "__SMU", FRV_BUILTIN_SMU, UNKNOWN, 0} }; static struct builtin_description bdesc_prefetches[] = { - { CODE_FOR_frv_prefetch0, "__data_prefetch0", FRV_BUILTIN_PREFETCH0, 0, 0 }, - { CODE_FOR_frv_prefetch, "__data_prefetch", FRV_BUILTIN_PREFETCH, 0, 0 } + { CODE_FOR_frv_prefetch0, "__data_prefetch0", FRV_BUILTIN_PREFETCH0, UNKNOWN, + 0}, + { CODE_FOR_frv_prefetch, "__data_prefetch", FRV_BUILTIN_PREFETCH, UNKNOWN, 0} }; /* Media intrinsics that take two arguments, the first being an ACC number. */ static struct builtin_description bdesc_cut[] = { - { CODE_FOR_mcut, "__MCUT", FRV_BUILTIN_MCUT, 0, 0 }, - { CODE_FOR_mcutss, "__MCUTSS", FRV_BUILTIN_MCUTSS, 0, 0 }, - { CODE_FOR_mdcutssi, "__MDCUTSSI", FRV_BUILTIN_MDCUTSSI, 0, 0 } + { CODE_FOR_mcut, "__MCUT", FRV_BUILTIN_MCUT, UNKNOWN, 0}, + { CODE_FOR_mcutss, "__MCUTSS", FRV_BUILTIN_MCUTSS, UNKNOWN, 0}, + { CODE_FOR_mdcutssi, "__MDCUTSSI", FRV_BUILTIN_MDCUTSSI, UNKNOWN, 0} }; /* Two-argument media intrinsics with an immediate second argument. */ static struct builtin_description bdesc_2argimm[] = { - { CODE_FOR_mrotli, "__MROTLI", FRV_BUILTIN_MROTLI, 0, 0 }, - { CODE_FOR_mrotri, "__MROTRI", FRV_BUILTIN_MROTRI, 0, 0 }, - { CODE_FOR_msllhi, "__MSLLHI", FRV_BUILTIN_MSLLHI, 0, 0 }, - { CODE_FOR_msrlhi, "__MSRLHI", FRV_BUILTIN_MSRLHI, 0, 0 }, - { CODE_FOR_msrahi, "__MSRAHI", FRV_BUILTIN_MSRAHI, 0, 0 }, - { CODE_FOR_mexpdhw, "__MEXPDHW", FRV_BUILTIN_MEXPDHW, 0, 0 }, - { CODE_FOR_mexpdhd, "__MEXPDHD", FRV_BUILTIN_MEXPDHD, 0, 0 }, - { CODE_FOR_mdrotli, "__MDROTLI", FRV_BUILTIN_MDROTLI, 0, 0 }, - { CODE_FOR_mcplhi, "__MCPLHI", FRV_BUILTIN_MCPLHI, 0, 0 }, - { CODE_FOR_mcpli, "__MCPLI", FRV_BUILTIN_MCPLI, 0, 0 }, - { CODE_FOR_mhsetlos, "__MHSETLOS", FRV_BUILTIN_MHSETLOS, 0, 0 }, - { CODE_FOR_mhsetloh, "__MHSETLOH", FRV_BUILTIN_MHSETLOH, 0, 0 }, - { CODE_FOR_mhsethis, "__MHSETHIS", FRV_BUILTIN_MHSETHIS, 0, 0 }, - { CODE_FOR_mhsethih, "__MHSETHIH", FRV_BUILTIN_MHSETHIH, 0, 0 }, - { CODE_FOR_mhdseth, "__MHDSETH", FRV_BUILTIN_MHDSETH, 0, 0 }, - { CODE_FOR_mqsllhi, "__MQSLLHI", FRV_BUILTIN_MQSLLHI, 0, 0 }, - { CODE_FOR_mqsrahi, "__MQSRAHI", FRV_BUILTIN_MQSRAHI, 0, 0 } + { CODE_FOR_mrotli, "__MROTLI", FRV_BUILTIN_MROTLI, UNKNOWN, 0}, + { CODE_FOR_mrotri, "__MROTRI", FRV_BUILTIN_MROTRI, UNKNOWN, 0}, + { CODE_FOR_msllhi, "__MSLLHI", FRV_BUILTIN_MSLLHI, UNKNOWN, 0}, + { CODE_FOR_msrlhi, "__MSRLHI", FRV_BUILTIN_MSRLHI, UNKNOWN, 0}, + { CODE_FOR_msrahi, "__MSRAHI", FRV_BUILTIN_MSRAHI, UNKNOWN, 0}, + { CODE_FOR_mexpdhw, "__MEXPDHW", FRV_BUILTIN_MEXPDHW, UNKNOWN, 0}, + { CODE_FOR_mexpdhd, "__MEXPDHD", FRV_BUILTIN_MEXPDHD, UNKNOWN, 0}, + { CODE_FOR_mdrotli, "__MDROTLI", FRV_BUILTIN_MDROTLI, UNKNOWN, 0}, + { CODE_FOR_mcplhi, "__MCPLHI", FRV_BUILTIN_MCPLHI, UNKNOWN, 0}, + { CODE_FOR_mcpli, "__MCPLI", FRV_BUILTIN_MCPLI, UNKNOWN, 0}, + { CODE_FOR_mhsetlos, "__MHSETLOS", FRV_BUILTIN_MHSETLOS, UNKNOWN, 0}, + { CODE_FOR_mhsetloh, "__MHSETLOH", FRV_BUILTIN_MHSETLOH, UNKNOWN, 0}, + { CODE_FOR_mhsethis, "__MHSETHIS", FRV_BUILTIN_MHSETHIS, UNKNOWN, 0}, + { CODE_FOR_mhsethih, "__MHSETHIH", FRV_BUILTIN_MHSETHIH, UNKNOWN, 0}, + { CODE_FOR_mhdseth, "__MHDSETH", FRV_BUILTIN_MHDSETH, UNKNOWN, 0}, + { CODE_FOR_mqsllhi, "__MQSLLHI", FRV_BUILTIN_MQSLLHI, UNKNOWN, 0}, + { CODE_FOR_mqsrahi, "__MQSRAHI", FRV_BUILTIN_MQSRAHI, UNKNOWN, 0} }; /* Media intrinsics that take two arguments and return void, the first argument @@ -8381,8 +8387,8 @@ static struct builtin_description bdesc_2argimm[] = static struct builtin_description bdesc_void2arg[] = { - { CODE_FOR_mdunpackh, "__MDUNPACKH", FRV_BUILTIN_MDUNPACKH, 0, 0 }, - { CODE_FOR_mbtohe, "__MBTOHE", FRV_BUILTIN_MBTOHE, 0, 0 }, + { CODE_FOR_mdunpackh, "__MDUNPACKH", FRV_BUILTIN_MDUNPACKH, UNKNOWN, 0}, + { CODE_FOR_mbtohe, "__MBTOHE", FRV_BUILTIN_MBTOHE, UNKNOWN, 0}, }; /* Media intrinsics that take three arguments, the first being a const_int that @@ -8390,31 +8396,31 @@ static struct builtin_description bdesc_void2arg[] = static struct builtin_description bdesc_void3arg[] = { - { CODE_FOR_mcpxrs, "__MCPXRS", FRV_BUILTIN_MCPXRS, 0, 0 }, - { CODE_FOR_mcpxru, "__MCPXRU", FRV_BUILTIN_MCPXRU, 0, 0 }, - { CODE_FOR_mcpxis, "__MCPXIS", FRV_BUILTIN_MCPXIS, 0, 0 }, - { CODE_FOR_mcpxiu, "__MCPXIU", FRV_BUILTIN_MCPXIU, 0, 0 }, - { CODE_FOR_mmulhs, "__MMULHS", FRV_BUILTIN_MMULHS, 0, 0 }, - { CODE_FOR_mmulhu, "__MMULHU", FRV_BUILTIN_MMULHU, 0, 0 }, - { CODE_FOR_mmulxhs, "__MMULXHS", FRV_BUILTIN_MMULXHS, 0, 0 }, - { CODE_FOR_mmulxhu, "__MMULXHU", FRV_BUILTIN_MMULXHU, 0, 0 }, - { CODE_FOR_mmachs, "__MMACHS", FRV_BUILTIN_MMACHS, 0, 0 }, - { CODE_FOR_mmachu, "__MMACHU", FRV_BUILTIN_MMACHU, 0, 0 }, - { CODE_FOR_mmrdhs, "__MMRDHS", FRV_BUILTIN_MMRDHS, 0, 0 }, - { CODE_FOR_mmrdhu, "__MMRDHU", FRV_BUILTIN_MMRDHU, 0, 0 }, - { CODE_FOR_mqcpxrs, "__MQCPXRS", FRV_BUILTIN_MQCPXRS, 0, 0 }, - { CODE_FOR_mqcpxru, "__MQCPXRU", FRV_BUILTIN_MQCPXRU, 0, 0 }, - { CODE_FOR_mqcpxis, "__MQCPXIS", FRV_BUILTIN_MQCPXIS, 0, 0 }, - { CODE_FOR_mqcpxiu, "__MQCPXIU", FRV_BUILTIN_MQCPXIU, 0, 0 }, - { CODE_FOR_mqmulhs, "__MQMULHS", FRV_BUILTIN_MQMULHS, 0, 0 }, - { CODE_FOR_mqmulhu, "__MQMULHU", FRV_BUILTIN_MQMULHU, 0, 0 }, - { CODE_FOR_mqmulxhs, "__MQMULXHS", FRV_BUILTIN_MQMULXHS, 0, 0 }, - { CODE_FOR_mqmulxhu, "__MQMULXHU", FRV_BUILTIN_MQMULXHU, 0, 0 }, - { CODE_FOR_mqmachs, "__MQMACHS", FRV_BUILTIN_MQMACHS, 0, 0 }, - { CODE_FOR_mqmachu, "__MQMACHU", FRV_BUILTIN_MQMACHU, 0, 0 }, - { CODE_FOR_mqxmachs, "__MQXMACHS", FRV_BUILTIN_MQXMACHS, 0, 0 }, - { CODE_FOR_mqxmacxhs, "__MQXMACXHS", FRV_BUILTIN_MQXMACXHS, 0, 0 }, - { CODE_FOR_mqmacxhs, "__MQMACXHS", FRV_BUILTIN_MQMACXHS, 0, 0 } + { CODE_FOR_mcpxrs, "__MCPXRS", FRV_BUILTIN_MCPXRS, UNKNOWN, 0}, + { CODE_FOR_mcpxru, "__MCPXRU", FRV_BUILTIN_MCPXRU, UNKNOWN, 0}, + { CODE_FOR_mcpxis, "__MCPXIS", FRV_BUILTIN_MCPXIS, UNKNOWN, 0}, + { CODE_FOR_mcpxiu, "__MCPXIU", FRV_BUILTIN_MCPXIU, UNKNOWN, 0}, + { CODE_FOR_mmulhs, "__MMULHS", FRV_BUILTIN_MMULHS, UNKNOWN, 0}, + { CODE_FOR_mmulhu, "__MMULHU", FRV_BUILTIN_MMULHU, UNKNOWN, 0}, + { CODE_FOR_mmulxhs, "__MMULXHS", FRV_BUILTIN_MMULXHS, UNKNOWN, 0}, + { CODE_FOR_mmulxhu, "__MMULXHU", FRV_BUILTIN_MMULXHU, UNKNOWN, 0}, + { CODE_FOR_mmachs, "__MMACHS", FRV_BUILTIN_MMACHS, UNKNOWN, 0}, + { CODE_FOR_mmachu, "__MMACHU", FRV_BUILTIN_MMACHU, UNKNOWN, 0}, + { CODE_FOR_mmrdhs, "__MMRDHS", FRV_BUILTIN_MMRDHS, UNKNOWN, 0}, + { CODE_FOR_mmrdhu, "__MMRDHU", FRV_BUILTIN_MMRDHU, UNKNOWN, 0}, + { CODE_FOR_mqcpxrs, "__MQCPXRS", FRV_BUILTIN_MQCPXRS, UNKNOWN, 0}, + { CODE_FOR_mqcpxru, "__MQCPXRU", FRV_BUILTIN_MQCPXRU, UNKNOWN, 0}, + { CODE_FOR_mqcpxis, "__MQCPXIS", FRV_BUILTIN_MQCPXIS, UNKNOWN, 0}, + { CODE_FOR_mqcpxiu, "__MQCPXIU", FRV_BUILTIN_MQCPXIU, UNKNOWN, 0}, + { CODE_FOR_mqmulhs, "__MQMULHS", FRV_BUILTIN_MQMULHS, UNKNOWN, 0}, + { CODE_FOR_mqmulhu, "__MQMULHU", FRV_BUILTIN_MQMULHU, UNKNOWN, 0}, + { CODE_FOR_mqmulxhs, "__MQMULXHS", FRV_BUILTIN_MQMULXHS, UNKNOWN, 0}, + { CODE_FOR_mqmulxhu, "__MQMULXHU", FRV_BUILTIN_MQMULXHU, UNKNOWN, 0}, + { CODE_FOR_mqmachs, "__MQMACHS", FRV_BUILTIN_MQMACHS, UNKNOWN, 0}, + { CODE_FOR_mqmachu, "__MQMACHU", FRV_BUILTIN_MQMACHU, UNKNOWN, 0}, + { CODE_FOR_mqxmachs, "__MQXMACHS", FRV_BUILTIN_MQXMACHS, UNKNOWN, 0}, + { CODE_FOR_mqxmacxhs, "__MQXMACXHS", FRV_BUILTIN_MQXMACXHS, UNKNOWN, 0}, + { CODE_FOR_mqmacxhs, "__MQMACXHS", FRV_BUILTIN_MQMACXHS, UNKNOWN, 0} }; /* Media intrinsics that take two accumulator numbers as argument and @@ -8422,12 +8428,12 @@ static struct builtin_description bdesc_void3arg[] = static struct builtin_description bdesc_voidacc[] = { - { CODE_FOR_maddaccs, "__MADDACCS", FRV_BUILTIN_MADDACCS, 0, 0 }, - { CODE_FOR_msubaccs, "__MSUBACCS", FRV_BUILTIN_MSUBACCS, 0, 0 }, - { CODE_FOR_masaccs, "__MASACCS", FRV_BUILTIN_MASACCS, 0, 0 }, - { CODE_FOR_mdaddaccs, "__MDADDACCS", FRV_BUILTIN_MDADDACCS, 0, 0 }, - { CODE_FOR_mdsubaccs, "__MDSUBACCS", FRV_BUILTIN_MDSUBACCS, 0, 0 }, - { CODE_FOR_mdasaccs, "__MDASACCS", FRV_BUILTIN_MDASACCS, 0, 0 } + { CODE_FOR_maddaccs, "__MADDACCS", FRV_BUILTIN_MADDACCS, UNKNOWN, 0}, + { CODE_FOR_msubaccs, "__MSUBACCS", FRV_BUILTIN_MSUBACCS, UNKNOWN, 0}, + { CODE_FOR_masaccs, "__MASACCS", FRV_BUILTIN_MASACCS, UNKNOWN, 0}, + { CODE_FOR_mdaddaccs, "__MDADDACCS", FRV_BUILTIN_MDADDACCS, UNKNOWN, 0}, + { CODE_FOR_mdsubaccs, "__MDSUBACCS", FRV_BUILTIN_MDSUBACCS, UNKNOWN, 0}, + { CODE_FOR_mdasaccs, "__MDASACCS", FRV_BUILTIN_MDASACCS, UNKNOWN, 0} }; /* Intrinsics that load a value and then issue a MEMBAR. The load is @@ -8436,13 +8442,13 @@ static struct builtin_description bdesc_voidacc[] = static struct builtin_description bdesc_loads[] = { { CODE_FOR_optional_membar_qi, "__builtin_read8", - FRV_BUILTIN_READ8, 0, 0 }, + FRV_BUILTIN_READ8, UNKNOWN, 0}, { CODE_FOR_optional_membar_hi, "__builtin_read16", - FRV_BUILTIN_READ16, 0, 0 }, + FRV_BUILTIN_READ16, UNKNOWN, 0}, { CODE_FOR_optional_membar_si, "__builtin_read32", - FRV_BUILTIN_READ32, 0, 0 }, + FRV_BUILTIN_READ32, UNKNOWN, 0}, { CODE_FOR_optional_membar_di, "__builtin_read64", - FRV_BUILTIN_READ64, 0, 0 } + FRV_BUILTIN_READ64, UNKNOWN, 0} }; /* Likewise stores. */ @@ -8450,13 +8456,13 @@ static struct builtin_description bdesc_loads[] = static struct builtin_description bdesc_stores[] = { { CODE_FOR_optional_membar_qi, "__builtin_write8", - FRV_BUILTIN_WRITE8, 0, 0 }, + FRV_BUILTIN_WRITE8, UNKNOWN, 0}, { CODE_FOR_optional_membar_hi, "__builtin_write16", - FRV_BUILTIN_WRITE16, 0, 0 }, + FRV_BUILTIN_WRITE16, UNKNOWN, 0}, { CODE_FOR_optional_membar_si, "__builtin_write32", - FRV_BUILTIN_WRITE32, 0, 0 }, + FRV_BUILTIN_WRITE32, UNKNOWN, 0}, { CODE_FOR_optional_membar_di, "__builtin_write64", - FRV_BUILTIN_WRITE64, 0, 0 }, + FRV_BUILTIN_WRITE64, UNKNOWN, 0}, }; /* Initialize media builtins. */ @@ -8811,8 +8817,7 @@ frv_matching_accg_for_acc (rtx acc) static rtx frv_read_argument (tree exp, unsigned int index) { - return expand_expr (CALL_EXPR_ARG (exp, index), - NULL_RTX, VOIDmode, 0); + return expand_normal (CALL_EXPR_ARG (exp, index)); } /* Like frv_read_argument, but interpret the argument as the number diff --git a/gcc/config/frv/frv.md b/gcc/config/frv/frv.md index 9315f9b623c..2440d12fccf 100644 --- a/gcc/config/frv/frv.md +++ b/gcc/config/frv/frv.md @@ -345,7 +345,7 @@ ;; enumeration in frv-protos.h. (define_attr "cpu" "generic,fr550,fr500,fr450,fr405,fr400,fr300,simple,tomcat" - (const (symbol_ref "frv_cpu_type"))) + (const (symbol_ref "(enum attr_cpu) frv_cpu_type"))) ;; Attribute is "yes" for branches and jumps that span too great a distance ;; to be implemented in the most natural way. Such instructions will use @@ -360,7 +360,7 @@ (const_string "unknown")) (define_attr "acc_group" "none,even,odd" - (symbol_ref "frv_acc_group (insn)")) + (symbol_ref "(enum attr_acc_group) frv_acc_group (insn)")) ;; Scheduling and Packing Overview ;; ------------------------------- @@ -1895,10 +1895,8 @@ } else { - operands[4] = GEN_INT ((((unsigned HOST_WIDE_INT)INTVAL (op1) >> 16) - >> 16) ^ ((unsigned HOST_WIDE_INT)1 << 31) - - ((unsigned HOST_WIDE_INT)1 << 31)); - operands[5] = GEN_INT (trunc_int_for_mode (INTVAL (op1), SImode)); + operands[4] = gen_int_mode ((INTVAL (op1) >> 16) >> 16, SImode); + operands[5] = gen_int_mode (INTVAL (op1), SImode); } }") diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h index 09ea866c0d7..4ee2a04349e 100644 --- a/gcc/config/i386/cygming.h +++ b/gcc/config/i386/cygming.h @@ -84,6 +84,10 @@ along with GCC; see the file COPYING3. If not see (TARGET_64BIT ? dbx64_register_map[(n)] \ : svr4_dbx_register_map[(n)]) +/* The MS_ABI changes the set of call-used registers. */ +#undef DWARF_FRAME_REGISTERS +#define DWARF_FRAME_REGISTERS (TARGET_64BIT ? 33 : 17) + #ifdef HAVE_GAS_PE_SECREL32_RELOC /* Use section relative relocations for debugging offsets. Unlike other targets that fake this by putting the section VMA at 0, PE diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 00febba7c64..29e4620e4ee 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -7147,7 +7147,7 @@ ix86_function_arg_boundary (enum machine_mode mode, const_tree type) { warned = true; inform (input_location, - "The ABI of passing parameter with %dbyte" + "The ABI for passing parameters with %d-byte" " alignment has changed in GCC 4.6", align / BITS_PER_UNIT); } @@ -11050,6 +11050,11 @@ split_stack_prologue_scratch_regno (void) static GTY(()) rtx split_stack_fn; +/* A SYMBOL_REF for the more stack function when using the large + model. */ + +static GTY(()) rtx split_stack_fn_large; + /* Handle -fsplit-stack. These are the first instructions in the function, even before the regular prologue. */ @@ -11062,6 +11067,7 @@ ix86_expand_split_stack_prologue (void) rtx label, limit, current, jump_insn, allocate_rtx, call_insn, call_fusage; rtx scratch_reg = NULL_RTX; rtx varargs_label = NULL_RTX; + rtx fn; gcc_assert (flag_split_stack && reload_completed); @@ -11125,6 +11131,10 @@ ix86_expand_split_stack_prologue (void) add_reg_note (jump_insn, REG_BR_PROB, GEN_INT (REG_BR_PROB_BASE - REG_BR_PROB_BASE / 100)); + if (split_stack_fn == NULL_RTX) + split_stack_fn = gen_rtx_SYMBOL_REF (Pmode, "__morestack"); + fn = split_stack_fn; + /* Get more stack space. We pass in the desired stack space and the size of the arguments to copy to the new stack. In 32-bit mode we push the parameters; __morestack will return on a new stack @@ -11135,9 +11145,10 @@ ix86_expand_split_stack_prologue (void) call_fusage = NULL_RTX; if (TARGET_64BIT) { - rtx reg; + rtx reg10, reg11; - reg = gen_rtx_REG (Pmode, R10_REG); + reg10 = gen_rtx_REG (Pmode, R10_REG); + reg11 = gen_rtx_REG (Pmode, R11_REG); /* If this function uses a static chain, it will be in %r10. Preserve it across the call to __morestack. */ @@ -11146,24 +11157,69 @@ ix86_expand_split_stack_prologue (void) rtx rax; rax = gen_rtx_REG (Pmode, AX_REG); - emit_move_insn (rax, reg); + emit_move_insn (rax, reg10); use_reg (&call_fusage, rax); } - emit_move_insn (reg, allocate_rtx); - use_reg (&call_fusage, reg); - reg = gen_rtx_REG (Pmode, R11_REG); - emit_move_insn (reg, GEN_INT (args_size)); - use_reg (&call_fusage, reg); + if (ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC) + { + HOST_WIDE_INT argval; + + /* When using the large model we need to load the address + into a register, and we've run out of registers. So we + switch to a different calling convention, and we call a + different function: __morestack_large. We pass the + argument size in the upper 32 bits of r10 and pass the + frame size in the lower 32 bits. */ + gcc_assert ((allocate & (HOST_WIDE_INT) 0xffffffff) == allocate); + gcc_assert (((unsigned HOST_WIDE_INT) args_size & 0xffffffff) + == (unsigned HOST_WIDE_INT) args_size); + + if (split_stack_fn_large == NULL_RTX) + split_stack_fn_large = + gen_rtx_SYMBOL_REF (Pmode, "__morestack_large_model"); + + if (ix86_cmodel == CM_LARGE_PIC) + { + rtx label, x; + + label = gen_label_rtx (); + emit_label (label); + LABEL_PRESERVE_P (label) = 1; + emit_insn (gen_set_rip_rex64 (reg10, label)); + emit_insn (gen_set_got_offset_rex64 (reg11, label)); + emit_insn (gen_adddi3 (reg10, reg10, reg11)); + x = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, split_stack_fn_large), + UNSPEC_GOT); + x = gen_rtx_CONST (Pmode, x); + emit_move_insn (reg11, x); + x = gen_rtx_PLUS (Pmode, reg10, reg11); + x = gen_const_mem (Pmode, x); + emit_move_insn (reg11, x); + } + else + emit_move_insn (reg11, split_stack_fn_large); + + fn = reg11; + + argval = (((HOST_WIDE_INT) args_size << 16) << 16) + allocate; + emit_move_insn (reg10, GEN_INT (argval)); + } + else + { + emit_move_insn (reg10, allocate_rtx); + emit_move_insn (reg11, GEN_INT (args_size)); + use_reg (&call_fusage, reg11); + } + + use_reg (&call_fusage, reg10); } else { emit_insn (gen_push (GEN_INT (args_size))); emit_insn (gen_push (allocate_rtx)); } - if (split_stack_fn == NULL_RTX) - split_stack_fn = gen_rtx_SYMBOL_REF (Pmode, "__morestack"); - call_insn = ix86_expand_call (NULL_RTX, gen_rtx_MEM (QImode, split_stack_fn), + call_insn = ix86_expand_call (NULL_RTX, gen_rtx_MEM (QImode, fn), GEN_INT (UNITS_PER_WORD), constm1_rtx, NULL_RTX, 0); add_function_usage_to (call_insn, call_fusage); @@ -11718,6 +11774,7 @@ legitimate_pic_address_disp_p (rtx disp) if (GET_CODE (disp) != UNSPEC || (XINT (disp, 1) != UNSPEC_GOTPCREL && XINT (disp, 1) != UNSPEC_GOTOFF + && XINT (disp, 1) != UNSPEC_PCREL && XINT (disp, 1) != UNSPEC_PLTOFF)) return false; @@ -11900,6 +11957,7 @@ ix86_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, return false; case UNSPEC_GOTPCREL: + case UNSPEC_PCREL: gcc_assert (flag_pic); goto is_legitimate_pic; @@ -12127,7 +12185,19 @@ legitimize_pic_address (rtx orig, rtx reg) } } - if (TARGET_64BIT && ix86_cmodel != CM_LARGE_PIC) + /* For x64 PE-COFF there is no GOT table. So we use address + directly. */ + if (TARGET_64BIT && DEFAULT_ABI == MS_ABI) + { + new_rtx = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_PCREL); + new_rtx = gen_rtx_CONST (Pmode, new_rtx); + + if (reg == 0) + reg = gen_reg_rtx (Pmode); + emit_move_insn (reg, new_rtx); + new_rtx = reg; + } + else if (TARGET_64BIT && ix86_cmodel != CM_LARGE_PIC) { new_rtx = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_GOTPCREL); new_rtx = gen_rtx_CONST (Pmode, new_rtx); @@ -12836,6 +12906,10 @@ output_pic_addr_const (FILE *file, rtx x, int code) case UNSPEC_PLTOFF: fputs ("@PLTOFF", file); break; + case UNSPEC_PCREL: + fputs (ASSEMBLER_DIALECT == ASM_ATT ? + "(%rip)" : "[rip]", file); + break; case UNSPEC_GOTPCREL: fputs (ASSEMBLER_DIALECT == ASM_ATT ? "@GOTPCREL(%rip)" : "@GOTPCREL[rip]", file); @@ -12994,7 +13068,8 @@ ix86_delegitimize_address (rtx x) { if (GET_CODE (x) != CONST || GET_CODE (XEXP (x, 0)) != UNSPEC - || XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL + || (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL + && XINT (XEXP (x, 0), 1) != UNSPEC_PCREL) || !MEM_P (orig_x)) return ix86_delegitimize_tls_address (orig_x); x = XVECEXP (XEXP (x, 0), 0, 0); @@ -13091,7 +13166,8 @@ ix86_find_base_term (rtx x) || GET_CODE (XEXP (term, 1)) == CONST_DOUBLE)) term = XEXP (term, 0); if (GET_CODE (term) != UNSPEC - || XINT (term, 1) != UNSPEC_GOTPCREL) + || (XINT (term, 1) != UNSPEC_GOTPCREL + && XINT (term, 1) != UNSPEC_PCREL)) return x; return XVECEXP (term, 0, 0); @@ -21803,6 +21879,7 @@ memory_address_length (rtx addr) || SYMBOL_REF_TLS_MODEL (symbol) != 0) && (GET_CODE (symbol) != UNSPEC || (XINT (symbol, 1) != UNSPEC_GOTPCREL + && XINT (symbol, 1) != UNSPEC_PCREL && XINT (symbol, 1) != UNSPEC_GOTNTPOFF))) len += 1; } @@ -29112,7 +29189,8 @@ x86_output_mi_thunk (FILE *file, xops[0] = XEXP (DECL_RTL (function), 0); if (TARGET_64BIT) { - if (!flag_pic || targetm.binds_local_p (function)) + if (!flag_pic || targetm.binds_local_p (function) + || DEFAULT_ABI == MS_ABI) output_asm_insn ("jmp\t%P0", xops); /* All thunks should be in the same object as their target, and thus binds_local_p should be true. */ diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 79f4b68d53c..eff96a106d4 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -76,6 +76,7 @@ UNSPEC_INDNTPOFF UNSPEC_PLTOFF UNSPEC_MACHOPIC_OFFSET + UNSPEC_PCREL ;; Prologue support UNSPEC_STACK_ALLOC diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index 45a736ad60e..251bb5ae5bc 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -326,10 +326,7 @@ i386_pe_binds_local_p (const_tree exp) /* Or a weak one, now that they are supported. */ if ((TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL) && DECL_WEAK (exp)) - /* But x64 gets confused and attempts to use unsupported GOTPCREL - relocations if we tell it the truth, so we still return true in - that case until the deeper problem can be fixed. */ - return (TARGET_64BIT && DEFAULT_ABI == MS_ABI); + return false; return true; } diff --git a/gcc/config/lm32/lm32.c b/gcc/config/lm32/lm32.c index 18a4b4403cd..ef09377626d 100644 --- a/gcc/config/lm32/lm32.c +++ b/gcc/config/lm32/lm32.c @@ -191,18 +191,22 @@ gen_int_relational (enum rtx_code code, case LT: case LEU: case LTU: - code = swap_condition (code); - rtx temp = cmp0; - cmp0 = cmp1; - cmp1 = temp; - break; + { + rtx temp; + + code = swap_condition (code); + temp = cmp0; + cmp0 = cmp1; + cmp1 = temp; + break; + } default: break; } if (branch_p) { - rtx insn; + rtx insn, cond, label; /* Operands must be in registers. */ if (!register_operand (cmp0, mode)) @@ -211,8 +215,8 @@ gen_int_relational (enum rtx_code code, cmp1 = force_reg (mode, cmp1); /* Generate conditional branch instruction. */ - rtx cond = gen_rtx_fmt_ee (code, mode, cmp0, cmp1); - rtx label = gen_rtx_LABEL_REF (VOIDmode, destination); + cond = gen_rtx_fmt_ee (code, mode, cmp0, cmp1); + label = gen_rtx_LABEL_REF (VOIDmode, destination); insn = gen_rtx_SET (VOIDmode, pc_rtx, gen_rtx_IF_THEN_ELSE (VOIDmode, cond, label, pc_rtx)); @@ -841,7 +845,7 @@ lm32_block_move_inline (rtx dest, rtx src, HOST_WIDE_INT length, delta = bits / BITS_PER_UNIT; /* Allocate a buffer for the temporary registers. */ - regs = alloca (sizeof (rtx) * length / delta); + regs = XALLOCAVEC (rtx, length / delta); /* Load as many BITS-sized chunks as possible. */ for (offset = 0, i = 0; offset + delta <= length; offset += delta, i++) diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h index c87c3bb705a..1c10f16c812 100644 --- a/gcc/config/lm32/lm32.h +++ b/gcc/config/lm32/lm32.h @@ -350,7 +350,7 @@ enum reg_class #define REG_OK_FOR_BASE_P(X) NONSTRICT_REG_OK_FOR_BASE_P(X) #endif -#define LEGITIMATE_CONSTANT_P(X) lm32_legitimate_constant_p +#define LEGITIMATE_CONSTANT_P(X) lm32_legitimate_constant_p (X) /*-------------------------*/ /* Condition Code Status. */ diff --git a/gcc/config/lm32/lm32.md b/gcc/config/lm32/lm32.md index 6d4305380c0..72c0d843c0b 100644 --- a/gcc/config/lm32/lm32.md +++ b/gcc/config/lm32/lm32.md @@ -824,7 +824,6 @@ { int i; int shifts = INTVAL (operands[2]); - rtx one = GEN_INT (1); if (shifts == 0) emit_move_insn (operands[0], operands[1]); diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c index f032a47f6df..0132cbf6892 100644 --- a/gcc/config/m68k/m68k.c +++ b/gcc/config/m68k/m68k.c @@ -4659,49 +4659,46 @@ m68k_output_dwarf_dtprel (FILE *file, int size, rtx x) static rtx m68k_delegitimize_address (rtx orig_x) { - rtx x, y; - rtx addend = NULL_RTX; - rtx result; + rtx x; + struct m68k_address addr; + rtx unspec; orig_x = delegitimize_mem_from_attrs (orig_x); - if (! MEM_P (orig_x)) - return orig_x; - - x = XEXP (orig_x, 0); - - if (GET_CODE (x) == PLUS - && GET_CODE (XEXP (x, 1)) == CONST - && REG_P (XEXP (x, 0)) - && REGNO (XEXP (x, 0)) == PIC_REG) - { - y = x = XEXP (XEXP (x, 1), 0); + x = orig_x; + if (MEM_P (x)) + x = XEXP (x, 0); - /* Handle an addend. */ - if ((GET_CODE (x) == PLUS || GET_CODE (x) == MINUS) - && CONST_INT_P (XEXP (x, 1))) - { - addend = XEXP (x, 1); - x = XEXP (x, 0); - } + if (GET_CODE (x) != PLUS || GET_MODE (x) != Pmode) + return orig_x; - if (GET_CODE (x) == UNSPEC - && (XINT (x, 1) == UNSPEC_RELOC16 - || XINT (x, 1) == UNSPEC_RELOC32)) - { - result = XVECEXP (x, 0, 0); - if (addend) - { - if (GET_CODE (y) == PLUS) - result = gen_rtx_PLUS (Pmode, result, addend); - else - result = gen_rtx_MINUS (Pmode, result, addend); - result = gen_rtx_CONST (Pmode, result); - } - return result; - } - } + if (!m68k_decompose_address (GET_MODE (x), x, false, &addr) + || addr.offset == NULL_RTX + || GET_CODE (addr.offset) != CONST) + return orig_x; - return orig_x; + unspec = XEXP (addr.offset, 0); + if (GET_CODE (unspec) == PLUS && CONST_INT_P (XEXP (unspec, 1))) + unspec = XEXP (unspec, 0); + if (GET_CODE (unspec) != UNSPEC + || (XINT (unspec, 1) != UNSPEC_RELOC16 + && XINT (unspec, 1) != UNSPEC_RELOC32)) + return orig_x; + x = XVECEXP (unspec, 0, 0); + gcc_assert (GET_CODE (x) == SYMBOL_REF); + if (unspec != XEXP (addr.offset, 0)) + x = gen_rtx_PLUS (Pmode, x, XEXP (XEXP (addr.offset, 0), 1)); + if (addr.index) + { + rtx idx = addr.index; + if (addr.scale != 1) + idx = gen_rtx_MULT (Pmode, idx, GEN_INT (addr.scale)); + x = gen_rtx_PLUS (Pmode, idx, x); + } + if (addr.base) + x = gen_rtx_PLUS (Pmode, addr.base, x); + if (MEM_P (orig_x)) + x = replace_equiv_address_nv (orig_x, x); + return x; } diff --git a/gcc/config/rs6000/darwin.md b/gcc/config/rs6000/darwin.md index 356b879b2a4..a61240a1f48 100644 --- a/gcc/config/rs6000/darwin.md +++ b/gcc/config/rs6000/darwin.md @@ -141,11 +141,13 @@ You should have received a copy of the GNU General Public License ;; 64-bit MachO load/store support (define_insn "movdi_low" - [(set (match_operand:DI 0 "gpc_reg_operand" "=r") - (mem:DI (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b") + [(set (match_operand:DI 0 "gpc_reg_operand" "=r,*!d") + (mem:DI (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,b") (match_operand 2 "" ""))))] "TARGET_MACHO && TARGET_64BIT" - "{l|ld} %0,lo16(%2)(%1)" + "@ + {l|ld} %0,lo16(%2)(%1) + lfd %0,lo16(%2)(%1)" [(set_attr "type" "load") (set_attr "length" "4")]) @@ -159,11 +161,13 @@ You should have received a copy of the GNU General Public License (set_attr "length" "4")]) (define_insn "movdi_low_st" - [(set (mem:DI (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b") + [(set (mem:DI (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,b") (match_operand 2 "" ""))) - (match_operand:DI 0 "gpc_reg_operand" "r"))] + (match_operand:DI 0 "gpc_reg_operand" "r,*!d"))] "TARGET_MACHO && TARGET_64BIT" - "{st|std} %0,lo16(%2)(%1)" + "@ + {st|std} %0,lo16(%2)(%1) + stfd %0,lo16(%2)(%1)" [(set_attr "type" "store") (set_attr "length" "4")]) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 854f6d00f88..eadc1222c44 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -2577,7 +2577,8 @@ rs6000_option_override_internal (const char *default_cpu) /* Masks for instructions set at various powerpc ISAs. */ enum { ISA_2_1_MASKS = MASK_MFCRF, - ISA_2_2_MASKS = (ISA_2_1_MASKS | MASK_POPCNTB | MASK_FPRND), + ISA_2_2_MASKS = (ISA_2_1_MASKS | MASK_POPCNTB), + ISA_2_4_MASKS = (ISA_2_2_MASKS | MASK_FPRND), /* For ISA 2.05, do not add MFPGPR, since it isn't in ISA 2.06, and don't add ALTIVEC, since in general it isn't a win on power6. In ISA 2.04, @@ -2746,7 +2747,9 @@ rs6000_option_override_internal (const char *default_cpu) target_flags |= (ISA_2_5_MASKS_SERVER & ~target_flags_explicit); else if (TARGET_CMPB) target_flags |= (ISA_2_5_MASKS_EMBEDDED & ~target_flags_explicit); - else if (TARGET_POPCNTB || TARGET_FPRND) + else if (TARGET_FPRND) + target_flags |= (ISA_2_4_MASKS & ~target_flags_explicit); + else if (TARGET_POPCNTB) target_flags |= (ISA_2_2_MASKS & ~target_flags_explicit); else if (TARGET_ALTIVEC) target_flags |= (MASK_PPC_GFXOPT & ~target_flags_explicit); diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 1dbf52c3c3d..37f5ad227b4 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -7149,7 +7149,7 @@ (define_insn "*friz" [(set (match_operand:DF 0 "gpc_reg_operand" "=d") (float:DF (fix:DI (match_operand:DF 1 "gpc_reg_operand" "d"))))] - "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_POPCNTB + "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_FPRND && !VECTOR_UNIT_VSX_P (DFmode) && flag_unsafe_math_optimizations && !flag_trapping_math && TARGET_FRIZ" "friz %0,%1" diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 105cf6de618..7b2a6ffd4f0 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -1554,6 +1554,9 @@ s390_handle_arch_option (const char *arg, *flags = processor_alias_table[i].flags; return true; } + + *type = PROCESSOR_max; + *flags = 0; return false; } @@ -1614,6 +1617,12 @@ s390_option_override (void) s390_handle_arch_option (s390_arch_string, &s390_arch, &s390_arch_flags); } + /* This check is triggered when the user specified a wrong -march= + string and prevents subsequent error messages from being + issued. */ + if (s390_arch == PROCESSOR_max) + return; + /* Determine processor to tune for. */ if (s390_tune == PROCESSOR_max) { diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 4793e772bda..afea74c7270 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -405,7 +405,6 @@ static rtx sparc_tls_got (void); static const char *get_some_local_dynamic_name (void); static int get_some_local_dynamic_name_1 (rtx *, void *); static bool sparc_rtx_costs (rtx, int, int, int *, bool); -static bool sparc_promote_prototypes (const_tree); static rtx sparc_function_value (const_tree, const_tree, bool); static rtx sparc_libcall_value (enum machine_mode, const_rtx); static bool sparc_function_value_regno_p (const unsigned int); @@ -554,9 +553,6 @@ static const struct default_options sparc_option_optimization_table[] = #undef TARGET_PROMOTE_FUNCTION_MODE #define TARGET_PROMOTE_FUNCTION_MODE sparc_promote_function_mode -#undef TARGET_PROMOTE_PROTOTYPES -#define TARGET_PROMOTE_PROTOTYPES sparc_promote_prototypes - #undef TARGET_FUNCTION_VALUE #define TARGET_FUNCTION_VALUE sparc_function_value #undef TARGET_LIBCALL_VALUE @@ -4909,15 +4905,6 @@ init_cumulative_args (struct sparc_args *cum, tree fntype, cum->libcall_p = fntype == 0; } -/* Handle the TARGET_PROMOTE_PROTOTYPES target hook. - When a prototype says `char' or `short', really pass an `int'. */ - -static bool -sparc_promote_prototypes (const_tree fntype ATTRIBUTE_UNUSED) -{ - return TARGET_ARCH32 ? true : false; -} - /* Handle promotion of pointer and integer arguments. */ static enum machine_mode @@ -4933,12 +4920,8 @@ sparc_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, return Pmode; } - /* For TARGET_ARCH64 we need this, as we don't have instructions - for arithmetic operations which do zero/sign extension at the same time, - so without this we end up with a srl/sra after every assignment to an - user variable, which means very very bad code. */ - if (TARGET_ARCH64 - && GET_MODE_CLASS (mode) == MODE_INT + /* Integral arguments are passed as full words, as per the ABI. */ + if (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) < UNITS_PER_WORD) return word_mode; @@ -5959,8 +5942,8 @@ sparc_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) integers are returned like floats of the same size, that is in registers. Return all vector floats like structure and unions; note that they always have BLKmode like the latter. */ - return ((TYPE_MODE (type) == BLKmode - && (unsigned HOST_WIDE_INT) int_size_in_bytes (type) > 32)); + return (TYPE_MODE (type) == BLKmode + && (unsigned HOST_WIDE_INT) int_size_in_bytes (type) > 32); } /* Handle the TARGET_STRUCT_VALUE target hook. @@ -6001,22 +5984,22 @@ sparc_struct_value_rtx (tree fndecl, int incoming) tree size = TYPE_SIZE_UNIT (TREE_TYPE (fndecl)); rtx size_rtx = GEN_INT (TREE_INT_CST_LOW (size) & 0xfff); /* Construct a temporary return value */ - rtx temp_val = assign_stack_local (Pmode, TREE_INT_CST_LOW (size), 0); + rtx temp_val + = assign_stack_local (Pmode, TREE_INT_CST_LOW (size), 0); - /* Implement SPARC 32-bit psABI callee returns struck checking - requirements: + /* Implement SPARC 32-bit psABI callee return struct checking: - Fetch the instruction where we will return to and see if + Fetch the instruction where we will return to and see if it's an unimp instruction (the most significant 10 bits will be zero). */ emit_move_insn (scratch, gen_rtx_MEM (SImode, plus_constant (ret_rtx, 8))); /* Assume the size is valid and pre-adjust */ emit_insn (gen_add3_insn (ret_rtx, ret_rtx, GEN_INT (4))); - emit_cmp_and_jump_insns (scratch, size_rtx, EQ, const0_rtx, SImode, 0, endlab); + emit_cmp_and_jump_insns (scratch, size_rtx, EQ, const0_rtx, SImode, + 0, endlab); emit_insn (gen_sub3_insn (ret_rtx, ret_rtx, GEN_INT (4))); - /* Assign stack temp: - Write the address of the memory pointed to by temp_val into + /* Write the address of the memory pointed to by temp_val into the memory pointed to by mem */ emit_move_insn (mem, XEXP (temp_val, 0)); emit_label (endlab); @@ -6107,12 +6090,19 @@ sparc_function_value_1 (const_tree type, enum machine_mode mode, mclass = MODE_INT; } - /* This must match sparc_promote_function_mode. - ??? Maybe 32-bit pointers should actually remain in Pmode? */ + /* We should only have pointer and integer types at this point. This + must match sparc_promote_function_mode. */ else if (mclass == MODE_INT && GET_MODE_SIZE (mode) < UNITS_PER_WORD) mode = word_mode; } + /* We should only have pointer and integer types at this point. This must + match sparc_promote_function_mode. */ + else if (TARGET_ARCH32 + && mclass == MODE_INT + && GET_MODE_SIZE (mode) < UNITS_PER_WORD) + mode = word_mode; + if ((mclass == MODE_FLOAT || mclass == MODE_COMPLEX_FLOAT) && TARGET_FPU) regno = SPARC_FP_ARG_FIRST; else @@ -6122,9 +6112,8 @@ sparc_function_value_1 (const_tree type, enum machine_mode mode, } /* Handle TARGET_FUNCTION_VALUE. - - On SPARC the value is found in the first "output" register, but the called - function leaves it in the first "input" register. */ + On the SPARC, the value is found in the first "output" register, but the + called function leaves it in the first "input" register. */ static rtx sparc_function_value (const_tree valtype, @@ -6143,9 +6132,9 @@ sparc_libcall_value (enum machine_mode mode, return sparc_function_value_1 (NULL_TREE, mode, false); } -/* Handle FUNCTION_VALUE_REGNO_P. - On SPARC, the first "output" reg is used for integer values, and - the first floating point register is used for floating point values. */ +/* Handle FUNCTION_VALUE_REGNO_P. + On the SPARC, the first "output" reg is used for integer values, and the + first floating point register is used for floating point values. */ static bool sparc_function_value_regno_p (const unsigned int regno) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 939b05af362..4f08ec39617 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,55 @@ +2010-11-08 Jason Merrill <jason@redhat.com> + + Correct conversion/overflow behavior. + * cvt.c (ignore_overflows): Move here from typeck.c. + (ocp_convert): Use it. + (cp_fold_convert): Use it. Don't call rvalue. + * typeck.c (build_static_cast_1): Don't use it. Do call rvalue. + * error.c (location_of): Handle expressions, too. + * class.c (check_bitfield_decl): Set input_location around call to + cxx_constant_value. + * semantics.c (cxx_eval_outermost_constant_expr): Don't + print the expression if it already had TREE_OVERFLOW set. + (reduced_constant_expression_p): Check TREE_OVERFLOW_P for C++98, too. + (verify_constant): Allow overflow with a permerror if we're + enforcing. + (cxx_eval_outermost_constant_expr): Use verify_constant. + (adjust_temp_type): Use cp_fold_convert. + * decl.c (build_enumerator): Don't call constant_expression_warning. + * decl2.c (grokbitfield): Likewise. + +2010-11-06 Jason Merrill <jason@redhat.com> + + PR c++/46348 + * init.c (perform_member_init): Use build_vec_init_expr for + value-init of arrays, too. + * cp-gimplify.c (cp_gimplify_expr): Use VEC_INIT_EXPR_VALUE_INIT. + * cp-tree.h (VEC_INIT_EXPR_IS_CONSTEXPR): New macro. + (VEC_INIT_EXPR_VALUE_INIT): New macro. + * semantics.c (potential_constant_expression): No longer static. + Check VEC_INIT_EXPR_IS_CONSTEXPR. + * tree.c (build_vec_init_expr): Handle value-init. Set + VEC_INIT_EXPR_IS_CONSTEXPR and VEC_INIT_EXPR_VALUE_INIT. + +2010-11-06 Nathan Froyd <froydnj@codesourcery.com> + + PR c++/45332 + * parser.c (cp_lexer_previous_token): New function. + (cp_parser_member_declaration): Use previous token for error + messages. Assume semicolon presence rather than grovelling for + the next one. + +2010-11-06 Joern Rennecke <amylaar@spamcop.net> + + PR middle-end/46314 + * method.c (make_alias_for_thunk): + Use targetm.asm_out.generate_internal_label. + +2010-11-05 Jason Merrill <jason@redhat.com> + + PR c++/45473 + * search.c (look_for_overrides): A constructor is never virtual. + 2010-11-05 Jakub Jelinek <jakub@redhat.com> PR c++/46160 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 435fa71c3f5..03951cfa4ea 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2797,11 +2797,14 @@ check_bitfield_decl (tree field) } else { + location_t loc = input_location; /* Avoid the non_lvalue wrapper added by fold for PLUS_EXPRs. */ STRIP_NOPS (w); /* detect invalid field size. */ + input_location = DECL_SOURCE_LOCATION (field); w = cxx_constant_value (w); + input_location = loc; if (TREE_CODE (w) != INTEGER_CST) { diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 705979d6c55..557430d6c83 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -535,7 +535,7 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) gcc_assert (EXPR_HAS_LOCATION (*expr_p)); input_location = EXPR_LOCATION (*expr_p); *expr_p = build_vec_init (VEC_INIT_EXPR_SLOT (*expr_p), NULL_TREE, - init, /*explicit_value_init_p*/false, + init, VEC_INIT_EXPR_VALUE_INIT (*expr_p), from_array, tf_warning_or_error); ret = GS_OK; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8f5227800f5..241805ca36b 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -72,6 +72,7 @@ c-common.h, not after. CONSTRUCTOR_IS_DIRECT_INIT (in CONSTRUCTOR) LAMBDA_EXPR_CAPTURES_THIS_P (in LAMBDA_EXPR) DECLTYPE_FOR_LAMBDA_CAPTURE (in DECLTYPE_TYPE) + VEC_INIT_EXPR_IS_CONSTEXPR (in VEC_INIT_EXPR) 1: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE) TI_PENDING_TEMPLATE_FLAG. TEMPLATE_PARMS_FOR_INLINE. @@ -2898,6 +2899,15 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) #define VEC_INIT_EXPR_SLOT(NODE) TREE_OPERAND (NODE, 0) #define VEC_INIT_EXPR_INIT(NODE) TREE_OPERAND (NODE, 1) +/* Indicates that a VEC_INIT_EXPR is a potential constant expression. + Only set when the current function is constexpr. */ +#define VEC_INIT_EXPR_IS_CONSTEXPR(NODE) \ + TREE_LANG_FLAG_0 (VEC_INIT_EXPR_CHECK (NODE)) + +/* Indicates that a VEC_INIT_EXPR is expressing value-initialization. */ +#define VEC_INIT_EXPR_VALUE_INIT(NODE) \ + TREE_LANG_FLAG_1 (VEC_INIT_EXPR_CHECK (NODE)) + /* The TYPE_MAIN_DECL for a class template type is a TYPE_DECL, not a TEMPLATE_DECL. This macro determines whether or not a given class type is really a template type, as opposed to an instantiation or @@ -5240,6 +5250,7 @@ extern bool literal_type_p (tree); extern tree validate_constexpr_fundecl (tree); extern tree register_constexpr_fundef (tree, tree); extern tree ensure_literal_type_for_constexpr_object (tree); +extern bool potential_constant_expression (tree, tsubst_flags_t); extern tree cxx_constant_value (tree); extern tree maybe_constant_value (tree); extern tree maybe_constant_init (tree); diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index d2d6f4acdf9..2f7823f76d9 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -543,12 +543,35 @@ force_rvalue (tree expr) } -/* Fold away simple conversions, but make sure the result is an rvalue. */ +/* If EXPR and ORIG are INTEGER_CSTs, return a version of EXPR that has + TREE_OVERFLOW set only if it is set in ORIG. Otherwise, return EXPR + unchanged. */ + +static tree +ignore_overflows (tree expr, tree orig) +{ + if (TREE_CODE (expr) == INTEGER_CST + && TREE_CODE (orig) == INTEGER_CST + && TREE_OVERFLOW (expr) != TREE_OVERFLOW (orig)) + { + gcc_assert (!TREE_OVERFLOW (orig)); + /* Ensure constant sharing. */ + expr = build_int_cst_wide (TREE_TYPE (expr), + TREE_INT_CST_LOW (expr), + TREE_INT_CST_HIGH (expr)); + } + return expr; +} + +/* Fold away simple conversions, but make sure TREE_OVERFLOW is set + properly. */ tree cp_fold_convert (tree type, tree expr) { - return rvalue (fold_convert (type, expr)); + tree conv = fold_convert (type, expr); + conv = ignore_overflows (conv, expr); + return conv; } /* C++ conversions, preference to static cast conversions. */ @@ -661,6 +684,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags) if (INTEGRAL_CODE_P (code)) { tree intype = TREE_TYPE (e); + tree converted; if (TREE_CODE (type) == ENUMERAL_TYPE) { @@ -705,7 +729,10 @@ ocp_convert (tree type, tree expr, int convtype, int flags) if (code == BOOLEAN_TYPE) return cp_truthvalue_conversion (e); - return fold_if_not_in_template (convert_to_integer (type, e)); + converted = fold_if_not_in_template (convert_to_integer (type, e)); + + /* Ignore any integer overflow caused by the conversion. */ + return ignore_overflows (converted, e); } if (NULLPTR_TYPE_P (type) && e && null_ptr_cst_p (e)) return nullptr_node; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index fb5ca7ff6f9..c3728408368 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11823,7 +11823,6 @@ build_enumerator (tree name, tree value, tree enumtype, location_t loc) if (TREE_CODE (value) == INTEGER_CST) { value = perform_integral_promotions (value); - constant_expression_warning (value); } else { diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index a805c6b52d7..e00549eca3b 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1054,7 +1054,6 @@ grokbitfield (const cp_declarator *declarator, if (!INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (width))) error ("width of bit-field %qD has non-integral type %qT", value, TREE_TYPE (width)); - constant_expression_warning (width); DECL_INITIAL (value) = width; SET_DECL_C_BIT_FIELD (value); } diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 6f60c06887c..1560fc6047b 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -2469,7 +2469,9 @@ location_of (tree t) else if (TREE_CODE (t) == OVERLOAD) t = OVL_FUNCTION (t); - return DECL_SOURCE_LOCATION (t); + if (DECL_P (t)) + return DECL_SOURCE_LOCATION (t); + return EXPR_LOC_OR_HERE (t); } /* Now the interfaces from error et al to dump_type et al. Each takes an diff --git a/gcc/cp/init.c b/gcc/cp/init.c index ab834bf65ef..0ecd61d3aed 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -453,10 +453,8 @@ perform_member_init (tree member, tree init) /* mem() means value-initialization. */ if (TREE_CODE (type) == ARRAY_TYPE) { - init = build_vec_init (decl, NULL_TREE, NULL_TREE, - /*explicit_value_init_p=*/true, - /* from_array=*/0, - tf_warning_or_error); + init = build_vec_init_expr (type, init); + init = build2 (INIT_EXPR, type, decl, init); finish_expr_stmt (init); } else diff --git a/gcc/cp/method.c b/gcc/cp/method.c index c1d30d476a1..d0ed0f4e9cb 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -252,7 +252,7 @@ make_alias_for_thunk (tree function) tree alias; char buf[256]; - ASM_GENERATE_INTERNAL_LABEL (buf, "LTHUNK", thunk_labelno); + targetm.asm_out.generate_internal_label (buf, "LTHUNK", thunk_labelno); thunk_labelno++; alias = make_alias_for (function, get_identifier (buf)); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 6302864fd97..6a9e4d7b981 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -502,6 +502,19 @@ cp_lexer_token_at (cp_lexer *lexer ATTRIBUTE_UNUSED, cp_token_position pos) return pos; } +static inline cp_token * +cp_lexer_previous_token (cp_lexer *lexer) +{ + cp_token_position tp; + + if (lexer->next_token == &eof_token) + tp = lexer->last_token - 1; + else + tp = cp_lexer_token_position (lexer, true); + + return cp_lexer_token_at (lexer, tp); +} + /* nonzero if we are presently saving tokens. */ static inline int @@ -17627,6 +17640,8 @@ cp_parser_member_declaration (cp_parser* parser) } else { + bool assume_semicolon = false; + /* See if these declarations will be friends. */ friend_p = cp_parser_friend_p (&decl_specifiers); @@ -17820,11 +17835,18 @@ cp_parser_member_declaration (cp_parser* parser) else if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON)) { - cp_parser_error (parser, "expected %<;%>"); - /* Skip tokens until we find a `;'. */ - cp_parser_skip_to_end_of_statement (parser); + /* The next token might be a ways away from where the + actual semicolon is missing. Find the previous token + and use that for our error position. */ + cp_token *token = cp_lexer_previous_token (parser->lexer); + error_at (token->location, + "expected %<;%> at end of member declaration"); - break; + /* Assume that the user meant to provide a semicolon. If + we were to cp_parser_skip_to_end_of_statement, we might + skip to a semicolon inside a member function definition + and issue nonsensical error messages. */ + assume_semicolon = true; } if (decl) @@ -17836,6 +17858,9 @@ cp_parser_member_declaration (cp_parser* parser) if (TREE_CODE (decl) == FUNCTION_DECL) cp_parser_save_default_args (parser, decl); } + + if (assume_semicolon) + return; } } diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 0249fb06d48..370ddf636c3 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1935,6 +1935,11 @@ look_for_overrides (tree type, tree fndecl) int ix; int found = 0; + /* A constructor for a class T does not override a function T + in a base class. */ + if (DECL_CONSTRUCTOR_P (fndecl)) + return 0; + for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++) { tree basetype = BINFO_TYPE (base_binfo); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 558be885275..494247e71b5 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5324,8 +5324,6 @@ typedef struct GTY(()) constexpr_fundef { static GTY ((param_is (constexpr_fundef))) htab_t constexpr_fundef_table; -static bool potential_constant_expression (tree, tsubst_flags_t); - /* Utility function used for managing the constexpr function table. Return true if the entries pointed to by P and Q are for the same constexpr function. */ @@ -5791,7 +5789,7 @@ adjust_temp_type (tree type, tree temp) if (TREE_CODE (temp) == CONSTRUCTOR) return build_constructor (type, CONSTRUCTOR_ELTS (temp)); gcc_assert (SCALAR_TYPE_P (type)); - return fold_convert (type, temp); + return cp_fold_convert (type, temp); } /* Subroutine of cxx_eval_call_expression. @@ -6005,13 +6003,13 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t, return result; } +/* FIXME speed this up, it's taking 16% of compile time on sieve testcase. */ + bool reduced_constant_expression_p (tree t) { - /* FIXME speed this up, it's taking 16% of compile time on sieve testcase. */ - if (cxx_dialect >= cxx0x && TREE_OVERFLOW_P (t)) - /* In C++0x, integer overflow makes this not a constant expression. - FIXME arithmetic overflow is different from conversion truncation */ + if (TREE_OVERFLOW_P (t)) + /* Integer overflow makes this not a constant expression. */ return false; /* FIXME are we calling this too much? */ return initializer_constant_valid_p (t, TREE_TYPE (t)) != NULL_TREE; @@ -6032,7 +6030,20 @@ verify_constant (tree t, bool allow_non_constant, bool *non_constant_p) if (!*non_constant_p && !reduced_constant_expression_p (t)) { if (!allow_non_constant) - error ("%qE is not a constant expression", t); + { + /* If T was already folded to a _CST with TREE_OVERFLOW set, + printing the folded constant isn't helpful. */ + if (TREE_OVERFLOW_P (t)) + { + permerror (input_location, "overflow in constant expression"); + /* If we're being permissive (and are in an enforcing + context), consider this constant. */ + if (flag_permissive) + return false; + } + else + error ("%q+E is not a constant expression", t); + } *non_constant_p = true; } return *non_constant_p; @@ -6897,12 +6908,7 @@ cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant) tree r = cxx_eval_constant_expression (NULL, t, allow_non_constant, false, &non_constant_p); - if (!non_constant_p && !reduced_constant_expression_p (r)) - { - if (!allow_non_constant) - error ("%qE is not a constant expression", t); - non_constant_p = true; - } + verify_constant (r, allow_non_constant, &non_constant_p); if (non_constant_p && !allow_non_constant) return error_mark_node; @@ -7066,7 +7072,7 @@ morally_constexpr_builtin_function_p (tree decl) logical OR (5.15), and conditional (5.16) operations that are not evaluated are not considered. */ -static bool +bool potential_constant_expression (tree t, tsubst_flags_t flags) { int i; @@ -7451,11 +7457,7 @@ potential_constant_expression (tree t, tsubst_flags_t flags) return false; case VEC_INIT_EXPR: - /* We should only see this in a defaulted constructor for a class - with a non-static data member of array type; if we get here we - know this is a potential constant expression. */ - gcc_assert (DECL_DEFAULTED_FN (current_function_decl)); - return true; + return VEC_INIT_EXPR_IS_CONSTEXPR (t); default: sorry ("unexpected ast of kind %s", tree_code_name[TREE_CODE (t)]); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d1d306e3a2a..5440e10204e 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -462,34 +462,54 @@ build_vec_init_expr (tree type, tree init) { tree slot; tree inner_type = strip_array_types (type); - - gcc_assert (init == NULL_TREE - || (same_type_ignoring_top_level_qualifiers_p - (type, TREE_TYPE (init)))); + tree elt_init = integer_zero_node; + bool value_init = false; /* Since we're deferring building the actual constructor calls until gimplification time, we need to build one now and throw it away so that the relevant constructor gets mark_used before cgraph decides what functions are needed. Here we assume that init is either - NULL_TREE or another array to copy. */ - if (CLASS_TYPE_P (inner_type)) + NULL_TREE, void_type_node (indicating value-initialization), or + another array to copy. */ + if (init == void_type_node) { - VEC(tree,gc) *argvec = make_tree_vector (); - if (init) + elt_init = build_value_init (inner_type, tf_warning_or_error); + value_init = true; + init = NULL_TREE; + } + else + { + gcc_assert (init == NULL_TREE + || (same_type_ignoring_top_level_qualifiers_p + (type, TREE_TYPE (init)))); + + if (CLASS_TYPE_P (inner_type)) { - tree dummy = build_dummy_object (inner_type); - if (!real_lvalue_p (init)) - dummy = move (dummy); - VEC_quick_push (tree, argvec, dummy); + VEC(tree,gc) *argvec = make_tree_vector (); + if (init) + { + tree dummy = build_dummy_object (inner_type); + if (!real_lvalue_p (init)) + dummy = move (dummy); + VEC_quick_push (tree, argvec, dummy); + } + elt_init + = build_special_member_call (NULL_TREE, complete_ctor_identifier, + &argvec, inner_type, LOOKUP_NORMAL, + tf_warning_or_error); } - build_special_member_call (NULL_TREE, complete_ctor_identifier, - &argvec, inner_type, LOOKUP_NORMAL, - tf_warning_or_error); } slot = build_local_temp (type); init = build2 (VEC_INIT_EXPR, type, slot, init); SET_EXPR_LOCATION (init, input_location); + + if (current_function_decl + && DECL_DECLARED_CONSTEXPR_P (current_function_decl) + && potential_constant_expression (elt_init, tf_warning_or_error)) + VEC_INIT_EXPR_IS_CONSTEXPR (init) = true; + VEC_INIT_EXPR_VALUE_INIT (init) = value_init; + init = build_target_expr (slot, init); TARGET_EXPR_IMPLICIT_P (init) = 1; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 6a52fc47645..cad88179718 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5717,33 +5717,6 @@ convert_ptrmem (tree type, tree expr, bool allow_inverse_p, allow_inverse_p, c_cast_p, complain); } -/* If EXPR is an INTEGER_CST and ORIG is an arithmetic constant, return - a version of EXPR that has TREE_OVERFLOW set if it is set in ORIG. - Otherwise, return EXPR unchanged. */ - -static tree -ignore_overflows (tree expr, tree orig) -{ - if (TREE_CODE (expr) == INTEGER_CST - && CONSTANT_CLASS_P (orig) - && TREE_CODE (orig) != STRING_CST - && TREE_OVERFLOW (expr) != TREE_OVERFLOW (orig)) - { - if (!TREE_OVERFLOW (orig)) - /* Ensure constant sharing. */ - expr = build_int_cst_wide (TREE_TYPE (expr), - TREE_INT_CST_LOW (expr), - TREE_INT_CST_HIGH (expr)); - else - { - /* Avoid clobbering a shared constant. */ - expr = copy_node (expr); - TREE_OVERFLOW (expr) = TREE_OVERFLOW (orig); - } - } - return expr; -} - /* Perform a static_cast from EXPR to TYPE. When C_CAST_P is true, this static_cast is being attempted as one of the possible casts allowed by a C-style cast. (In that case, accessibility of base @@ -5757,7 +5730,6 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, { tree intype; tree result; - tree orig; /* Assume the cast is valid. */ *valid_p = true; @@ -5814,8 +5786,14 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, expr = build_base_path (MINUS_EXPR, build_address (expr), base, /*nonnull=*/false); /* Convert the pointer to a reference -- but then remember that - there are no expressions with reference type in C++. */ - return convert_from_reference (cp_fold_convert (type, expr)); + there are no expressions with reference type in C++. + + We call rvalue so that there's an actual tree code + (NON_LVALUE_EXPR) for the static_cast; otherwise, if the operand + is a variable with the same type, the conversion would get folded + away, leaving just the variable and causing lvalue_kind to give + the wrong answer. */ + return convert_from_reference (rvalue (cp_fold_convert (type, expr))); } /* "An lvalue of type cv1 T1 can be cast to type rvalue reference to @@ -5830,8 +5808,6 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, return convert_from_reference (expr); } - orig = expr; - /* Resolve overloaded address here rather than once in implicit_conversion and again in the inverse code below. */ if (TYPE_PTRMEMFUNC_P (type) && type_unknown_p (expr)) @@ -5852,9 +5828,6 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, { result = convert_from_reference (result); - /* Ignore any integer overflow caused by the cast. */ - result = ignore_overflows (result, orig); - /* [expr.static.cast] If T is a reference type, the result is an lvalue; otherwise, @@ -5894,13 +5867,7 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, || SCALAR_FLOAT_TYPE_P (type)) && (INTEGRAL_OR_ENUMERATION_TYPE_P (intype) || SCALAR_FLOAT_TYPE_P (intype))) - { - expr = ocp_convert (type, expr, CONV_C_CAST, LOOKUP_NORMAL); - - /* Ignore any integer overflow caused by the cast. */ - expr = ignore_overflows (expr, orig); - return expr; - } + return ocp_convert (type, expr, CONV_C_CAST, LOOKUP_NORMAL); if (TYPE_PTR_P (type) && TYPE_PTR_P (intype) && CLASS_TYPE_P (TREE_TYPE (type)) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 95e9d8808f8..577c35a15ad 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -2418,7 +2418,13 @@ standard modes, the X/Open function @code{strfmon} is also checked as are @code{printf_unlocked} and @code{fprintf_unlocked}. @xref{C Dialect Options,,Options Controlling C Dialect}. -The target may provide additional types of format checks. +For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is +recognized in the same context. Declarations including these format attributes +will be parsed for correct syntax, however the result of checking of such format +strings is not yet defined, and will not be carried out by this version of the +compiler. + +The target may also provide additional types of format checks. @xref{Target Format Checks,,Format Checks Specific to Particular Target Machines}. @@ -2467,6 +2473,14 @@ requested by @option{-ansi} or an appropriate @option{-std} option, or is used. @xref{C Dialect Options,,Options Controlling C Dialect}. +For Objective-C dialects, the @code{format-arg} attribute may refer to an +@code{NSString} reference for compatibility with the @code{format} attribute +above. + +The target may also allow additional types in @code{format-arg} attributes. +@xref{Target Format Checks,,Format Checks Specific to Particular +Target Machines}. + @item function_vector @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified @@ -12426,6 +12440,7 @@ format attribute @menu * Solaris Format Checks:: +* Darwin Format Checks:: @end menu @node Solaris Format Checks @@ -12436,6 +12451,20 @@ check. @code{cmn_err} accepts a subset of the standard @code{printf} conversions, and the two-argument @code{%b} conversion for displaying bit-fields. See the Solaris man page for @code{cmn_err} for more information. +@node Darwin Format Checks +@subsection Darwin Format Checks + +Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format +attribute context. Declarations made with such attribution will be parsed for correct syntax +and format argument types. However, parsing of the format string itself is currently undefined +and will not be carried out by this version of the compiler. + +Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may +also be used as format arguments. Note that the relevant headers are only likely to be +available on Darwin (OSX) installations. On such installations, the XCode and system +documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and +associated functions. + @node Pragmas @section Pragmas Accepted by GCC @cindex pragmas diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 0bb146e9cf2..7666fcfd401 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -715,8 +715,16 @@ only available in the C (and related language) front ends, then you should use @code{TARGET_HANDLE_C_OPTION} instead. @end deftypefn -@deftypefn {Target Hook} tree TARGET_OBJC_CONSTRUCT_STRING (tree @var{string}) -Construct a constant string representation for @var{string} +@deftypefn {Target Hook} tree TARGET_OBJC_CONSTRUCT_STRING_OBJECT (tree @var{string}) +Targets may provide a string object type that can be used within and between C, C++ and their respective Objective-C dialects. A string object might, for example, embed encoding and length information. These objects are considered opaque to the compiler and handled as references. An ideal implementation makes the composition of the string object match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep), allowing efficient interworking between C-only and Objective-C code. If a target implements string objects then this hook should return a reference to such an object constructed from the normal `C' string representation provided in @var{string}. At present, the hook is used by Objective-C only, to obtain a common-format string object when the target provides one. +@end deftypefn + +@deftypefn {Target Hook} bool TARGET_STRING_OBJECT_REF_TYPE_P (const_tree @var{stringref}) +If a target implements string objects then this hook should return @code{true} if @var{stringref} is a valid reference to such an object. +@end deftypefn + +@deftypefn {Target Hook} void TARGET_CHECK_STRING_OBJECT_FORMAT_ARG (tree @var{format_arg}, tree @var{args_list}) +If a target implements string objects then this hook should should provide a facility to check the function arguments in @var{args_list} against the format specifiers in @var{format_arg} where the type of @var{format_arg} is one recognized as a valid string reference type. @end deftypefn @defmac TARGET_VERSION diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 6bf51d65d24..b0c4bccc704 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -715,7 +715,11 @@ only available in the C (and related language) front ends, then you should use @code{TARGET_HANDLE_C_OPTION} instead. @end deftypefn -@hook TARGET_OBJC_CONSTRUCT_STRING +@hook TARGET_OBJC_CONSTRUCT_STRING_OBJECT + +@hook TARGET_STRING_OBJECT_REF_TYPE_P + +@hook TARGET_CHECK_STRING_OBJECT_FORMAT_ARG @defmac TARGET_VERSION This macro is a C statement to print on @code{stderr} a string diff --git a/gcc/explow.c b/gcc/explow.c index a83c6e87388..85e93447940 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -1340,7 +1340,7 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align, least it doesn't cause a stack overflow. */ if (flag_split_stack) { - rtx available_label, space, func; + rtx available_label, ask, space, func; available_label = NULL_RTX; @@ -1355,10 +1355,24 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align, } #endif + /* The __morestack_allocate_stack_space function will allocate + memory using malloc. If the alignment of the memory returned + by malloc does not meet REQUIRED_ALIGN, we increase SIZE to + make sure we allocate enough space. */ + if (MALLOC_ABI_ALIGNMENT >= required_align) + ask = size; + else + { + ask = expand_binop (Pmode, add_optab, size, + GEN_INT (required_align / BITS_PER_UNIT - 1), + NULL_RTX, 1, OPTAB_LIB_WIDEN); + must_align = true; + } + func = init_one_libfunc ("__morestack_allocate_stack_space"); space = emit_library_call_value (func, target, LCT_NORMAL, Pmode, - 1, size, Pmode); + 1, ask, Pmode); if (available_label == NULL_RTX) return space; diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index cace0a310f1..a513933c5a1 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,14 @@ +2010-11-08 Janus Weil <janus@gcc.gnu.org> + + PR fortran/46344 + * trans-types.c (gfc_copy_dt_decls_ifequal): Handle CLASS components. + +2010-11-06 Janus Weil <janus@gcc.gnu.org> + + PR fortran/46330 + * trans-expr.c (gfc_trans_class_assign): Find 'vtab' symbol in correct + namespace. + 2010-11-05 Janus Weil <janus@gcc.gnu.org> PR fortran/45451 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 8da6cf0ef13..a95b421170a 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -5925,7 +5925,7 @@ gfc_trans_class_assign (gfc_expr *expr1, gfc_expr *expr2, gfc_exec_op op) gcc_assert (vtab); rhs = gfc_get_expr (); rhs->expr_type = EXPR_VARIABLE; - gfc_find_sym_tree (vtab->name, NULL, 1, &st); + gfc_find_sym_tree (vtab->name, vtab->ns, 1, &st); rhs->symtree = st; rhs->ts = vtab->ts; } diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 1ccba7a656d..a597cd72395 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -1936,10 +1936,12 @@ gfc_copy_dt_decls_ifequal (gfc_symbol *from, gfc_symbol *to, for (; to_cm; to_cm = to_cm->next, from_cm = from_cm->next) { to_cm->backend_decl = from_cm->backend_decl; - if ((!from_cm->attr.pointer || from_gsym) - && from_cm->ts.type == BT_DERIVED) + if (from_cm->ts.type == BT_DERIVED + && (!from_cm->attr.pointer || from_gsym)) + gfc_get_derived_type (to_cm->ts.u.derived); + else if (from_cm->ts.type == BT_CLASS + && (!CLASS_DATA (from_cm)->attr.class_pointer || from_gsym)) gfc_get_derived_type (to_cm->ts.u.derived); - else if (from_cm->ts.type == BT_CHARACTER) to_cm->ts.u.cl->backend_decl = from_cm->ts.u.cl->backend_decl; } diff --git a/gcc/gengtype.c b/gcc/gengtype.c index d7c7b9b5fdd..d31f3c07a6c 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -2641,9 +2641,12 @@ output_type_enum (outf_p of, type_p s) static outf_p get_output_file_for_structure (const_type_p s, type_p *param) { - const char *fn = s->u.s.line.file; + const char *fn; int i; + gcc_assert (UNION_OR_STRUCT_P (s)); + fn = s->u.s.line.file; + /* This is a hack, and not the good kind either. */ for (i = NUM_PARAM - 1; i >= 0; i--) if (param && param[i] && param[i]->kind == TYPE_POINTER @@ -4066,7 +4069,7 @@ output_typename (outf_p of, const_type_p t) static void write_splay_tree_allocator_def (const_type_p s) { - outf_p of = get_output_file_for_structure (s, NULL); + outf_p of = get_output_file_with_visibility (NULL); oprintf (of, "void * ggc_alloc_splay_tree_"); output_typename (of, s); oprintf (of, " (int sz, void * nl)\n"); @@ -4535,28 +4538,21 @@ main (int argc, char **argv) /* These types are set up with #define or else outside of where we can see them. We should initialize them before calling read_input_list. */ - pos.file = this_file; - pos.line = __LINE__ + 1; - do_scalar_typedef ("CUMULATIVE_ARGS", &pos); - pos.line++; - do_scalar_typedef ("REAL_VALUE_TYPE", &pos); - pos.line++; - do_scalar_typedef ("FIXED_VALUE_TYPE", &pos); - pos.line++; - do_scalar_typedef ("double_int", &pos); - pos.line++; - do_scalar_typedef ("uint64_t", &pos); - pos.line++; - do_scalar_typedef ("uint8", &pos); - pos.line++; - do_scalar_typedef ("jword", &pos); - pos.line++; - do_scalar_typedef ("JCF_u2", &pos); - pos.line++; - do_scalar_typedef ("void", &pos); - pos.line++; - do_typedef ("PTR", create_pointer (resolve_typedef ("void", &pos)), - &pos); +#define POS_HERE(Call) do { pos.file = this_file; pos.line = __LINE__; \ + Call;} while(0) + POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos)); + POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos)); + POS_HERE (do_scalar_typedef ("FIXED_VALUE_TYPE", &pos)); + POS_HERE (do_scalar_typedef ("double_int", &pos)); + POS_HERE (do_scalar_typedef ("uint64_t", &pos)); + POS_HERE (do_scalar_typedef ("uint8", &pos)); + POS_HERE (do_scalar_typedef ("jword", &pos)); + POS_HERE (do_scalar_typedef ("JCF_u2", &pos)); + POS_HERE (do_scalar_typedef ("void", &pos)); + POS_HERE (do_typedef ("PTR", + create_pointer (resolve_typedef ("void", &pos)), + &pos)); +#undef POS_HERE read_input_list (inputlist); for (i = 0; i < num_gt_files; i++) { diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index ae89444eb1e..4b9767768fe 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,11 @@ +2010-11-06 Joern Rennecke <amylaar@spamcop.net> + + PR middle-end/46314 + * class.c: Include target.h. + (make_local_function_alias): + Use targetm.asm_out.generate_internal_label. + * expr.c (lookup_label, generate_name): Likewise. + 2010-11-03 Joern Rennecke <joern.rennecke@embecosm.com> PR bootstrap/44335 diff --git a/gcc/java/class.c b/gcc/java/class.c index ece261b8dd3..a1dc9c08b25 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -43,6 +43,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "tree-iterator.h" #include "vecprim.h" #include "tm.h" /* FIXME: For gcc_obstack_init from defaults.h. */ +#include "target.h" /* DOS brain-damage */ #ifndef O_BINARY @@ -1399,7 +1400,7 @@ make_local_function_alias (tree method) *name = 'L'; strcpy (name + 1, method_name); - ASM_GENERATE_INTERNAL_LABEL (buf, name, alias_labelno++); + targetm.asm_out.generate_internal_label (buf, name, alias_labelno++); alias = build_decl (input_location, FUNCTION_DECL, get_identifier (buf), TREE_TYPE (method)); diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 9f9667fa88a..85cf1a2bcae 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -1763,7 +1763,8 @@ lookup_label (int pc) char buf[32]; if (pc > highest_label_pc_this_method) highest_label_pc_this_method = pc; - ASM_GENERATE_INTERNAL_LABEL(buf, "LJpc=", start_label_pc_this_method + pc); + targetm.asm_out.generate_internal_label (buf, "LJpc=", + start_label_pc_this_method + pc); name = get_identifier (buf); if (IDENTIFIER_LOCAL_VALUE (name)) return IDENTIFIER_LOCAL_VALUE (name); @@ -1783,7 +1784,7 @@ generate_name (void) { static int l_number = 0; char buff [32]; - ASM_GENERATE_INTERNAL_LABEL(buff, "LJv", l_number); + targetm.asm_out.generate_internal_label (buff, "LJv", l_number); l_number++; return get_identifier (buff); } diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index dc4cffd1e53..9bde682663a 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,35 @@ +2010-11-06 Nicola Pero <nicola.pero@meta-innovation.com> + + Fixed using the Objective-C 2.0 syntax with self and super. + * objc-act.c (OBJC_LOOKUP_NO_INSTANCE_METHODS_OF_ROOT_CLASS): New. + (maybe_make_artificial_property_decl): Added 'implementation' + argument. Use OBJC_LOOKUP_NO_INSTANCE_METHODS_OF_ROOT_CLASS when + looking up getters or setters for a class. If an implementation + is specified, search it as well for a getter or setter. + (objc_maybe_build_component_ref): Updated calls to + maybe_make_artificial_property_decl; added code to deal with + 'self' and 'super' and with methods declared locally in the + implementation. Store the getter call expression in the + PROPERTY_REF instead of throwing it away. + (objc_build_class_component_ref): Updated calls to + maybe_make_artificial_property_decl, and store the getter call + expression in PROPERTY_REF instead of throwing it away. + (lookup_method_static): Implemented + OBJC_LOOKUP_NO_INSTANCE_METHODS_OF_ROOT_CLASS option. + (objc_gimplify_property_ref): Do not build the getter method call + here; instead use the one stored in the PROPERTY_REF. If it's not + there, produce helpful error messages. + * objc-tree.def (PROPERTY_REF): Increased the number of operands + from 2 to 3. Updated comments. + * objc-act.h (PROPERTY_REF_GETTER_CALL): New. + +2010-11-06 Iain Sandoe <iains@gcc.gnu.org> + + PR target/44981 + * objc-act.c (objc_build_string_object): Amend for renamed hook. + (objc_string_ref_type_p): New. + (objc_check_format_arg): New. + 2010-11-04 Nicola Pero <nicola.pero@meta-innovation.com> Fixed using the Objective-C 2.0 dot-syntax with class names. diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index aa4c2e392b8..fd5244e389a 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "c-family/c-common.h" #include "c-family/c-pragma.h" +#include "c-family/c-format.h" #include "flags.h" #include "langhooks.h" #include "objc-act.h" @@ -376,8 +377,14 @@ static const char *default_constant_string_class_name; #define TAG_GNUINIT "__objc_gnu_init" /* Flags for lookup_method_static(). */ -#define OBJC_LOOKUP_CLASS 1 /* Look for class methods. */ -#define OBJC_LOOKUP_NO_SUPER 2 /* Do not examine superclasses. */ + +/* Look for class methods. */ +#define OBJC_LOOKUP_CLASS 1 +/* Do not examine superclasses. */ +#define OBJC_LOOKUP_NO_SUPER 2 +/* Disable returning an instance method of a root class when a class + method can't be found. */ +#define OBJC_LOOKUP_NO_INSTANCE_METHODS_OF_ROOT_CLASS 4 /* The OCTI_... enumeration itself is in objc/objc-act.h. */ tree objc_global_trees[OCTI_MAX]; @@ -1084,32 +1091,58 @@ lookup_property (tree interface_type, tree property) } /* This is a subroutine of objc_maybe_build_component_ref. Search the - list of methods in the interface (and, failing that, protocol list) + list of methods in the interface (and, failing that, the local list + in the implementation, and failing that, the protocol list) provided for a 'setter' or 'getter' for 'component' with default names (ie, if 'component' is "name", then search for "name" and "setName:"). If any is found, then create an artificial property that uses them. Return NULL_TREE if 'getter' or 'setter' could not be found. */ static tree -maybe_make_artificial_property_decl (tree interface, tree protocol_list, tree component, bool is_class) +maybe_make_artificial_property_decl (tree interface, tree implementation, + tree protocol_list, tree component, bool is_class) { tree getter_name = component; tree setter_name = get_identifier (objc_build_property_setter_name (component)); tree getter = NULL_TREE; tree setter = NULL_TREE; + /* First, check the @interface and all superclasses. */ if (interface) { int flags = 0; + /* Using instance methods of the root class as accessors is most + likely unwanted and can be extremely confusing (and, most + importantly, other Objective-C 2.0 compilers do not do it). + Turn it off. */ if (is_class) - flags = OBJC_LOOKUP_CLASS; + flags = OBJC_LOOKUP_CLASS | OBJC_LOOKUP_NO_INSTANCE_METHODS_OF_ROOT_CLASS; getter = lookup_method_static (interface, getter_name, flags); setter = lookup_method_static (interface, setter_name, flags); } - /* Try the protocol_list if we didn't find anything in the interface. */ + /* Second, check the local @implementation context. */ + if (!getter && !setter) + { + if (implementation) + { + if (is_class) + { + getter = lookup_method (CLASS_CLS_METHODS (implementation), getter_name); + setter = lookup_method (CLASS_CLS_METHODS (implementation), setter_name); + } + else + { + getter = lookup_method (CLASS_NST_METHODS (implementation), getter_name); + setter = lookup_method (CLASS_NST_METHODS (implementation), setter_name); + } + } + } + + /* Try the protocol_list if we didn't find anything in the + @interface and in the @implementation. */ if (!getter && !setter) { getter = lookup_method_in_protocol_list (protocol_list, getter_name, is_class); @@ -1185,13 +1218,13 @@ objc_maybe_build_component_ref (tree object, tree property_ident) tree x = NULL_TREE; tree rtype; - /* If we are in Objective-C 1.0 mode, properties are not - available. */ + /* If we are in Objective-C 1.0 mode, dot-syntax and properties are + not available. */ if (flag_objc1_only) return NULL_TREE; - /* Try to determine quickly if 'object' is an Objective-C object or - not. If not, return. */ + /* Try to determine if 'object' is an Objective-C object or not. If + not, return. */ if (object == NULL_TREE || object == error_mark_node || (rtype = TREE_TYPE (object)) == NULL_TREE) return NULL_TREE; @@ -1200,37 +1233,118 @@ objc_maybe_build_component_ref (tree object, tree property_ident) || TREE_CODE (property_ident) != IDENTIFIER_NODE) return NULL_TREE; - /* TODO: Implement super.property. */ - - /* TODO: Carefully review the following code. */ + /* The following analysis of 'object' is similar to the one used for + the 'receiver' of a method invocation. We need to determine what + 'object' is and find the appropriate property (either declared, + or artificial) for it (in the same way as we need to find the + appropriate method prototype for a method invocation). There are + some simplifications here though: "object.property" is invalid if + "object" has a type of "id" or "Class"; it must at least have a + protocol attached to it, and "object" is never a class name as + that is done by objc_build_class_component_ref. Finally, we + don't know if this really is a dot-syntax expression, so we want + to make a quick exit if it is not; for this reason, we try to + postpone checks after determining that 'object' looks like an + Objective-C object. */ + if (objc_is_id (rtype)) { - tree rprotos = (TYPE_HAS_OBJC_INFO (TREE_TYPE (rtype)) - ? TYPE_OBJC_PROTOCOL_LIST (TREE_TYPE (rtype)) - : NULL_TREE); - if (rprotos) - x = lookup_property_in_protocol_list (rprotos, property_ident); + /* This is the case that the 'object' is of type 'id' or + 'Class'. */ - if (x == NULL_TREE) + /* Check if at least it is of type 'id <Protocol>' or 'Class + <Protocol>'; if so, look the property up in the + protocols. */ + if (TYPE_HAS_OBJC_INFO (TREE_TYPE (rtype))) { - /* Ok, no property. Maybe it was an object.component - dot-syntax without a declared property. Look for - getter/setter methods and internally declare an artifical - property based on them if found. */ - x = maybe_make_artificial_property_decl (NULL_TREE, rprotos, - property_ident, - false); + tree rprotos = TYPE_OBJC_PROTOCOL_LIST (TREE_TYPE (rtype)); + + if (rprotos) + { + /* No point looking up declared @properties if we are + dealing with a class. Classes have no declared + properties. */ + if (!IS_CLASS (rtype)) + x = lookup_property_in_protocol_list (rprotos, property_ident); + + if (x == NULL_TREE) + { + /* Ok, no property. Maybe it was an + object.component dot-syntax without a declared + property (this is valid for classes too). Look + for getter/setter methods and internally declare + an artifical property based on them if found. */ + x = maybe_make_artificial_property_decl (NULL_TREE, + NULL_TREE, + rprotos, + property_ident, + IS_CLASS (rtype)); + } + } + } + else if (objc_method_context) + { + /* Else, if we are inside a method it could be the case of + 'super' or 'self'. */ + tree interface_type = NULL_TREE; + tree t = object; + while (TREE_CODE (t) == COMPOUND_EXPR + || TREE_CODE (t) == MODIFY_EXPR + || CONVERT_EXPR_P (t) + || TREE_CODE (t) == COMPONENT_REF) + t = TREE_OPERAND (t, 0); + + if (t == UOBJC_SUPER_decl) + interface_type = lookup_interface (CLASS_SUPER_NAME (implementation_template)); + else if (t == self_decl) + interface_type = lookup_interface (CLASS_NAME (implementation_template)); + + /* TODO: Protocols. */ + + if (interface_type) + { + if (TREE_CODE (objc_method_context) != CLASS_METHOD_DECL) + { + x = lookup_property (interface_type, property_ident); + /* TODO: Protocols. */ + } + + if (x == NULL_TREE) + { + /* Try the dot-syntax without a declared property. + If this is an access to 'self', it is possible + that they may refer to a setter/getter that is + not declared in the interface, but exists locally + in the implementation. In that case, get the + implementation context and use it. */ + tree implementation = NULL_TREE; + + if (t == self_decl) + implementation = objc_implementation_context; + + /* TODO: Protocols. */ + + x = maybe_make_artificial_property_decl + (interface_type, implementation, NULL_TREE, + property_ident, + (TREE_CODE (objc_method_context) == CLASS_METHOD_DECL)); + } + } } } else { + /* This is the case where we have more information on 'rtype'. */ tree basetype = TYPE_MAIN_VARIANT (rtype); + /* Skip the pointer - if none, it's not an Objective-C object or + class. */ if (basetype != NULL_TREE && TREE_CODE (basetype) == POINTER_TYPE) basetype = TREE_TYPE (basetype); else return NULL_TREE; + /* Traverse typedefs. */ while (basetype != NULL_TREE && TREE_CODE (basetype) == RECORD_TYPE && OBJC_TYPE_NAME (basetype) @@ -1242,58 +1356,91 @@ objc_maybe_build_component_ref (tree object, tree property_ident) { tree interface_type = TYPE_OBJC_INTERFACE (basetype); tree protocol_list = TYPE_OBJC_PROTOCOL_LIST (basetype); - - x = lookup_property (interface_type, property_ident); - - if (x == NULL_TREE) - x = lookup_property_in_protocol_list (protocol_list, property_ident); - if (x == NULL_TREE) + if (interface_type + && (TREE_CODE (interface_type) == CLASS_INTERFACE_TYPE + || TREE_CODE (interface_type) == CATEGORY_INTERFACE_TYPE + || TREE_CODE (interface_type) == PROTOCOL_INTERFACE_TYPE)) { - /* Ok, no property. Try the dot-syntax without a - declared property. */ - x = maybe_make_artificial_property_decl (interface_type, protocol_list, - property_ident, false); + /* Not sure 'rtype' could ever be a class here! Just + for safety we keep the checks. */ + if (!IS_CLASS (rtype)) + { + x = lookup_property (interface_type, property_ident); + + if (x == NULL_TREE) + x = lookup_property_in_protocol_list (protocol_list, + property_ident); + } + + if (x == NULL_TREE) + { + /* Try the dot-syntax without a declared property. + If we are inside a method implementation, it is + possible that they may refer to a setter/getter + that is not declared in the interface, but exists + locally in the implementation. In that case, get + the implementation context and use it. */ + tree implementation = NULL_TREE; + + if (objc_implementation_context + && CLASS_NAME (objc_implementation_context) + == OBJC_TYPE_NAME (interface_type)) + implementation = objc_implementation_context; + + x = maybe_make_artificial_property_decl (interface_type, + implementation, + protocol_list, + property_ident, + IS_CLASS (rtype)); + } } } } + /* TODO: Fix compiling super.accessor. */ + if (x) { tree expression; - - if (TREE_DEPRECATED (x)) - warn_deprecated_use (x, NULL_TREE); - - expression = build2 (PROPERTY_REF, TREE_TYPE(x), object, x); - SET_EXPR_LOCATION (expression, input_location); - TREE_SIDE_EFFECTS (expression) = 1; + tree getter_call; /* We have an additional nasty problem here; if this PROPERTY_REF needs to become a 'getter', then the conversion from PROPERTY_REF into a getter call happens in gimplify, - after the selector table has already been generated and it is - too late to add another selector to it. To work around the - problem, we always put the selector in the table at this - stage, as if we were building the method call here. And the - easiest way to do this is precisely to build the method call, - then discard it. Note that if the PROPERTY_REF becomes a - 'setter' instead of a 'getter', then we have added a selector - too many to the selector table. This is a little - inefficient. - - TODO: This can be made more efficient; in particular we don't - need to build the whole message call, we could just work on - the selector. + after the selector table has already been generated and when + it is too late to add another selector to it. To work around + the problem, we always create the getter call at this stage, + which puts the selector in the table. Note that if the + PROPERTY_REF becomes a 'setter' instead of a 'getter', then + we have added a selector too many to the selector table. + This is a little inefficient. + + Also note that method calls to 'self' and 'super' require the + context (self_decl, UOBJS_SUPER_decl, + objc_implementation_context etc) to be built correctly; this + is yet another reason why building the call at the gimplify + stage (when this context has been lost) is not very + practical. If we build it at this stage, we know it will + always be built correctly. If the PROPERTY_HAS_NO_GETTER() (ie, it is an artificial property decl created to deal with a dotsyntax not really referring to an existing property) then do not try to build a call to the getter as there is no getter. */ - if (!PROPERTY_HAS_NO_GETTER (x)) - objc_finish_message_expr (object, - PROPERTY_GETTER_NAME (x), - NULL_TREE); + if (PROPERTY_HAS_NO_GETTER (x)) + getter_call = NULL_TREE; + else + getter_call = objc_finish_message_expr (object, + PROPERTY_GETTER_NAME (x), + NULL_TREE); + + if (TREE_DEPRECATED (x)) + warn_deprecated_use (x, NULL_TREE); + + expression = build3 (PROPERTY_REF, TREE_TYPE(x), object, x, getter_call); + SET_EXPR_LOCATION (expression, input_location); + TREE_SIDE_EFFECTS (expression) = 1; return expression; } @@ -1340,26 +1487,28 @@ objc_build_class_component_ref (tree class_name, tree property_ident) return error_mark_node; } - x = maybe_make_artificial_property_decl (rtype, NULL_TREE, + x = maybe_make_artificial_property_decl (rtype, NULL_TREE, NULL_TREE, property_ident, true); if (x) { tree expression; + tree getter_call; + if (PROPERTY_HAS_NO_GETTER (x)) + getter_call = NULL_TREE; + else + getter_call = objc_finish_message_expr (object, + PROPERTY_GETTER_NAME (x), + NULL_TREE); if (TREE_DEPRECATED (x)) warn_deprecated_use (x, NULL_TREE); - expression = build2 (PROPERTY_REF, TREE_TYPE(x), object, x); + expression = build3 (PROPERTY_REF, TREE_TYPE(x), object, x, getter_call); SET_EXPR_LOCATION (expression, input_location); TREE_SIDE_EFFECTS (expression) = 1; - /* See above for why we do this. */ - if (!PROPERTY_HAS_NO_GETTER (x)) - objc_finish_message_expr (object, - PROPERTY_GETTER_NAME (x), - NULL_TREE); - + return expression; } else @@ -2755,9 +2904,9 @@ objc_build_string_object (tree string) literal. On Darwin (Mac OS X), for example, we may wish to obtain a constant CFString reference instead. At present, this is only supported for the NeXT runtime. */ - if (flag_next_runtime && targetcm.objc_construct_string) + if (flag_next_runtime && targetcm.objc_construct_string_object) { - tree constructor = (*targetcm.objc_construct_string) (string); + tree constructor = (*targetcm.objc_construct_string_object) (string); if (constructor) return build1 (NOP_EXPR, objc_object_type, constructor); } @@ -7956,13 +8105,16 @@ lookup_method (tree mchain, tree method) return NULL_TREE; } -/* Look up a class (if OBJC_LOOKUP_CLASS is set in FLAGS) or instance method - in INTERFACE, along with any categories and protocols attached thereto. - If method is not found, and the OBJC_LOOKUP_NO_SUPER is _not_ set in FLAGS, - recursively examine the INTERFACE's superclass. If OBJC_LOOKUP_CLASS is - set, OBJC_LOOKUP_NO_SUPER is cleared, and no suitable class method could - be found in INTERFACE or any of its superclasses, look for an _instance_ - method of the same name in the root class as a last resort. +/* Look up a class (if OBJC_LOOKUP_CLASS is set in FLAGS) or instance + method in INTERFACE, along with any categories and protocols + attached thereto. If method is not found, and the + OBJC_LOOKUP_NO_SUPER is _not_ set in FLAGS, recursively examine the + INTERFACE's superclass. If OBJC_LOOKUP_CLASS is set, + OBJC_LOOKUP_NO_SUPER is clear, and no suitable class method could + be found in INTERFACE or any of its superclasses, look for an + _instance_ method of the same name in the root class as a last + resort. This behaviour can be turned off by using + OBJC_LOOKUP_NO_INSTANCE_METHODS_OF_ROOT_CLASS. If a suitable method cannot be found, return NULL_TREE. */ @@ -7973,6 +8125,7 @@ lookup_method_static (tree interface, tree ident, int flags) tree inter = interface; int is_class = (flags & OBJC_LOOKUP_CLASS); int no_superclasses = (flags & OBJC_LOOKUP_NO_SUPER); + int no_instance_methods_of_root_class = (flags & OBJC_LOOKUP_NO_INSTANCE_METHODS_OF_ROOT_CLASS); while (inter) { @@ -8019,11 +8172,18 @@ lookup_method_static (tree interface, tree ident, int flags) } while (inter); - /* If no class (factory) method was found, check if an _instance_ - method of the same name exists in the root class. This is what - the Objective-C runtime will do. If an instance method was not - found, return 0. */ - return is_class ? lookup_method_static (root_inter, ident, 0): NULL_TREE; + if (is_class && !no_instance_methods_of_root_class) + { + /* If no class (factory) method was found, check if an _instance_ + method of the same name exists in the root class. This is what + the Objective-C runtime will do. */ + return lookup_method_static (root_inter, ident, 0); + } + else + { + /* If an instance method was not found, return 0. */ + return NULL_TREE; + } } /* Add the method to the hash list if it doesn't contain an identical @@ -12037,15 +12197,24 @@ objc_rewrite_function_call (tree function, tree first_param) static void objc_gimplify_property_ref (tree *expr_p) { - tree object_expression = PROPERTY_REF_OBJECT (*expr_p); - tree property_decl = PROPERTY_REF_PROPERTY_DECL (*expr_p); - tree call_exp, getter; - - /* TODO: Implement super.property. */ + tree getter = PROPERTY_REF_GETTER_CALL (*expr_p); + tree call_exp; + + if (getter == NULL_TREE) + { + tree property_decl = PROPERTY_REF_PROPERTY_DECL (*expr_p); + /* This can happen if DECL_ARTIFICIAL (*expr_p), but + should be impossible for real properties, which always + have a getter. */ + error_at (EXPR_LOCATION (*expr_p), "no %qs getter found", + IDENTIFIER_POINTER (PROPERTY_NAME (property_decl))); + /* Try to recover from the error to prevent an ICE. We take + zero and cast it to the type of the property. */ + *expr_p = convert (TREE_TYPE (property_decl), + integer_zero_node); + return; + } - getter = objc_finish_message_expr (object_expression, - PROPERTY_GETTER_NAME (property_decl), - NULL_TREE); call_exp = getter; #ifdef OBJCPLUS /* In C++, a getter which returns an aggregate value results in a @@ -12673,4 +12842,28 @@ objc_finish_foreach_loop (location_t location, tree object_expression, tree coll /* Done by c-parser.c */ } +/* Return true if we have an NxString object pointer. */ + +bool +objc_string_ref_type_p (tree strp) +{ + tree tmv; + if (!strp || TREE_CODE (strp) != POINTER_TYPE) + return false; + + tmv = TYPE_MAIN_VARIANT (TREE_TYPE (strp)); + tmv = OBJC_TYPE_NAME (tmv); + return (tmv + && TREE_CODE (tmv) == IDENTIFIER_NODE + && IDENTIFIER_POINTER (tmv) + && !strncmp (IDENTIFIER_POINTER (tmv), "NSString", 8)); +} + +/* At present the behavior of this is undefined and it does nothing. */ +void +objc_check_format_arg (tree ARG_UNUSED (format_arg), + tree ARG_UNUSED (args_list)) +{ +} + #include "gt-objc-objc-act.h" diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h index 9478d72fbcc..9a9cacd668f 100644 --- a/gcc/objc/objc-act.h +++ b/gcc/objc/objc-act.h @@ -131,6 +131,15 @@ typedef enum objc_property_assign_semantics { declared property. */ #define PROPERTY_REF_PROPERTY_DECL(NODE) TREE_OPERAND (PROPERTY_REF_CHECK (NODE), 1) +/* PROPERTY_REF_GETTER_CALL is the getter call expression, ready to + use at gimplify time if needed. Generating the getter call + requires modifying the selector table, and, in the case of + self/super, requires the context to be generated correctly. The + gimplify stage is too late to do these things, so we generate the + getter call earlier instead, and keep it here in case we need to + use it. */ +#define PROPERTY_REF_GETTER_CALL(NODE) TREE_OPERAND (PROPERTY_REF_CHECK (NODE), 2) + /* CLASS_INTERFACE_TYPE, CLASS_IMPLEMENTATION_TYPE, CATEGORY_INTERFACE_TYPE, CATEGORY_IMPLEMENTATION_TYPE, diff --git a/gcc/objc/objc-tree.def b/gcc/objc/objc-tree.def index 7316675c3bd..e33fc78db29 100644 --- a/gcc/objc/objc-tree.def +++ b/gcc/objc/objc-tree.def @@ -44,9 +44,11 @@ DEFTREECODE (CLASS_REFERENCE_EXPR, "class_reference_expr", tcc_expression, 1) where 'object' is an Objective-C object and 'property' is an Objective-C property. Operand 0 is the object (the tree representing the expression), and Operand 1 is the property (the - PROPERTY_DECL). A PROPERTY_REF tree needs to be transformed into - 'setter' and 'getter' calls at some point; at the moment this - happens in two places: + PROPERTY_DECL). Operand 2 is the 'getter' call, ready to be used; + we pregenerate it because it is hard to generate it properly later + on. A PROPERTY_REF tree needs to be transformed into 'setter' and + 'getter' calls at some point; at the moment this happens in two + places: * if we detect that a modify expression is being applied to a PROPERTY_REF, then we transform that into a 'getter' call (this @@ -54,13 +56,15 @@ DEFTREECODE (CLASS_REFERENCE_EXPR, "class_reference_expr", tcc_expression, 1) * else, it will remain as a PROPERTY_REF until we get to gimplification; at that point, we convert each PROPERTY_REF into - a 'getter' call during ObjC/ObjC++ gimplify. + a 'getter' call during ObjC/ObjC++ gimplify. At that point, it + is quite hard to build a 'getter' call, but we have already built + it and we just need to swap Operand 2 in. Please note that when the Objective-C 2.0 "dot-syntax" 'object.component' is encountered, where 'component' is not a property but there are valid setter/getter methods for it, an artificial PROPERTY_DECL is generated and used in the PROPERTY_REF. */ -DEFTREECODE (PROPERTY_REF, "property_ref", tcc_expression, 2) +DEFTREECODE (PROPERTY_REF, "property_ref", tcc_expression, 3) /* Local variables: diff --git a/gcc/output.h b/gcc/output.h index 2a70fd25bdd..fa223d5cf7e 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -627,6 +627,8 @@ extern void default_globalize_label (FILE *, const char *); extern void default_globalize_decl_name (FILE *, tree); extern void default_emit_unwind_label (FILE *, tree, int, int); extern void default_emit_except_table_label (FILE *); +extern void default_generate_internal_label (char *, const char *, + unsigned long); extern void default_internal_label (FILE *, const char *, unsigned long); extern void default_asm_declare_constant_name (FILE *, const char *, const_tree, HOST_WIDE_INT); diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c index 70e831d7cee..8550fcc2bf4 100644 --- a/gcc/sel-sched.c +++ b/gcc/sel-sched.c @@ -4403,7 +4403,8 @@ find_best_expr (av_set_t *av_vliw_ptr, blist_t bnds, fence_t fence, { can_issue_more = invoke_aftermath_hooks (fence, EXPR_INSN_RTX (best), can_issue_more); - if (can_issue_more == 0) + if (targetm.sched.variable_issue + && can_issue_more == 0) *pneed_stall = 1; } @@ -5511,7 +5512,7 @@ fill_insns (fence_t fence, int seqno, ilist_t **scheduled_insns_tailpp) blist_t *bnds_tailp1, *bndsp; expr_t expr_vliw; int need_stall; - int was_stall = 0, scheduled_insns = 0, stall_iterations = 0; + int was_stall = 0, scheduled_insns = 0; int max_insns = pipelining_p ? issue_rate : 2 * issue_rate; int max_stall = pipelining_p ? 1 : 3; bool last_insn_was_debug = false; @@ -5530,16 +5531,15 @@ fill_insns (fence_t fence, int seqno, ilist_t **scheduled_insns_tailpp) do { expr_vliw = find_best_expr (&av_vliw, bnds, fence, &need_stall); - if (!expr_vliw && need_stall) + if (! expr_vliw && need_stall) { /* All expressions required a stall. Do not recompute av sets as we'll get the same answer (modulo the insns between the fence and its boundary, which will not be available for - pipelining). */ - gcc_assert (! expr_vliw && stall_iterations < 2); - was_stall++; - /* If we are going to stall for too long, break to recompute av + pipelining). + If we are going to stall for too long, break to recompute av sets and bring more insns for pipelining. */ + was_stall++; if (need_stall <= 3) stall_for_cycles (fence, need_stall); else @@ -6712,6 +6712,8 @@ init_seqno_1 (basic_block bb, sbitmap visited_bbs, bitmap blocks_to_reschedule) init_seqno_1 (succ, visited_bbs, blocks_to_reschedule); } + else if (blocks_to_reschedule) + bitmap_set_bit (forced_ebb_heads, succ->index); } for (insn = BB_END (bb); insn != note; insn = PREV_INSN (insn)) @@ -6966,6 +6968,7 @@ reset_sched_cycles_in_current_ebb (void) int last_clock = 0; int haifa_last_clock = -1; int haifa_clock = 0; + int issued_insns = 0; insn_t insn; if (targetm.sched.init) @@ -7020,7 +7023,9 @@ reset_sched_cycles_in_current_ebb (void) haifa_cost = cost; after_stall = 1; } - + if (haifa_cost == 0 + && issued_insns == issue_rate) + haifa_cost = 1; if (haifa_cost > 0) { int i = 0; @@ -7028,6 +7033,7 @@ reset_sched_cycles_in_current_ebb (void) while (haifa_cost--) { advance_state (curr_state); + issued_insns = 0; i++; if (sched_verbose >= 2) @@ -7047,6 +7053,8 @@ reset_sched_cycles_in_current_ebb (void) } haifa_clock += i; + if (sched_verbose >= 2) + sel_print ("haifa clock: %d\n", haifa_clock); } else gcc_assert (haifa_cost == 0); @@ -7060,21 +7068,27 @@ reset_sched_cycles_in_current_ebb (void) &sort_p)) { advance_state (curr_state); + issued_insns = 0; haifa_clock++; if (sched_verbose >= 2) { sel_print ("advance_state (dfa_new_cycle)\n"); debug_state (curr_state); + sel_print ("haifa clock: %d\n", haifa_clock + 1); } } if (real_insn) { cost = state_transition (curr_state, insn); + issued_insns++; if (sched_verbose >= 2) - debug_state (curr_state); - + { + sel_print ("scheduled insn %d, clock %d\n", INSN_UID (insn), + haifa_clock + 1); + debug_state (curr_state); + } gcc_assert (cost < 0); } @@ -7518,7 +7532,7 @@ sel_sched_region_1 (void) continue; } - if (bitmap_clear_bit (blocks_to_reschedule, bb->index)) + if (bitmap_bit_p (blocks_to_reschedule, bb->index)) { flist_tail_init (new_fences); diff --git a/gcc/target.def b/gcc/target.def index 7947961bf9e..66006aee9f9 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -200,6 +200,14 @@ DEFHOOKPOD be called afterward.", bool, true) +/* Generate an internal label. + For now this is just a wrapper for ASM_GENERATE_INTERNAL_LABEL. */ +DEFHOOK_UNDOC +(generate_internal_label, + "", + void, (char *buf, const char *prefix, unsigned long labelno), + default_generate_internal_label) + /* Output an internal label. */ DEFHOOK (internal_label, @@ -2648,10 +2656,40 @@ DEFHOOK bool, (size_t code, const char *arg, int value), default_handle_c_option) -DEFHOOK -(objc_construct_string, - "Construct a constant string representation for @var{string}", +/* Targets may provide a string object type that can be used within + and between C, C++, and Objective-C dialects. */ + +DEFHOOK +(objc_construct_string_object, + "Targets may provide a string object type that can be used within\ + and between C, C++ and their respective Objective-C dialects.\ + A string object might, for example, embed encoding and length information.\ + These objects are considered opaque to the compiler and handled as references.\ + An ideal implementation makes the composition of the string object\ + match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep),\ + allowing efficient interworking between C-only and Objective-C code.\ + If a target implements string objects then this hook should return a\ + reference to such an object constructed from the normal `C' string\ + representation provided in @var{string}.\ + At present, the hook is used by Objective-C only, to obtain a\ + common-format string object when the target provides one.", tree, (tree string), NULL) + +DEFHOOK +(string_object_ref_type_p, + "If a target implements string objects then this hook should return\ + @code{true} if @var{stringref} is a valid reference to such an object.", + bool, (const_tree stringref), + hook_bool_const_tree_false) +DEFHOOK +(check_string_object_format_arg, + "If a target implements string objects then this hook should should\ + provide a facility to check the function arguments in @var{args_list}\ + against the format specifiers in @var{format_arg} where the type of\ + @var{format_arg} is one recognized as a valid string reference type.", + void, (tree format_arg, tree args_list), + NULL) + HOOK_VECTOR_END (C90_EMPTY_HACK) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fda07c36ac0..7d2688e3547 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,220 @@ +2010-11-08 Jason Merrill <jason@redhat.com> + + * g++.dg/expr/overflow1.C: New. + * g++.dg/warn/overflow-warn-1.C: Add expected diagnostics. + * g++.dg/warn/overflow-warn-3.C: Remove unnecessary line number. + * g++.dg/warn/overflow-warn-4.C: Add expected diagnostics. + * g++.dg/warn/overflow-warn-5.C: Don't expect wrong warning. + +2010-11-08 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + * gcc.dg/pr35442.c: Adapt warning. + + PR target/46280 + * g++.dg/eh/simd-2.C: Add -msse to dg-options, add + dg-require-effective-target sse_runtime for for i?86-*-*, x86_64-*-*. + * g++.dg/torture/pr36444.C: Add dg-options -msse for + i?86-*-* x86_64-*-*. + * g++.dg/torture/pr36445.C: Likewise. + * gcc.c-torture/compile/pr34856.c: Likewise. + * gcc.c-torture/compile/pr39928-1.c: Likewise. + * gcc.c-torture/compile/vector-1.c: Likewise. + * gcc.c-torture/compile/vector-2.c: Likewise. + * gcc.dg/pr32912-1.c: Likewise. + * gcc.c-torture/execute/va-arg-25.c: Move ... + * gcc.dg/torture/va-arg-25.c: ... here. + Add dg-do run. + Add dg-options -msse, dg-require-effective-target sse_runtime for + for i?86-*-*, x86_64-*-*. + * gcc.c-torture/execute/vector-1.c: Likewise. + * gcc.c-torture/execute/vector-2.c: Likewise. + * gcc.dg/tree-ssa/forwprop-5.c: Add -msse to dg-options for + i?86-*-*, x86_64-*-*. + * gcc.dg/tree-ssa/fre-vce-1.c: Likewise. + * gcc.dg/tree-ssa/sra-4.c: Likewise. + * gcc.dg/tree-ssa/vector-1.c: Likewise. + * gcc.dg/tree-ssa/vector-2.c: Likewise. + * gcc.target/i386/vect-args.c: Add -Wno-psabi to dg-options. + +2010-11-08 Steve Ellcey <sje@cup.hp.com> + + * gcc.dg/torture/pr45982.c: Add -std=c99 + * gcc.dg/torture/pr45623.c: Ditto. + +2010-11-08 Steve Ellcey <sje@cup.hp.com> + + * gcc/testsuite/g++.dg/abi/covariant1.C: Fix scan-assembler. + * gcc/testsuite/g++.dg/abi/covariant6.C: Ditto. + +2010-11-08 Kai Tietz <kai.tietz@onevision.com> + + PR target/28627 + * g++.dg/ext/dllimport7.C: Adjust second error check and + allow test for x86_64 mingw, too. + +2010-11-08 Janus Weil <janus@gcc.gnu.org> + + PR fortran/46344 + * gfortran.dg/class_28.f03: New. + +2010-11-08 Andrey Belevantsev <abel@ispras.ru> + + PR rtl-optimization/45352 + gcc.dg/pr45352.c, gcc.dg/pr45352-1.c, gcc.dg/pr45352-2.c: New tests. + gcc.target/i386/pr45352.c, gcc.target/i386/pr45352-1.c, + gcc.target/i386/pr45352-2.c: New tests. + +2010-11-06 Iain Sandoe <iains@gcc.gnu.org> + + PR libobjc/36610 + * objc.dg/torture/forward-1.m: Re-enable for gnu-runtime, XFAIL the run for + all but m32 x86. + +2010-11-07 Andreas Schwab <schwab@linux-m68k.org> + + * g++.dg/debug/dwarf2/nested-2.C: Adjust pattern to also match "|" + as comment character. + +2010-11-07 Richard Sandiford <rdsandiford@googlemail.com> + + * gcc.target/mips/mips.exp: Revert previous patch. + * gcc.target/mips/fma-1.c: Delete. + * gcc.target/mips/fma-2.c: Likewise. + * gcc.target/mips/fma-3.c: Likewise. + * gcc.target/mips/fma-4.c: Likewise. + * gcc.target/mips/fma-5.c: Likewise. + * gcc.target/mips/fma-6.c: Likewise. + * gcc.target/mips/fma-7.c: Likewise. + * gcc.target/mips/fma-8.c: Likewise. + * gcc.target/mips/fma-9.c: Likewise. + * gcc.target/mips/fma-10.c: Likewise. + * gcc.target/mips/fma-11.c: Likewise. + * gcc.target/mips/fma-12.c: Likewise. + * gcc.target/mips/fma-13.c: Likewise. + * gcc.target/mips/fma-14.c: Likewise. + * gcc.target/mips/fma-15.c: Likewise. + * gcc.target/mips/fma-16.c: Likewise. + * gcc.target/mips/fma-17.c: Likewise. + * gcc.target/mips/fma-18.c: Likewise. + * gcc.target/mips/fma-19.c: Likewise. + * gcc.target/mips/fma-20.c: Likewise. + +2010-11-07 Richard Sandiford <rdsandiford@googlemail.com> + + * gcc.target/mips/mips.exp: Add support for -ffp-contract. + * gcc.target/mips/fma-1.c: New test. + * gcc.target/mips/fma-2.c: Likewise. + * gcc.target/mips/fma-3.c: Likewise. + * gcc.target/mips/fma-4.c: Likewise. + * gcc.target/mips/fma-5.c: Likewise. + * gcc.target/mips/fma-6.c: Likewise. + * gcc.target/mips/fma-7.c: Likewise. + * gcc.target/mips/fma-8.c: Likewise. + * gcc.target/mips/fma-9.c: Likewise. + * gcc.target/mips/fma-10.c: Likewise. + * gcc.target/mips/fma-11.c: Likewise. + * gcc.target/mips/fma-12.c: Likewise. + * gcc.target/mips/fma-13.c: Likewise. + * gcc.target/mips/fma-14.c: Likewise. + * gcc.target/mips/fma-15.c: Likewise. + * gcc.target/mips/fma-16.c: Likewise. + * gcc.target/mips/fma-17.c: Likewise. + * gcc.target/mips/fma-18.c: Likewise. + * gcc.target/mips/fma-19.c: Likewise. + * gcc.target/mips/fma-20.c: Likewise. + +2010-11-06 Jason Merrill <jason@redhat.com> + + * g++.dg/cpp0x/constexpr-ctor3.C: New. + +2010-11-06 Simon Martin <simartin@users.sourceforge.net> + + PR c/43384 + * gcc.dg/parser-error-3.c: New test. + +2010-11-06 Nathan Froyd <froydnj@codesourcery.com> + + PR c++/45332 + * g++.dg/parse/semicolon2.C: New testcase. + * g++.dg/ext/asmspec1.C: Adjust. + * g++.dg/init/new13.C: Adjust. + * g++.dg/parse/ctor5.C: Adjust. + +2010-11-06 Janus Weil <janus@gcc.gnu.org> + + PR fortran/46330 + * gfortran.dg/class_27.f03: New. + +2010-11-06 Nicola Pero <nicola.pero@meta-innovation.com> + + Fixed using the Objective-C 2.0 dot-syntax with self and super. + * objc.dg/property/dotsyntax-5.m: New. + * objc.dg/property/dotsyntax-6.m: New. + * objc.dg/property/dotsyntax-7.m: New. + * objc.dg/property/dotsyntax-8.m: New. + * objc.dg/property/dotsyntax-9.m: New. + * objc.dg/property/dotsyntax-10.m: New. + * objc.dg/property/dotsyntax-11.m: New. + * obj-c++.dg/property/dotsyntax-5.mm: New. + * obj-c++.dg/property/dotsyntax-6.mm: New. + * obj-c++.dg/property/dotsyntax-7.mm: New. + * obj-c++.dg/property/dotsyntax-8.mm: New. + * obj-c++.dg/property/dotsyntax-9.mm: New. + * obj-c++.dg/property/dotsyntax-10.mm: New. + * obj-c++.dg/property/dotsyntax-11.mm: New. + +2010-11-06 Iain Sandoe <iains@gcc.gnu.org> + + * obj-c++.dg/encode-3.mm: Provide a different string check for the + NeXT runtime when the type is READONLY. + +2010-11-06 Uros Bizjak <ubizjak@gmail.com> + + * gcc.target/i386/387-2.c: Skip if -march= is specified. + * gcc.target/i386/387-6.c: Ditto. + * gcc.target/i386/387-3.c: Add -mfancy-math-387 to dg-options. + * gcc.target/i386/387-4.c: Ditto. + * gcc.target/i386/387-7.c: Ditto. + * gcc.target/i386/387-8.c: Ditto. + * gcc.target/i386/387-9.c: Ditto. + * gcc.target/i386/387-10.c: Ditto. + * gcc.target/i386/387-11.c: Ditto. + * gcc.target/i386/387-12.c: Ditto. + + * gcc.target/i386/funcspec-8.c: Add -mno-sse3 to dg-options. + +2010-11-06 Iain Sandoe <iains@gcc.gnu.org> + + PR target/44981 + * gcc.dg/darwin-cfstring-format-1.c: New. + * gcc.dg/warn-nsstring.c: New. + * objc.dg/fsf-nsstring-format-1.m: New. + * obj-c++.dg/fsf-nsstring-format-1.mm: New. + * obj-c++.dg/torture/strings/const-cfstring-1.mm: Update for darwin10 + linker warning. + +2010-11-05 Jason Merrill <jason@redhat.com> + + PR c++/45473 + * g++.dg/inherit/virtual6.C: New. + +2010-11-05 Jakub Jelinek <jakub@redhat.com> + + PR c/44772 + * gcc.dg/Wcxx-compat-21.c: New test. + +2010-11-05 Ian Lance Taylor <iant@google.com> + + PR target/46084 + * gcc.target/i386/pr46084.c: New test. + +2010-11-05 Steve Ellcey <sje@cup.hp.com> + + * lib/target-supports.exp (check_function_available): Use -fno-builtin. + * (check_effective_target_mempcpy): New. + * gcc.c-torture/execute/pr45636.c: Move this... + * gcc.dg/torture/pr45636.c: to here. Add add dg- directives. + 2010-11-05 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> * gcc.target/i386/i386.exp (FLAGS): Remove. @@ -72,8 +289,7 @@ 2010-11-04 Bud Davis <jimmied@smu.edu> - * gfortran.dg/intrinsic_numeric_arg.f: Add test to check - error message. + * gfortran.dg/intrinsic_numeric_arg.f: Add test to check error message. 2010-11-04 Chao-ying Fu <fu@mips.com> diff --git a/gcc/testsuite/g++.dg/abi/covariant1.C b/gcc/testsuite/g++.dg/abi/covariant1.C index ae8c5e603da..97737ddb94c 100644 --- a/gcc/testsuite/g++.dg/abi/covariant1.C +++ b/gcc/testsuite/g++.dg/abi/covariant1.C @@ -20,7 +20,7 @@ struct c14 : void c14::f() { } -// { dg-final { scan-assembler "_ZTcv0_n12_v0_n16_N3c143f17Ev" { target ilp32 } } } +// { dg-final { scan-assembler "_ZTcv0_n12_v0_n16_N3c143f17Ev" { target { ilp32 && { ! { ia64-*-hpux* } } } } } } // { dg-final { scan-assembler-not "_ZTch0_v0_n16_N3c143f17Ev" } } -// { dg-final { scan-assembler "_ZTcv0_n24_v0_n32_N3c143f17Ev" { target lp64 } } } +// { dg-final { scan-assembler "_ZTcv0_n24_v0_n32_N3c143f17Ev" { target { lp64 || { ia64-*-hpux* } } } } } // { dg-final { scan-assembler-not "_ZTch0_v0_n32_N3c143f17Ev" } } diff --git a/gcc/testsuite/g++.dg/abi/covariant6.C b/gcc/testsuite/g++.dg/abi/covariant6.C index 9dfc5ba74ab..143b4ad36cb 100644 --- a/gcc/testsuite/g++.dg/abi/covariant6.C +++ b/gcc/testsuite/g++.dg/abi/covariant6.C @@ -16,10 +16,10 @@ struct C: B C* C::f() { return 0; } // When we emit C::f, we should emit both thunks: one for B and one for A. -// { dg-final { scan-assembler "_ZTch0_v0_n16_N1C1fEv" { target ilp32 } } } -// { dg-final { scan-assembler "_ZTch0_v0_n32_N1C1fEv" { target lp64 } } } -// { dg-final { scan-assembler "_ZTcv0_n12_v0_n16_N1C1fEv" { target ilp32 } } } -// { dg-final { scan-assembler "_ZTcv0_n24_v0_n32_N1C1fEv" { target lp64 } } } +// { dg-final { scan-assembler "_ZTch0_v0_n16_N1C1fEv" { target { ilp32 && { ! { ia64-*-hpux* } } } } } } +// { dg-final { scan-assembler "_ZTch0_v0_n32_N1C1fEv" { target { lp64 || { ia64-*-hpux* } } } } } +// { dg-final { scan-assembler "_ZTcv0_n12_v0_n16_N1C1fEv" { target { ilp32 && { ! { ia64-*-hpux* } } } } } } +// { dg-final { scan-assembler "_ZTcv0_n24_v0_n32_N1C1fEv" { target { lp64 || { ia64-*-hpux* } } } } } struct D: B { @@ -30,5 +30,5 @@ struct D: B void D::dummy() { } // When we emit the D vtable, it should refer to the thunk for B. -// { dg-final { scan-assembler "_ZTch0_v0_n16_N1D1fEv" { target ilp32 } } } -// { dg-final { scan-assembler "_ZTch0_v0_n32_N1D1fEv" { target lp64 } } } +// { dg-final { scan-assembler "_ZTch0_v0_n16_N1D1fEv" { target { ilp32 && { ! { ia64-*-hpux* } } } } } } +// { dg-final { scan-assembler "_ZTch0_v0_n32_N1D1fEv" { target { lp64 || { ia64-*-hpux* } } } } } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor3.C new file mode 100644 index 00000000000..d5bfbad3d67 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor3.C @@ -0,0 +1,10 @@ +// PR c++/46348 +// { dg-options -std=c++0x } + +struct A +{ + int arr[1]; + + constexpr A() + : arr() { } +}; diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/nested-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/nested-2.C index 65d382be4f9..5297a4e2b28 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/nested-2.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/nested-2.C @@ -32,6 +32,6 @@ We want to express that the DIE of S::T<int> must be a child of the DIE of S, li Hence the slightly odd regexp: - { dg-final { scan-assembler "\[^\n\r\]*\\(DIE\[^\n\r\]*DW_TAG_structure_type\\)\[\n\r\]+\[^\n\r\]*\"S\\\\0\"\[ \t\]+\(@|#|!|//?\)\[ \t\]+DW_AT_name\[\n\r\]+\(.*\)?\\(DIE\[^\n\r\]*DW_TAG_structure_type\\)\[\n\r\]+\[^\n\r\]*\"T<int>\\\\0\"\[ \t\]+\(.*\)?\\(DIE\[^\n\r\]*DW_TAG_template_type_param\\)\[\n\r\]+\[^\n\r\]*\[\n\r\]+\[^\n\r\]*\[\n\r\]+\[^\n\r\]*\(@|#|!|//?\)\[ \t\]+end of children of DIE\[^\n\r\]*\[\n\r\]+\[^\n\r\]*end of children of DIE\[^\n\r\]*" } } + { dg-final { scan-assembler "\[^\n\r\]*\\(DIE\[^\n\r\]*DW_TAG_structure_type\\)\[\n\r\]+\[^\n\r\]*\"S\\\\0\"\[ \t\]+\(\[@|#!\]|//?\)\[ \t\]+DW_AT_name\[\n\r\]+\(.*\)?\\(DIE\[^\n\r\]*DW_TAG_structure_type\\)\[\n\r\]+\[^\n\r\]*\"T<int>\\\\0\"\[ \t\]+\(.*\)?\\(DIE\[^\n\r\]*DW_TAG_template_type_param\\)\[\n\r\]+\[^\n\r\]*\[\n\r\]+\[^\n\r\]*\[\n\r\]+\[^\n\r\]*\(\[@|#!\]|//?\)\[ \t\]+end of children of DIE\[^\n\r\]*\[\n\r\]+\[^\n\r\]*end of children of DIE\[^\n\r\]*" } } */ diff --git a/gcc/testsuite/g++.dg/eh/simd-2.C b/gcc/testsuite/g++.dg/eh/simd-2.C index da7ef495120..2761061c178 100644 --- a/gcc/testsuite/g++.dg/eh/simd-2.C +++ b/gcc/testsuite/g++.dg/eh/simd-2.C @@ -1,10 +1,11 @@ // Test EH when V4SI SIMD registers are involved. // Contributed by Aldy Hernandez (aldy@quesejoda.com). // { dg-options "-O -Wno-abi" } -// { dg-options "-O -w" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } +// { dg-options "-O -w -msse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } // { dg-options "-O -w" { target powerpc*-*-* } } // { dg-options "-O -w -maltivec" { target { powerpc*-*-* && vmx_hw } } } // { dg-do run } +// { dg-require-effective-target sse_runtime { target { { i?86-*-* x86_64-*-* } && ilp32 } } } #include "check-vect.h" diff --git a/gcc/testsuite/g++.dg/expr/overflow1.C b/gcc/testsuite/g++.dg/expr/overflow1.C new file mode 100644 index 00000000000..b67b4e42edd --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/overflow1.C @@ -0,0 +1,8 @@ +#include <limits.h> + +enum E { + A = (unsigned char)-1, /* OK */ + B = (signed char)UCHAR_MAX, /* implementation-defined */ + C = INT_MAX+1, /* undefined (C)/ill-formed (C++) { dg-message "" } */ + D = UINT_MAX+1 /* OK */ +}; diff --git a/gcc/testsuite/g++.dg/ext/asmspec1.C b/gcc/testsuite/g++.dg/ext/asmspec1.C index 3df2483ad53..0661136fecc 100644 --- a/gcc/testsuite/g++.dg/ext/asmspec1.C +++ b/gcc/testsuite/g++.dg/ext/asmspec1.C @@ -3,6 +3,6 @@ struct A { - int i __asm__(int); // { dg-error "before" } - static int j __asm__(int); // { dg-error "before" } + int i __asm__(int); // { dg-error "expected" } + static int j __asm__(int); // { dg-error "expected" } }; diff --git a/gcc/testsuite/g++.dg/ext/dllimport7.C b/gcc/testsuite/g++.dg/ext/dllimport7.C index 8bf384889b5..0a79b3da33c 100644 --- a/gcc/testsuite/g++.dg/ext/dllimport7.C +++ b/gcc/testsuite/g++.dg/ext/dllimport7.C @@ -1,4 +1,4 @@ -// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} } +// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw* x86_64-*-mingw* } } // Report errors on definition of dllimport'd static data member . @@ -19,12 +19,9 @@ class __declspec(dllimport) Bar }; const int Bar::three = 3; // { dg-warning "redeclared without dllimport" } -// { dg-error "definition of static data" "C++ specific error" { target i?86-*-cygwin* i?86-*-mingw* } 21 } +// { dg-error "definition of static data" "C++ specific error" { target i?86-*-cygwin* i?86-*-mingw* x86_64-*-mingw* } 21 } const Baz Bar::null_baz; // { dg-warning "redeclared without dllimport" } -// { dg-error "definition of static data" "C++ specific error" { target i?86-*-cygwin* i?86-*-mingw* } 24 } - - int foo() { diff --git a/gcc/testsuite/g++.dg/inherit/virtual6.C b/gcc/testsuite/g++.dg/inherit/virtual6.C new file mode 100644 index 00000000000..f0369699321 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/virtual6.C @@ -0,0 +1,15 @@ +// PR c++/45473 + +struct A +{ + virtual void B (); +}; + +struct B : A +{ + B (); +}; + +struct C : B +{ +}; diff --git a/gcc/testsuite/g++.dg/init/new13.C b/gcc/testsuite/g++.dg/init/new13.C index 3563c48808f..2ced6e3fe02 100644 --- a/gcc/testsuite/g++.dg/init/new13.C +++ b/gcc/testsuite/g++.dg/init/new13.C @@ -5,7 +5,7 @@ struct A { - void* operator new(__SIZE_TYPE__) throw(X); // { dg-error "" } + void* operator new(__SIZE_TYPE__) throw(X); // { dg-error "expected|type" } }; -A* p = new A; // { dg-error "no suitable" } +A* p = new A; diff --git a/gcc/testsuite/g++.dg/parse/ctor5.C b/gcc/testsuite/g++.dg/parse/ctor5.C index 819458598a3..3ea23549c0b 100644 --- a/gcc/testsuite/g++.dg/parse/ctor5.C +++ b/gcc/testsuite/g++.dg/parse/ctor5.C @@ -2,9 +2,9 @@ struct A { - int i; - A() i() {} // { dg-error "expected" } -}; // { dg-error "expected" } + int i; // { dg-error "conflicts" } + A() i() {} // { dg-error "declaration" } +}; struct B { diff --git a/gcc/testsuite/g++.dg/parse/semicolon2.C b/gcc/testsuite/g++.dg/parse/semicolon2.C new file mode 100644 index 00000000000..d14a225a674 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/semicolon2.C @@ -0,0 +1,9 @@ +// PR c++/45332 +// { dg-do compile } + +class C +{ + int x // { dg-error "at end of member declaration" } + + const int foo() { return x; } +}; diff --git a/gcc/testsuite/g++.dg/torture/pr36444.C b/gcc/testsuite/g++.dg/torture/pr36444.C index fd20bde3d47..ae639e25d2c 100644 --- a/gcc/testsuite/g++.dg/torture/pr36444.C +++ b/gcc/testsuite/g++.dg/torture/pr36444.C @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ #define vector __attribute__((vector_size(16) )) struct struct1 { union {} vmx; diff --git a/gcc/testsuite/g++.dg/torture/pr36445.C b/gcc/testsuite/g++.dg/torture/pr36445.C index 39a7a553afd..56642e9ec73 100644 --- a/gcc/testsuite/g++.dg/torture/pr36445.C +++ b/gcc/testsuite/g++.dg/torture/pr36445.C @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ // This used to fail as we would try to expand a VCE where one side had // a mode of BLKmode and the other side was a vector mode. #define vector __attribute__((vector_size(16) )) diff --git a/gcc/testsuite/g++.dg/warn/overflow-warn-1.C b/gcc/testsuite/g++.dg/warn/overflow-warn-1.C index 17bd06783dc..22c512a4f8f 100644 --- a/gcc/testsuite/g++.dg/warn/overflow-warn-1.C +++ b/gcc/testsuite/g++.dg/warn/overflow-warn-1.C @@ -1,7 +1,7 @@ /* Test for diagnostics for constant overflow. */ /* Origin: Joseph Myers <joseph@codesourcery.com> */ /* { dg-do compile } */ -/* { dg-options "" } */ +/* { dg-options "-fpermissive" } */ #include <limits.h> @@ -19,8 +19,10 @@ enum e { E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */ /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { xfail *-*-* } 19 } */ E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */ + /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 21 } */ /* Again, overflow in evaluated subexpression. */ E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */ + /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 24 } */ /* A cast does not constitute overflow in conversion. */ E7 = (char) INT_MAX }; @@ -29,6 +31,7 @@ struct s { int a; int : 0 * (1 / 0); /* { dg-warning "division by zero" } */ int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ + /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 33 } */ }; void @@ -49,10 +52,10 @@ void *n = 0; constants. The third has the overflow in an unevaluated subexpression, so is a null pointer constant. */ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ -/* { dg-error "invalid conversion from 'int' to 'void" "null" { target *-*-* } 51 } */ +/* { dg-warning "invalid conversion from 'int' to 'void" "null" { target *-*-* } 54 } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ -/* { dg-error "invalid conversion from 'int' to 'void*'" "null" { xfail *-*-* } 53 } */ -void *r = (1 ? 0 : INT_MAX+1); /* { dg-bogus "integer overflow in expression" "" { xfail *-*-* } 55 } */ +/* { dg-error "invalid conversion from 'int' to 'void*'" "null" { xfail *-*-* } 56 } */ +void *r = (1 ? 0 : INT_MAX+1); /* { dg-bogus "integer overflow in expression" "" { xfail *-*-* } } */ void g (int i) @@ -62,6 +65,7 @@ g (int i) case 0 * (1/0): /* { dg-warning "division by zero" } */ ; case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */ + /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 67 } */ ; } } diff --git a/gcc/testsuite/g++.dg/warn/overflow-warn-3.C b/gcc/testsuite/g++.dg/warn/overflow-warn-3.C index ce03a9781e4..d88c87a5398 100644 --- a/gcc/testsuite/g++.dg/warn/overflow-warn-3.C +++ b/gcc/testsuite/g++.dg/warn/overflow-warn-3.C @@ -57,7 +57,7 @@ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ /* { dg-warning "invalid conversion from 'int' to 'void*'" "null" { xfail *-*-* } 58 } */ -void *r = (1 ? 0 : INT_MAX+1); /* { dg-bogus "integer overflow in expression" "" { xfail *-*-* } 60 } */ +void *r = (1 ? 0 : INT_MAX+1); /* { dg-bogus "integer overflow in expression" "" { xfail *-*-* } } */ void g (int i) diff --git a/gcc/testsuite/g++.dg/warn/overflow-warn-4.C b/gcc/testsuite/g++.dg/warn/overflow-warn-4.C index 0c916d0929c..374d29428a8 100644 --- a/gcc/testsuite/g++.dg/warn/overflow-warn-4.C +++ b/gcc/testsuite/g++.dg/warn/overflow-warn-4.C @@ -11,7 +11,7 @@ enum e { E1 = UINT_MAX + 1, /* Overflow in an unevaluated part of an expression is OK (example in the standard). */ - E2 = 2 || 1 / 0, /* { dg-bogus "warning: division by zero" "" { xfail *-*-* } 14 } */ + E2 = 2 || 1 / 0, /* { dg-bogus "warning: division by zero" "" { xfail *-*-* } } */ E3 = 1 / 0, /* { dg-warning "division by zero" } */ /* { dg-error "enumerator value for 'E3' is not an integer constant|not a constant expression" "enum error" { target *-*-* } 15 } */ /* But as in DR#031, the 1/0 in an evaluated subexpression means the @@ -20,9 +20,11 @@ enum e { /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { xfail *-*-* } 19 } */ E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 21 } */ + /* { dg-error "enumerator value for 'E5' is not an integer constant" "enum error" { target *-*-* } 21 } */ /* Again, overflow in evaluated subexpression. */ E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */ - /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 24 } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 25 } */ + /* { dg-error "enumerator value for 'E6' is not an integer constant" "enum error" { target *-*-* } 25 } */ /* A cast does not constitute overflow in conversion. */ E7 = (char) INT_MAX }; @@ -31,7 +33,8 @@ struct s { int a; int : 0 * (1 / 0); /* { dg-warning "division by zero" } */ int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ - /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 33 } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 35 } */ + /* { dg-error "bit-field .* width not an integer constant" "" { target *-*-* } 35 } */ }; void @@ -53,11 +56,11 @@ void *n = 0; constants. The third has the overflow in an unevaluated subexpression, so is a null pointer constant. */ void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ -/* { dg-error "invalid conversion from 'int' to 'void" "null" { target *-*-* } 55 } */ +/* { dg-error "invalid conversion from 'int' to 'void" "null" { target *-*-* } 58 } */ void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ -/* { dg-error "invalid conversion from 'int' to 'void*'" "null" { xfail *-*-* } 58 } */ -void *r = (1 ? 0 : INT_MAX+1); /* { dg-bogus "integer overflow in expression" "" { xfail *-*-* } 60 } */ +/* { dg-error "invalid conversion from 'int' to 'void*'" "null" { xfail *-*-* } 61 } */ +void *r = (1 ? 0 : INT_MAX+1); /* { dg-bogus "integer overflow in expression" "" { xfail *-*-* } } */ void g (int i) @@ -67,7 +70,7 @@ g (int i) case 0 * (1/0): /* { dg-warning "division by zero" } */ ; case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */ - /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 69 } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 72 } */ ; } } diff --git a/gcc/testsuite/g++.dg/warn/overflow-warn-5.C b/gcc/testsuite/g++.dg/warn/overflow-warn-5.C index 472d4a7cab1..bdfec4a6be1 100644 --- a/gcc/testsuite/g++.dg/warn/overflow-warn-5.C +++ b/gcc/testsuite/g++.dg/warn/overflow-warn-5.C @@ -1,7 +1,11 @@ /* PR c/27273 */ /* { dg-do compile } */ -/* { dg-options "-Woverflow" } */ + +// This used to warn about "overflow in implicit constant conversion", +// which was wrong; 512 is never converted to unsigned char. Rather, an +// appropriate warning would be that the & expression always evaluates to 0 +// because of the limited range of unsigned char. unsigned char rx_async(unsigned char p) { - return p & 512; /* { dg-warning "overflow in implicit constant conversion" } */ + return p & 512; /* { dg-warning "" "" { xfail *-*-* } } */ } diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34856.c b/gcc/testsuite/gcc.c-torture/compile/pr34856.c index a2f43690990..7b0d5962a60 100644 --- a/gcc/testsuite/gcc.c-torture/compile/pr34856.c +++ b/gcc/testsuite/gcc.c-torture/compile/pr34856.c @@ -1,3 +1,4 @@ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ #undef __vector #define __vector __attribute__((vector_size(16) )) typedef __vector signed char qword; diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39928-1.c b/gcc/testsuite/gcc.c-torture/compile/pr39928-1.c index 3bee4380e5b..1abb5ccb505 100644 --- a/gcc/testsuite/gcc.c-torture/compile/pr39928-1.c +++ b/gcc/testsuite/gcc.c-torture/compile/pr39928-1.c @@ -1,3 +1,4 @@ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__)); extern __m128 _mm_sub_ps (__m128 __A, __m128 __B); extern __m128 _mm_mul_ps (__m128 __A, __m128 __B); diff --git a/gcc/testsuite/gcc.c-torture/compile/vector-1.c b/gcc/testsuite/gcc.c-torture/compile/vector-1.c index d22afd55df5..9be0be19bca 100644 --- a/gcc/testsuite/gcc.c-torture/compile/vector-1.c +++ b/gcc/testsuite/gcc.c-torture/compile/vector-1.c @@ -1,3 +1,4 @@ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ #define vector __attribute__((vector_size(16) )) struct ss { diff --git a/gcc/testsuite/gcc.c-torture/compile/vector-2.c b/gcc/testsuite/gcc.c-torture/compile/vector-2.c index 930a9c1f870..e04d55588e5 100644 --- a/gcc/testsuite/gcc.c-torture/compile/vector-2.c +++ b/gcc/testsuite/gcc.c-torture/compile/vector-2.c @@ -1,3 +1,4 @@ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ #define vector __attribute__((vector_size(16) )) struct ss { diff --git a/gcc/testsuite/gcc.dg/Wcxx-compat-21.c b/gcc/testsuite/gcc.dg/Wcxx-compat-21.c new file mode 100644 index 00000000000..183f0f17980 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wcxx-compat-21.c @@ -0,0 +1,25 @@ +/* PR c/44772 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +typedef enum { E1, E2 } E; + +typedef struct +{ + E e; + union + { + int i; + char *c; + }; /* { dg-bogus "as both field and typedef name" } */ +} S; + +S s; + +typedef int T; + +struct U +{ + T t; + union { int i; }; /* { dg-bogus "as both field and typedef name" } */ +}; diff --git a/gcc/testsuite/gcc.dg/darwin-cfstring-format-1.c b/gcc/testsuite/gcc.dg/darwin-cfstring-format-1.c new file mode 100644 index 00000000000..8771d526fe0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/darwin-cfstring-format-1.c @@ -0,0 +1,36 @@ +/* Check CFString format extensions. */ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-Wall" } */ + +extern int printf (const char *fmt, ...); + +typedef const struct __CFString * CFStringRef; + +#ifdef __CONSTANT_CFSTRINGS__ +#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr "")) +#else +#error requires CFString +#endif + +int s1 (CFStringRef fmt, ...) __attribute__((format(CFString, 1, 2))) ; /* OK */ +int s2 (int a, CFStringRef fmt, ... ) __attribute__((format(__CFString__, 2, 3))) ; /* OK */ + +int s2a (int a, CFStringRef fmt, ... ) __attribute__((format(CFString, 2, 2))) ; /* { dg-error "format string argument follows the args to be formatted" } */ + +int s3 (const char *fmt, ... ) __attribute__((format(__CFString__, 1, 2))) ; /* { dg-error "format argument should be a .CFString. reference but a string was found" } */ +int s4 (CFStringRef fmt, ... ) __attribute__((format(printf, 1, 2))) ; /* { dg-error "found a .CFStringRef. but the format argument should be a string" } */ + +char *s5 (char dum, char *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ +CFStringRef s6 (CFStringRef dum, CFStringRef fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ + +char *s7 (int dum, void *fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "format string argument is not a string type" } */ +int s8 (CFStringRef dum, CFStringRef fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "function does not return string type" } */ + +void foo (void) +{ + CFStringRef notchk = CFSTR ("here is an unchecked %d %s string"); + s1 (notchk, 5, 6, 7); + printf("this one is checked %d %s", 3, 4, 5); /* { dg-warning "format .%s. expects type .char .., but argument 3 has type .int." } */ + /* { dg-warning "too many arguments for format" "" { target *-*-* } 33 } */ + printf(s5 (1, "and so is this %d %d %s", 3, 4, "hey", 6), 5, 6, 12);/* { dg-warning "format .%s. expects type .char .., but argument 4 has type .int." } */ +}
\ No newline at end of file diff --git a/gcc/testsuite/gcc.dg/parse-error-3.c b/gcc/testsuite/gcc.dg/parse-error-3.c new file mode 100644 index 00000000000..1a463b5dd6b --- /dev/null +++ b/gcc/testsuite/gcc.dg/parse-error-3.c @@ -0,0 +1,14 @@ +/* PR c/43384 */ +/* { dg-do "compile" } */ + +void c_direct(par) + void *par = &&lab; /* { dg-error "is initialized|non-standard|outside of" } */ +{} + +void foo(p, q) + int *p = &q; /* { dg-error "initialized|undeclared" } */ +{} + +void bar(i) + int j = i; /* { dg-error "initialized|undeclared|no such parameter" } */ +{} diff --git a/gcc/testsuite/gcc.dg/pr32912-1.c b/gcc/testsuite/gcc.dg/pr32912-1.c index 1ceb77ad43c..4fcc29a9cc8 100644 --- a/gcc/testsuite/gcc.dg/pr32912-1.c +++ b/gcc/testsuite/gcc.dg/pr32912-1.c @@ -2,6 +2,8 @@ /* { dg-do run } */ /* { dg-options "-O2 -w" } */ /* { dg-options "-O2 -w -fno-common" { target hppa*-*-hpux* } } */ +/* { dg-options "-O2 -w -msse" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */ extern void abort (void); diff --git a/gcc/testsuite/gcc.dg/pr35442.c b/gcc/testsuite/gcc.dg/pr35442.c index 875cb0b31b6..206853b9ef0 100644 --- a/gcc/testsuite/gcc.dg/pr35442.c +++ b/gcc/testsuite/gcc.dg/pr35442.c @@ -11,4 +11,4 @@ foo (A a) } /* Ignore a warning that is irrelevant to the purpose of this test. */ -/* { dg-prune-output "(.*GCC vector passed by reference.*|.*ABI of * passing parameter with.*)" } */ +/* { dg-prune-output "(.*GCC vector passed by reference.*|.*ABI for * passing parameters with.*)" } */ diff --git a/gcc/testsuite/gcc.dg/pr45352-1.c b/gcc/testsuite/gcc.dg/pr45352-1.c new file mode 100644 index 00000000000..3b092cd13ed --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr45352-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */ +/* { dg-options "-O3 -fschedule-insns -fschedule-insns2 -fselective-scheduling2 -fsel-sched-pipelining -funroll-loops -fprefetch-loop-arrays" } */ + +void main1 (float *pa, float *pc) +{ + int i; + float b[256]; + float c[256]; + for (i = 0; i < 256; i++) + b[i] = c[i] = pc[i]; + for (i = 0; i < 256; i++) + pa[i] = b[i] * c[i]; +} diff --git a/gcc/testsuite/gcc.dg/pr45352-2.c b/gcc/testsuite/gcc.dg/pr45352-2.c new file mode 100644 index 00000000000..eed3847177c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr45352-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */ +/* { dg-options "-O1 -freorder-blocks -fschedule-insns2 -funswitch-loops -fselective-scheduling2 -fsel-sched-pipelining -funroll-all-loops" } */ +void +foo1 (int *s) +{ + s[0] = s[1]; + while (s[6] - s[8]) + { + s[6] -= s[8]; + if (s[8] || s[0]) + { + s[3] += s[0]; + s[4] += s[1]; + } + s[7]++; + } +} diff --git a/gcc/testsuite/gcc.dg/pr45352.c b/gcc/testsuite/gcc.dg/pr45352.c new file mode 100644 index 00000000000..75f9a213706 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr45352.c @@ -0,0 +1,24 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */ +/* { dg-options "-Os -fselective-scheduling2 -fsel-sched-pipelining -fprofile-generate" } */ + +static inline void +bmp_iter_next (int *bi, int *bit_no) +{ + *bi >>= 1; + *bit_no += 1; +} + +int bmp_iter_set (int *bi, int *bit_no); +void bitmap_initialize_stat (int, ...); +void bitmap_clear (void); + +void +df_md_alloc (int bi, int bb_index, void *bb_info) +{ + for (; bmp_iter_set (&bi, &bb_index); bmp_iter_next (&bi, &bb_index)) + + if (bb_info) + bitmap_clear (); + else + bitmap_initialize_stat (0); +} diff --git a/gcc/testsuite/gcc.dg/torture/pr45623.c b/gcc/testsuite/gcc.dg/torture/pr45623.c index 2f07d2554b5..693a8c4c7be 100644 --- a/gcc/testsuite/gcc.dg/torture/pr45623.c +++ b/gcc/testsuite/gcc.dg/torture/pr45623.c @@ -1,4 +1,5 @@ /* { dg-do run } */ +/* { dg-options "-std=c99" } */ #include <stdint.h> diff --git a/gcc/testsuite/gcc.c-torture/execute/pr45636.c b/gcc/testsuite/gcc.dg/torture/pr45636.c index 031c8037ffc..0566de86e16 100644 --- a/gcc/testsuite/gcc.c-torture/execute/pr45636.c +++ b/gcc/testsuite/gcc.dg/torture/pr45636.c @@ -1,3 +1,5 @@ +/* { dg-do run } */ +/* { dg-require-effective-target mempcpy } */ /* PR fortran/45636 */ typedef __SIZE_TYPE__ size_t; diff --git a/gcc/testsuite/gcc.dg/torture/pr45982.c b/gcc/testsuite/gcc.dg/torture/pr45982.c index 497b0a9807a..4aea6a8d8e4 100644 --- a/gcc/testsuite/gcc.dg/torture/pr45982.c +++ b/gcc/testsuite/gcc.dg/torture/pr45982.c @@ -1,4 +1,5 @@ /* { dg-do run } */ +/* { dg-options "-std=c99" } */ #include <stdint.h> diff --git a/gcc/testsuite/gcc.c-torture/execute/va-arg-25.c b/gcc/testsuite/gcc.dg/torture/va-arg-25.c index b9f3a1b1237..8496460d28c 100644 --- a/gcc/testsuite/gcc.c-torture/execute/va-arg-25.c +++ b/gcc/testsuite/gcc.dg/torture/va-arg-25.c @@ -1,6 +1,11 @@ /* Varargs and vectors! */ +/* { dg-do run } */ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */ + #include <stdarg.h> +#include <stdlib.h> #include <limits.h> #define vector __attribute__((vector_size(16))) diff --git a/gcc/testsuite/gcc.c-torture/execute/vector-1.c b/gcc/testsuite/gcc.dg/torture/vector-1.c index ff21d68ca7b..9ab78aaf53e 100644 --- a/gcc/testsuite/gcc.c-torture/execute/vector-1.c +++ b/gcc/testsuite/gcc.dg/torture/vector-1.c @@ -1,5 +1,9 @@ /* Check that vector extraction works correctly. */ +/* { dg-do run } */ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */ + #define vector __attribute__((vector_size(16) )) int f0(vector int t) diff --git a/gcc/testsuite/gcc.c-torture/execute/vector-2.c b/gcc/testsuite/gcc.dg/torture/vector-2.c index 55330dd6606..bff9f82cdad 100644 --- a/gcc/testsuite/gcc.c-torture/execute/vector-2.c +++ b/gcc/testsuite/gcc.dg/torture/vector-2.c @@ -1,5 +1,9 @@ /* Check that vector insertion works correctly. */ +/* { dg-do run } */ +/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */ + #define vector __attribute__((vector_size(16) )) vector int f0(vector int t, int a) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-5.c b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-5.c index f2ddab2535b..033c60dae0a 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-5.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-5.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O1 -fdump-tree-optimized -w" } */ +/* { dg-options "-O1 -fdump-tree-optimized -w -msse" { target { i?86-*-* x86_64-*-* } } } */ #define vector __attribute__((vector_size(16) )) struct VecClass diff --git a/gcc/testsuite/gcc.dg/tree-ssa/fre-vce-1.c b/gcc/testsuite/gcc.dg/tree-ssa/fre-vce-1.c index 2442b93231a..599d1f1efd5 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/fre-vce-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/fre-vce-1.c @@ -1,4 +1,5 @@ /* { dg-options "-O2 -fdump-tree-fre -w" } */ +/* { dg-options "-O2 -fdump-tree-fre -w -msse" { target { i?86-*-* x86_64-*-* } } } */ /* { dg-do compile } */ #define vector __attribute__((vector_size(sizeof(int)*4) )) struct s { vector int i; }; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/sra-4.c b/gcc/testsuite/gcc.dg/tree-ssa/sra-4.c index 73a68f90043..e6ca7561f7f 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/sra-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/sra-4.c @@ -1,6 +1,7 @@ /* { dg-do compile } */ /* { dg-options "-O1 -fdump-tree-optimized -w" } */ -/* Check that SRA replaces strucutres containing vectors. */ +/* { dg-options "-O1 -fdump-tree-optimized -w -msse" { target { i?86-*-* x86_64-*-* } } } */ +/* Check that SRA replaces structures containing vectors. */ #define vector __attribute__((vector_size(16))) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vector-1.c b/gcc/testsuite/gcc.dg/tree-ssa/vector-1.c index 5b07c67a2c6..6fe0e872bb9 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vector-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vector-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-w -O1 -fdump-tree-gimple" } */ +/* { dg-options "-w -O1 -fdump-tree-gimple -msse" { target { i?86-*-* x86_64-*-* } } } */ /* We should be able to produce a BIT_FIELD_REF for each of these vector access. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vector-2.c b/gcc/testsuite/gcc.dg/tree-ssa/vector-2.c index cb680937a2f..e34532d3faa 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vector-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vector-2.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-w -O1 -fdump-tree-optimized" } */ +/* { dg-options "-w -O1 -fdump-tree-optimized -msse" { target { i?86-*-* x86_64-*-* } } } */ #define vector __attribute__(( vector_size(16) )) diff --git a/gcc/testsuite/gcc.dg/warn-nsstring.c b/gcc/testsuite/gcc.dg/warn-nsstring.c new file mode 100644 index 00000000000..3795fb7376b --- /dev/null +++ b/gcc/testsuite/gcc.dg/warn-nsstring.c @@ -0,0 +1,7 @@ +/* Check that the NSString format extension is rejected in c. */ +/* { dg-do compile } */ + +extern void NSLog (void *fmt, ...) __attribute__((format(__NSString__, 1, 2))); /* { dg-warning "is only allowed in Objective-C dialects" } */ +extern void NSLog1 (void *fmt, ...) __attribute__((format(NSString, 1, 2))); /* { dg-warning "is only allowed in Objective-C dialects" } */ + + diff --git a/gcc/testsuite/gcc.target/i386/387-10.c b/gcc/testsuite/gcc.target/i386/387-10.c index 565f0196e88..0ff1b2a7c7c 100644 --- a/gcc/testsuite/gcc.target/i386/387-10.c +++ b/gcc/testsuite/gcc.target/i386/387-10.c @@ -1,6 +1,6 @@ /* PR tree-optimization/24964 */ /* { dg-do compile } */ -/* { dg-options "-O2 -mfpmath=387" } */ +/* { dg-options "-O2 -mfpmath=387 -mfancy-math-387" } */ double fabs(double x); diff --git a/gcc/testsuite/gcc.target/i386/387-11.c b/gcc/testsuite/gcc.target/i386/387-11.c index 03020f64fde..869f6061c38 100644 --- a/gcc/testsuite/gcc.target/i386/387-11.c +++ b/gcc/testsuite/gcc.target/i386/387-11.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mfpmath=387" } */ +/* { dg-options "-O2 -mfpmath=387 -mfancy-math-387" } */ double foo(double x, double y) { diff --git a/gcc/testsuite/gcc.target/i386/387-12.c b/gcc/testsuite/gcc.target/i386/387-12.c index 6b3ce240540..62c1d483c27 100644 --- a/gcc/testsuite/gcc.target/i386/387-12.c +++ b/gcc/testsuite/gcc.target/i386/387-12.c @@ -1,7 +1,6 @@ /* PR target/26915 */ /* { dg-do compile } */ -/* { dg-require-effective-target ilp32 } */ -/* { dg-options "-O" } */ +/* { dg-options "-O -mfpmath=387 -mfancy-math-387" } */ double testm0(void) { diff --git a/gcc/testsuite/gcc.target/i386/387-2.c b/gcc/testsuite/gcc.target/i386/387-2.c index 5a317efea57..bd6dbcdda99 100644 --- a/gcc/testsuite/gcc.target/i386/387-2.c +++ b/gcc/testsuite/gcc.target/i386/387-2.c @@ -1,6 +1,7 @@ /* Verify that -march overrides -mno-fancy-math-387. */ /* { dg-do compile } */ /* { dg-require-effective-target ilp32 } */ +/* { dg-skip-if "" { i?86-*-* x86_64-*-* } { "-march=*" } { "-march=i686" } } */ /* { dg-options "-O -ffast-math -mfpmath=387 -march=i686 -mno-fancy-math-387" } */ /* { dg-final { scan-assembler "fsin" } } */ /* { dg-final { scan-assembler "fcos" } } */ diff --git a/gcc/testsuite/gcc.target/i386/387-3.c b/gcc/testsuite/gcc.target/i386/387-3.c index ce11faa8f86..d00c7296721 100644 --- a/gcc/testsuite/gcc.target/i386/387-3.c +++ b/gcc/testsuite/gcc.target/i386/387-3.c @@ -1,7 +1,6 @@ /* Verify that 387 mathematical constants are recognized. */ /* { dg-do compile } */ -/* { dg-require-effective-target ilp32 } */ -/* { dg-options "-O2 -march=i686" } */ +/* { dg-options "-O2 -mfpmath=387 -mfancy-math-387" } */ /* { dg-final { scan-assembler "fldpi" } } */ long double add_pi(long double x) diff --git a/gcc/testsuite/gcc.target/i386/387-4.c b/gcc/testsuite/gcc.target/i386/387-4.c index 5617636da56..e4f4a48f2ef 100644 --- a/gcc/testsuite/gcc.target/i386/387-4.c +++ b/gcc/testsuite/gcc.target/i386/387-4.c @@ -1,6 +1,5 @@ /* { dg-do compile } */ -/* { dg-require-effective-target ilp32 } */ -/* { dg-options "-O2 -march=i686" } */ +/* { dg-options "-O2 -mfancy-math-387" } */ /* { dg-final { scan-assembler "fldpi" } } */ long double atanl (long double); diff --git a/gcc/testsuite/gcc.target/i386/387-6.c b/gcc/testsuite/gcc.target/i386/387-6.c index bfef46ae5f5..7b254d1302f 100644 --- a/gcc/testsuite/gcc.target/i386/387-6.c +++ b/gcc/testsuite/gcc.target/i386/387-6.c @@ -1,6 +1,7 @@ /* Verify that -march overrides -mno-fancy-math-387. */ /* { dg-do compile } */ /* { dg-require-effective-target ilp32 } */ +/* { dg-skip-if "" { i?86-*-* x86_64-*-* } { "-march=*" } { "-march=i686" } } */ /* { dg-options "-O -ffast-math -mfpmath=387 -march=i686 -mno-fancy-math-387" } */ /* { dg-final { scan-assembler "fpatan" } } */ /* { dg-final { scan-assembler "fyl2xp1" } } */ diff --git a/gcc/testsuite/gcc.target/i386/387-7.c b/gcc/testsuite/gcc.target/i386/387-7.c index 61c82c95eed..e01ed2e0576 100644 --- a/gcc/testsuite/gcc.target/i386/387-7.c +++ b/gcc/testsuite/gcc.target/i386/387-7.c @@ -1,7 +1,6 @@ /* Verify that 387 fsincos instruction is generated. */ /* { dg-do compile } */ -/* { dg-require-effective-target ilp32 } */ -/* { dg-options "-O -ffast-math -march=i686" } */ +/* { dg-options "-O -ffast-math -mfpmath=387 -mfancy-math-387" } */ /* { dg-final { scan-assembler "fsincos" } } */ extern double sin (double); diff --git a/gcc/testsuite/gcc.target/i386/387-8.c b/gcc/testsuite/gcc.target/i386/387-8.c index 3293f560c25..2dbcd740f62 100644 --- a/gcc/testsuite/gcc.target/i386/387-8.c +++ b/gcc/testsuite/gcc.target/i386/387-8.c @@ -2,8 +2,7 @@ inherent load of 1.0 is used in further calculations. */ /* { dg-do compile } */ -/* { dg-require-effective-target ilp32 } */ -/* { dg-options "-O2 -ffast-math -march=i686" } */ +/* { dg-options "-O2 -ffast-math -mfpmath=387 -mfancy-math-387" } */ /* { dg-final { scan-assembler "fptan" } } */ /* { dg-final { scan-assembler-not "fld1" } } */ diff --git a/gcc/testsuite/gcc.target/i386/387-9.c b/gcc/testsuite/gcc.target/i386/387-9.c index 9d126aff8dd..2667aa46872 100644 --- a/gcc/testsuite/gcc.target/i386/387-9.c +++ b/gcc/testsuite/gcc.target/i386/387-9.c @@ -1,7 +1,6 @@ /* Verify that 387 fsincos instruction is generated. */ /* { dg-do compile } */ -/* { dg-require-effective-target ilp32 } */ -/* { dg-options "-O -funsafe-math-optimizations -march=i686" } */ +/* { dg-options "-O -funsafe-math-optimizations -mfpmath=387 -mfancy-math-387" } */ extern double sin (double); extern double cos (double); diff --git a/gcc/testsuite/gcc.target/i386/funcspec-8.c b/gcc/testsuite/gcc.target/i386/funcspec-8.c index ba4b7f22743..225843493d9 100644 --- a/gcc/testsuite/gcc.target/i386/funcspec-8.c +++ b/gcc/testsuite/gcc.target/i386/funcspec-8.c @@ -2,7 +2,7 @@ functions in functions with the appropriate function specific options. */ /* { dg-do compile } */ /* { dg-skip-if "" { i?86-*-* x86_64-*-* } { "-march=*" } { "-march=k8" } } */ -/* { dg-options "-O2 -march=k8 -mfpmath=sse" } */ +/* { dg-options "-O2 -march=k8 -mno-sse3 -mfpmath=sse" } */ typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__)); typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__)); diff --git a/gcc/testsuite/gcc.target/i386/pr45352-1.c b/gcc/testsuite/gcc.target/i386/pr45352-1.c new file mode 100644 index 00000000000..5cd1bd842d8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr45352-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-mtune=amdfam10 -O3 -fpeel-loops -fselective-scheduling2 -fsel-sched-pipelining -fPIC" } */ + +static int FIR_Tab_16[16][16]; + +void +V_Pass_Avrg_16_C_ref (int *Dst, int *Src, int W, int BpS, int Rnd) +{ + while (W-- > 0) + { + int i, k; + int Sums[16] = { }; + for (i = 0; i < 16; ++i) + for (k = 0; k < 16; ++k) + Sums[k] += FIR_Tab_16[i][k] * Src[i]; + for (i = 0; i < 16; ++i) + Dst[i] = Sums[i] + Src[i]; + } +} diff --git a/gcc/testsuite/gcc.target/i386/pr45352-2.c b/gcc/testsuite/gcc.target/i386/pr45352-2.c new file mode 100644 index 00000000000..58713af869f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr45352-2.c @@ -0,0 +1,108 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -mtune=amdfam10 -fexpensive-optimizations -fgcse -foptimize-register-move -freorder-blocks -fschedule-insns2 -funswitch-loops -fgcse-las -fselective-scheduling2 -fsel-sched-pipelining -funroll-all-loops" } */ + +typedef char uint8_t; +typedef uint32_t; +typedef vo_frame_t; +struct vo_frame_s +{ + uint8_t base[3]; + int pitches[3];}; +typedef struct +{ +void + (*proc_macro_block) + (void); +} +xine_xvmc_t; +typedef struct +{ + uint8_t ref[2][3]; +int pmv; +} +motion_t; +typedef struct +{ + uint32_t bitstream_buf; + int bitstream_bits; + uint8_t * bitstream_ptr; + uint8_t dest[3]; + int pitches[3]; + int offset; + motion_t b_motion; + motion_t f_motion; + int v_offset; + int coded_picture_width; + int picture_structure; +struct vo_frame_s *current_frame;} +picture_t; +typedef struct +{ +int xvmc_last_slice_code;} +mpeg2dec_accel_t; +static bitstream_init (picture_t * picture, void *start) +{ + picture->bitstream_ptr = start; +} +static slice_xvmc_init (picture_t * picture, int code) +{ + int offset; + struct vo_frame_s *forward_reference_frame; + offset = picture->picture_structure == 2; + picture->pitches[0] = picture->current_frame->pitches[0]; + picture->pitches[1] = picture->current_frame->pitches[1]; + if (picture) + picture->f_motion.ref + [0] + [0] + = forward_reference_frame->base + (offset ? picture->pitches[0] : 0); + picture->f_motion.ref[0][1] = (offset); + if (picture->picture_structure) + picture->pitches[0] <<= picture->pitches[1] <<= 1; + offset = 0; + while (1) + { + if (picture->bitstream_buf >= 0x08000000) + break; + switch (picture->bitstream_buf >> 12) + { + case 8: + offset += 33; + picture->bitstream_buf + |= + picture->bitstream_ptr[1] << picture->bitstream_bits; + } + } + picture->offset = (offset); + while (picture->offset - picture->coded_picture_width >= 0) + { + picture->offset -= picture->coded_picture_width; + if (picture->current_frame) + { + picture->dest[0] += picture->pitches[0]; + picture->dest[1] += picture->pitches[1]; + } + picture->v_offset += 16; + } +} + +void +mpeg2_xvmc_slice + (mpeg2dec_accel_t * accel, picture_t * picture, int code, uint8_t buffer,int mba_inc) +{ + xine_xvmc_t * xvmc = bitstream_init (picture, buffer); + slice_xvmc_init (picture, code); + while (1) + { + if (picture) + break; + switch (picture->bitstream_buf) + { + case 8: + mba_inc += accel->xvmc_last_slice_code = code; + xvmc->proc_macro_block (); + while (mba_inc) + ; + } + } +} diff --git a/gcc/testsuite/gcc.target/i386/pr45352.c b/gcc/testsuite/gcc.target/i386/pr45352.c new file mode 100644 index 00000000000..ef710ce6b91 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr45352.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -march=amdfam10 -fselective-scheduling2 -fsel-sched-pipelining -funroll-all-loops" } */ + +struct S +{ + struct + { + int i; + } **p; + int x; + int y; +}; + +extern int baz (void); +extern int bar (void *, int, int); + +void +foo (struct S *s) +{ + int i; + for (i = 0; i < s->x; i++) + bar (s->p[i], baz (), s->y); + for (i = 0; i < s->x; i++) + s->p[i]->i++; +} diff --git a/gcc/testsuite/gcc.target/i386/pr46084.c b/gcc/testsuite/gcc.target/i386/pr46084.c new file mode 100644 index 00000000000..88bcd1ca5e0 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr46084.c @@ -0,0 +1,69 @@ +/* This test needs to use setrlimit to set the stack size, so it can + only run on Unix. */ +/* { dg-do run { target *-*-linux* *-*-solaris* *-*-darwin* } } */ +/* { dg-require-effective-target avx } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack -O2 -mavx" } */ + +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/resource.h> + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf, size_t) __attribute__ ((noinline)); +static void +use_buffer (char *buf, size_t c) +{ + size_t i; + + for (i = 0; i < c; ++i) + buf[i] = (char) i; +} + +/* Each recursive call uses 10 * i bytes. We call it 1000 times, + using a total of 5,000,000 bytes. If -fsplit-stack is not working, + that will overflow our stack limit. */ + +static void +down1 (int i) +{ + char buf[10 * i]; + + if (i > 0) + { + use_buffer (buf, 10 * i); + down1 (i - 1); + } +} + +/* Same thing, using alloca. */ + +static void +down2 (int i) +{ + char *buf = alloca (10 * i); + + if (i > 0) + { + use_buffer (buf, 10 * i); + down2 (i - 1); + } +} + +int +main (void) +{ + struct rlimit r; + + /* We set a stack limit because we are usually invoked via make, and + make sets the stack limit to be as large as possible. */ + r.rlim_cur = 8192 * 1024; + r.rlim_max = 8192 * 1024; + if (setrlimit (RLIMIT_STACK, &r) != 0) + abort (); + down1 (1000); + down2 (1000); + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/vect-args.c b/gcc/testsuite/gcc.target/i386/vect-args.c index 94b602d913a..fc458896ea1 100644 --- a/gcc/testsuite/gcc.target/i386/vect-args.c +++ b/gcc/testsuite/gcc.target/i386/vect-args.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-w" } */ +/* { dg-options "-w -Wno-psabi" } */ /* SSE1 and SSE2 modes. */ typedef unsigned char V16QImode __attribute__((vector_size(16))); diff --git a/gcc/testsuite/gfortran.dg/class_27.f03 b/gcc/testsuite/gfortran.dg/class_27.f03 new file mode 100644 index 00000000000..c3a3c902eae --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_27.f03 @@ -0,0 +1,67 @@ +! { dg-do compile } +! +! PR 46330: [4.6 Regression] [OOP] ICE after revision 166368 +! +! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr> +! Taken from http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/76f99e7fd4f3e772 + +module type2_type + implicit none + type, abstract :: Type2 + end type Type2 +end module type2_type + +module extended2A_type + use type2_type + implicit none + type, extends(Type2) :: Extended2A + real(kind(1.0D0)) :: coeff1 = 1. + contains + procedure :: setCoeff1 => Extended2A_setCoeff1 + end type Extended2A + contains + function Extended2A_new(c1, c2) result(typePtr_) + real(kind(1.0D0)), optional, intent(in) :: c1 + real(kind(1.0D0)), optional, intent(in) :: c2 + type(Extended2A), pointer :: typePtr_ + type(Extended2A), save, allocatable, target :: type_ + allocate(type_) + typePtr_ => null() + if (present(c1)) call type_%setCoeff1(c1) + typePtr_ => type_ + if ( .not.(associated (typePtr_))) then + stop 'Error initializing Extended2A Pointer.' + endif + end function Extended2A_new + subroutine Extended2A_setCoeff1(this,c1) + class(Extended2A) :: this + real(kind(1.0D0)), intent(in) :: c1 + this% coeff1 = c1 + end subroutine Extended2A_setCoeff1 +end module extended2A_type + +module type1_type + use type2_type + implicit none + type Type1 + class(type2), pointer :: type2Ptr => null() + contains + procedure :: initProc => Type1_initProc + end type Type1 + contains + function Type1_initProc(this) result(iError) + use extended2A_type + implicit none + class(Type1) :: this + integer :: iError + this% type2Ptr => extended2A_new() + if ( .not.( associated(this% type2Ptr))) then + iError = 1 + write(*,'(A)') "Something Wrong." + else + iError = 0 + endif + end function Type1_initProc +end module type1_type + +! { dg-final { cleanup-modules "type2_type extended2A_type type1_type" } } diff --git a/gcc/testsuite/gfortran.dg/class_28.f03 b/gcc/testsuite/gfortran.dg/class_28.f03 new file mode 100644 index 00000000000..cfd46a8eb65 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_28.f03 @@ -0,0 +1,30 @@ +! { dg-do compile } +! +! PR 46344: [4.6 Regression] [OOP] ICE with allocatable CLASS components +! +! Contributed by Salvatore Filippone <sfilippone@uniroma2.it> + +module m + + type t1 + end type + + type t2 + class(t1), allocatable :: cc + end type + + class(t2), allocatable :: sm + +end module m + +program p + use m + implicit none + + type(t2), allocatable :: x(:) + + allocate(x(1)) + +end program p + +! { dg-final { cleanup-modules "m" } } diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index f387d7e7233..751c1c51577 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -1366,7 +1366,7 @@ proc check_function_available { function } { #endif char $function (); int main () { $function (); } - }]] + }] "-fno-builtin" ] } # Returns true iff "fork" is available on the target system. @@ -3741,3 +3741,9 @@ proc check_effective_target_run_expensive_tests { } { } return 0 } + +# Returns 1 if "mempcpy" is available on the target system. + +proc check_effective_target_mempcpy {} { + return [check_function_available "mempcpy"] +} diff --git a/gcc/testsuite/obj-c++.dg/encode-3.mm b/gcc/testsuite/obj-c++.dg/encode-3.mm index 44f288d7de0..1486a652a0d 100644 --- a/gcc/testsuite/obj-c++.dg/encode-3.mm +++ b/gcc/testsuite/obj-c++.dg/encode-3.mm @@ -32,6 +32,15 @@ const char *enc3 = @encode(anonymous); #define L "l" #endif +/* Darwin (at least, as of XCode 3.2.3/Darwin10) does not encode the read-only + attribute on the type. Arguably, this is a bug, but we are compatible + with this when -fnext-runtime is selected. */ +#ifdef __NEXT_RUNTIME__ +#define E3 "{?=f[10d]i" L "q{Vec<const signed char>=cc" L "q}}" +#else +#define E3 "{?=f[10d]i" L "q{Vec<const signed char>=rcrc" L "q}}" +#endif + int main(void) { const char *encode = @encode(long); @@ -44,7 +53,7 @@ int main(void) { if (strcmp (enc2, (const char *)"{Vec<double>=dd" L "q}")) abort (); - if (strcmp (enc3, (const char *)"{?=f[10d]i" L "q{Vec<const signed char>=rcrc" L "q}}")) + if (strcmp (enc3, (const char *) E3)) abort (); return 0; diff --git a/gcc/testsuite/obj-c++.dg/fsf-nsstring-format-1.mm b/gcc/testsuite/obj-c++.dg/fsf-nsstring-format-1.mm new file mode 100644 index 00000000000..6e58e65dc7b --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/fsf-nsstring-format-1.mm @@ -0,0 +1,51 @@ +/* Check NSString format extensions. */ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ +/* { dg-options "-Wall" } */ + +#ifndef __CONSTANT_CFSTRINGS__ +#error requires CFString +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern int printf (const char *fmt, ...); +typedef const struct __CFString * CFStringRef; + +#ifdef __cplusplus +} +#endif + +@class NSString; + +int s1 (NSString *fmt, ...) __attribute__((format(NSString, 1, 2))) ; /* OK */ +/* A CFString can represent an NSString. */ +int s1a (CFStringRef fmt, ...) __attribute__((format(NSString, 1, 2))) ; /* OK */ +/* But... it is possible that a CFString format might imply functionality that + is not present in objective-c. */ +int s1b (NSString *fmt, ...) __attribute__((format(CFString, 1, 2))) ; /* { dg-error "format argument should be a .CFString. reference" } */ + +int s2 (int a, NSString *fmt, ... ) __attribute__((format(__NSString__, 2, 3))) ; /* OK */ + +int s2a (int a, NSString *fmt, ... ) __attribute__((format(NSString, 2, 2))) ; /* { dg-error "format string argument follows the args to be formatted" } */ + +int s3 (const char *fmt, ... ) __attribute__((format(__NSString__, 1, 2))) ; /* { dg-error "format argument should be a .NSString. reference but a string was found" } */ +int s4 (NSString *fmt, ... ) __attribute__((format(printf, 1, 2))) ; /* { dg-error "found a .NSString. reference but the format argument should be a string" } */ + +char *s5 (char dum, char *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ +NSString *s6 (NSString *dum, NSString *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ + +char *s7 (int dum, void *fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "format string argument is not a string type" } */ +int s8 (NSString *dum, NSString *fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "function does not return string type" } */ + +char *s9 (int dum, char *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ +NSString *s10 (int dum, NSString *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ + +void foo (void) +{ + s1 (@"this format not checked %d %s", 3, 4); + printf("this one is checked %d %s", 3, 4, 5); /* { dg-warning "format .%s. expects type .char.., but argument 3 has type 'int'" } */ + /* { dg-warning "too many arguments for format" "" { target *-*-* } 48 } */ + printf(s9 (1, (char *)"and so is this %d %d %s" , 3, 4, "hm"), 5, 6, 12); /* { dg-warning "format .%s. expects type .char.., but argument 4 has type .int." } */ +} diff --git a/gcc/testsuite/obj-c++.dg/property/dotsyntax-10.mm b/gcc/testsuite/obj-c++.dg/property/dotsyntax-10.mm new file mode 100644 index 00000000000..433595f3daa --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/property/dotsyntax-10.mm @@ -0,0 +1,86 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test dot-syntax with 'super'. */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +static int c; + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +- (int) count; +- (void) setCount: (int)count; ++ (int) classCount; ++ (void) setClassCount: (int)count; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} ++ (int) classCount +{ + return c; +} ++ (void) setClassCount: (int)count +{ + c = count; +} +@end + +@interface MySubClass : MyRootClass ++ (int) testMe; +- (int) testMe; +@end + +@implementation MySubClass +- (int) testMe +{ + super.count = 400; + if (super.count != 400) + abort (); + + return super.count; +} ++ (int) testMe +{ + super.classCount = 4000; + if (super.classCount != 4000) + abort (); + + return super.classCount; +} +@end + +int main (void) +{ + MySubClass *object = [[MySubClass alloc] init]; + + if ([object testMe] != 400) + abort (); + + if ([MySubClass testMe] != 4000) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/obj-c++.dg/property/dotsyntax-11.mm b/gcc/testsuite/obj-c++.dg/property/dotsyntax-11.mm new file mode 100644 index 00000000000..6c9d924ca82 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/property/dotsyntax-11.mm @@ -0,0 +1,61 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do compile } */ + +/* Test the error reporting for the dot-syntax in the scenario where + we have a setter, but not a getter, yet a getter is requested. */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +static int c; + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +- (void) setCount: (int)count; ++ (void) setClassCount: (int)count; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (void) setCount: (int)count +{ + a = count; +} ++ (void) setClassCount: (int)count +{ + c = count; +} +@end + +@interface MySubClass : MyRootClass ++ (int) testMe; +- (int) testMe; +@end + +@implementation MySubClass +- (int) testMe +{ + super.count = 400; + if (super.count != 400) /* { dg-error "no .count. getter found" } */ + abort (); + + return super.count; /* { dg-error "no .count. getter found" } */ +} ++ (int) testMe +{ + super.classCount = 4000; + if (super.classCount != 4000) /* { dg-error "no .classCount. getter found" } */ + abort (); + + return super.classCount; /* { dg-error "no .classCount. getter found" } */ +} +@end diff --git a/gcc/testsuite/obj-c++.dg/property/dotsyntax-5.mm b/gcc/testsuite/obj-c++.dg/property/dotsyntax-5.mm new file mode 100644 index 00000000000..06e11303219 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/property/dotsyntax-5.mm @@ -0,0 +1,78 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test the 'dot syntax' with self, both in instance and class methods. */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +static int c; + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +- (int) count; +- (void) setCount: (int)count; ++ (int) classCount; ++ (void) setClassCount: (int)count; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} ++ (int) classCount +{ + return c; +} ++ (void) setClassCount: (int)count +{ + c = count; +} +- (int) testMe +{ + self.count = 400; + if (self.count != 400) + abort (); + + return self.count; +} ++ (int) testMe +{ + self.classCount = 4000; + if (self.classCount != 4000) + abort (); + + return self.classCount; +} +@end + +int main (void) +{ + MyRootClass *object = [[MyRootClass alloc] init]; + + if ([object testMe] != 400) + abort (); + + if ([MyRootClass testMe] != 4000) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/obj-c++.dg/property/dotsyntax-6.mm b/gcc/testsuite/obj-c++.dg/property/dotsyntax-6.mm new file mode 100644 index 00000000000..cc8c567cff9 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/property/dotsyntax-6.mm @@ -0,0 +1,107 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test nested 'dot syntax' (xxx.yyy.zzz or [xxx yyy].zzz). */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +@class MyRootClass; + +static int c; +static MyRootClass *shared_root = nil; + +@interface MyRootClass +{ + Class isa; + int a; + int b; + MyRootClass *next; +} +@property int b; +@property (assign) MyRootClass *next; ++ (id) initialize; ++ (MyRootClass *)sharedInstance; ++ (id) alloc; +- (id) init; +- (MyRootClass *)same; +- (int) count; +- (void) setCount: (int)count; +@end + +@implementation MyRootClass +@synthesize b; +@synthesize next; ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } ++ (MyRootClass *)sharedInstance +{ + if (!shared_root) + shared_root = [[self alloc] init]; + + return shared_root; +} +- (MyRootClass *)same +{ + return self; +} +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} +@end + +int main (void) +{ + MyRootClass *object = [[MyRootClass alloc] init]; + + /* Test ClassName.accessor.accessor. */ + MyRootClass.sharedInstance.count = 500; + if (MyRootClass.sharedInstance.count != 500) + abort (); + + /* Test object.accessor.accessor. */ + object.same.count = 1000; + if (object.same.count != 1000) + abort (); + + /* Test object.accessor.property. */ + object.same.next = object; + if (object.same.next != object) + abort (); + + /* Test lots of nesting. */ + if (object.next.next.same.same.next.next.same != object) + abort (); + + /* Test more nesting. */ + MyRootClass.sharedInstance.next = object; + MyRootClass.sharedInstance.next.next.next.next.next.count = 2000; + if (MyRootClass.sharedInstance.next.next.next.next.next.count != 2000) + abort (); + + /* Test more nesting. */ + MyRootClass.sharedInstance.same.same.same.same.same.count = 3000; + if (MyRootClass.sharedInstance.same.same.same.same.same.count != 3000) + abort (); + + /* Test [object method].property. */ + [MyRootClass sharedInstance].count = 5000; + if ([MyRootClass sharedInstance].count != 5000) + abort (); + + /* Just a final check. */ + if (shared_root.count != 5000) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/obj-c++.dg/property/dotsyntax-7.mm b/gcc/testsuite/obj-c++.dg/property/dotsyntax-7.mm new file mode 100644 index 00000000000..15c1725d833 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/property/dotsyntax-7.mm @@ -0,0 +1,48 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test dot syntax of a casted expression. */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +- (int) count; +- (void) setCount: (int)count; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} +@end + +int main (void) +{ + id object = [[MyRootClass alloc] init]; + + ((MyRootClass *)object).count = 200; + if (((MyRootClass *)object).count != 200) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/obj-c++.dg/property/dotsyntax-8.mm b/gcc/testsuite/obj-c++.dg/property/dotsyntax-8.mm new file mode 100644 index 00000000000..35dfda40c9d --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/property/dotsyntax-8.mm @@ -0,0 +1,62 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test the 'dot syntax' with typedefs. */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +static int c; + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +- (int) count; +- (void) setCount: (int)count; ++ (int) classCount; ++ (void) setClassCount: (int)count; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} ++ (int) classCount +{ + return c; +} ++ (void) setClassCount: (int)count +{ + c = count; +} +@end + +typedef MyRootClass MyType; + +int main (void) +{ + MyType *object = [[MyRootClass alloc] init]; + + object.count = 1974; + if (object.count != 1974) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/obj-c++.dg/property/dotsyntax-9.mm b/gcc/testsuite/obj-c++.dg/property/dotsyntax-9.mm new file mode 100644 index 00000000000..61a5c0eb8c6 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/property/dotsyntax-9.mm @@ -0,0 +1,77 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test that setter/getters for dot-syntax are properly found even if + not declared in the @interface, but available in the local + @implementation before the current line (ie, [object name] can be + compiled in that case, so object.name should be compiled too). */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +static int c; + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} ++ (int) classCount +{ + return c; +} ++ (void) setClassCount: (int)count +{ + c = count; +} +- (int) testMe +{ + self.count = 400; + if (self.count != 400) + abort (); + + return self.count; +} ++ (int) testMe +{ + self.classCount = 4000; + if (self.classCount != 4000) + abort (); + + return self.classCount; +} +@end + +int main (void) +{ + MyRootClass *object = [[MyRootClass alloc] init]; + + if ([object testMe] != 400) + abort (); + + if ([MyRootClass testMe] != 4000) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-1.mm b/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-1.mm index a11b5266f40..2983c43c445 100644 --- a/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-1.mm +++ b/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-1.mm @@ -9,6 +9,9 @@ /* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ /* { dg-options "-mconstant-cfstrings -framework Cocoa" } */ +/* Darwin10's linker emits a warning that the constant strings are incompatible with writable ones. + well, we don't implement writable ones at this juncture. */ +/* { dg-options "-mconstant-cfstrings -framework Cocoa -Wl,-w" { target *-*-darwin[123]* } } */ #import <Foundation/NSString.h> #import <CoreFoundation/CFString.h> diff --git a/gcc/testsuite/objc.dg/fsf-nsstring-format-1.m b/gcc/testsuite/objc.dg/fsf-nsstring-format-1.m new file mode 100644 index 00000000000..2550a550168 --- /dev/null +++ b/gcc/testsuite/objc.dg/fsf-nsstring-format-1.m @@ -0,0 +1,44 @@ +/* Check NSString format extensions. */ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ +/* { dg-options "-Wall" } */ + +extern int printf (const char *fmt, ...); + +#ifndef __CONSTANT_CFSTRINGS__ +#error requires CFString +#endif + +typedef const struct __CFString * CFStringRef; +@class NSString; + +int s1 (NSString *fmt, ...) __attribute__((format(NSString, 1, 2))) ; /* OK */ +/* A CFString can represent an NSString. */ +int s1a (CFStringRef fmt, ...) __attribute__((format(NSString, 1, 2))) ; /* OK */ +/* But... it is possible that a CFString format might imply functionality that + is not present in objective-c. */ +int s1b (NSString *fmt, ...) __attribute__((format(CFString, 1, 2))) ; /* { dg-error "format argument should be a .CFString. reference" } */ + +int s2 (int a, NSString *fmt, ... ) __attribute__((format(__NSString__, 2, 3))) ; /* OK */ + +int s2a (int a, NSString *fmt, ... ) __attribute__((format(NSString, 2, 2))) ; /* { dg-error "format string argument follows the args to be formatted" } */ + +int s3 (const char *fmt, ... ) __attribute__((format(__NSString__, 1, 2))) ; /* { dg-error "format argument should be a .NSString. reference but a string was found" } */ +int s4 (NSString *fmt, ... ) __attribute__((format(printf, 1, 2))) ; /* { dg-error "found a .NSString. reference but the format argument should be a string" } */ + +char *s5 (char dum, char *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ +NSString *s6 (NSString *dum, NSString *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ + +char *s7 (int dum, void *fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "format string argument is not a string type" } */ +int s8 (NSString *dum, NSString *fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "function does not return string type" } */ + +char *s9 (int dum, char *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ +NSString *s10 (int dum, NSString *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ + +void foo (void) +{ + s1 (@"format not checked %d %s", 3, 4); + printf("this one is checked %d %s", 3, 4, 5); /* { dg-warning "format .%s. expects type .char .., but argument 3 has type .int." } */ + /* { dg-warning "too many arguments for format" "" { target *-*-* } 41 } */ + printf(s9 (1, "and so is this %d %d %s", 3, 4), 5, 6, 12); /* { dg-warning "format .%s. expects type .char .., but argument 4 has type .int." } */ +} diff --git a/gcc/testsuite/objc.dg/property/dotsyntax-10.m b/gcc/testsuite/objc.dg/property/dotsyntax-10.m new file mode 100644 index 00000000000..433595f3daa --- /dev/null +++ b/gcc/testsuite/objc.dg/property/dotsyntax-10.m @@ -0,0 +1,86 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test dot-syntax with 'super'. */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +static int c; + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +- (int) count; +- (void) setCount: (int)count; ++ (int) classCount; ++ (void) setClassCount: (int)count; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} ++ (int) classCount +{ + return c; +} ++ (void) setClassCount: (int)count +{ + c = count; +} +@end + +@interface MySubClass : MyRootClass ++ (int) testMe; +- (int) testMe; +@end + +@implementation MySubClass +- (int) testMe +{ + super.count = 400; + if (super.count != 400) + abort (); + + return super.count; +} ++ (int) testMe +{ + super.classCount = 4000; + if (super.classCount != 4000) + abort (); + + return super.classCount; +} +@end + +int main (void) +{ + MySubClass *object = [[MySubClass alloc] init]; + + if ([object testMe] != 400) + abort (); + + if ([MySubClass testMe] != 4000) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/objc.dg/property/dotsyntax-11.m b/gcc/testsuite/objc.dg/property/dotsyntax-11.m new file mode 100644 index 00000000000..6c9d924ca82 --- /dev/null +++ b/gcc/testsuite/objc.dg/property/dotsyntax-11.m @@ -0,0 +1,61 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do compile } */ + +/* Test the error reporting for the dot-syntax in the scenario where + we have a setter, but not a getter, yet a getter is requested. */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +static int c; + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +- (void) setCount: (int)count; ++ (void) setClassCount: (int)count; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (void) setCount: (int)count +{ + a = count; +} ++ (void) setClassCount: (int)count +{ + c = count; +} +@end + +@interface MySubClass : MyRootClass ++ (int) testMe; +- (int) testMe; +@end + +@implementation MySubClass +- (int) testMe +{ + super.count = 400; + if (super.count != 400) /* { dg-error "no .count. getter found" } */ + abort (); + + return super.count; /* { dg-error "no .count. getter found" } */ +} ++ (int) testMe +{ + super.classCount = 4000; + if (super.classCount != 4000) /* { dg-error "no .classCount. getter found" } */ + abort (); + + return super.classCount; /* { dg-error "no .classCount. getter found" } */ +} +@end diff --git a/gcc/testsuite/objc.dg/property/dotsyntax-5.m b/gcc/testsuite/objc.dg/property/dotsyntax-5.m new file mode 100644 index 00000000000..06e11303219 --- /dev/null +++ b/gcc/testsuite/objc.dg/property/dotsyntax-5.m @@ -0,0 +1,78 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test the 'dot syntax' with self, both in instance and class methods. */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +static int c; + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +- (int) count; +- (void) setCount: (int)count; ++ (int) classCount; ++ (void) setClassCount: (int)count; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} ++ (int) classCount +{ + return c; +} ++ (void) setClassCount: (int)count +{ + c = count; +} +- (int) testMe +{ + self.count = 400; + if (self.count != 400) + abort (); + + return self.count; +} ++ (int) testMe +{ + self.classCount = 4000; + if (self.classCount != 4000) + abort (); + + return self.classCount; +} +@end + +int main (void) +{ + MyRootClass *object = [[MyRootClass alloc] init]; + + if ([object testMe] != 400) + abort (); + + if ([MyRootClass testMe] != 4000) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/objc.dg/property/dotsyntax-6.m b/gcc/testsuite/objc.dg/property/dotsyntax-6.m new file mode 100644 index 00000000000..cc8c567cff9 --- /dev/null +++ b/gcc/testsuite/objc.dg/property/dotsyntax-6.m @@ -0,0 +1,107 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test nested 'dot syntax' (xxx.yyy.zzz or [xxx yyy].zzz). */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +@class MyRootClass; + +static int c; +static MyRootClass *shared_root = nil; + +@interface MyRootClass +{ + Class isa; + int a; + int b; + MyRootClass *next; +} +@property int b; +@property (assign) MyRootClass *next; ++ (id) initialize; ++ (MyRootClass *)sharedInstance; ++ (id) alloc; +- (id) init; +- (MyRootClass *)same; +- (int) count; +- (void) setCount: (int)count; +@end + +@implementation MyRootClass +@synthesize b; +@synthesize next; ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } ++ (MyRootClass *)sharedInstance +{ + if (!shared_root) + shared_root = [[self alloc] init]; + + return shared_root; +} +- (MyRootClass *)same +{ + return self; +} +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} +@end + +int main (void) +{ + MyRootClass *object = [[MyRootClass alloc] init]; + + /* Test ClassName.accessor.accessor. */ + MyRootClass.sharedInstance.count = 500; + if (MyRootClass.sharedInstance.count != 500) + abort (); + + /* Test object.accessor.accessor. */ + object.same.count = 1000; + if (object.same.count != 1000) + abort (); + + /* Test object.accessor.property. */ + object.same.next = object; + if (object.same.next != object) + abort (); + + /* Test lots of nesting. */ + if (object.next.next.same.same.next.next.same != object) + abort (); + + /* Test more nesting. */ + MyRootClass.sharedInstance.next = object; + MyRootClass.sharedInstance.next.next.next.next.next.count = 2000; + if (MyRootClass.sharedInstance.next.next.next.next.next.count != 2000) + abort (); + + /* Test more nesting. */ + MyRootClass.sharedInstance.same.same.same.same.same.count = 3000; + if (MyRootClass.sharedInstance.same.same.same.same.same.count != 3000) + abort (); + + /* Test [object method].property. */ + [MyRootClass sharedInstance].count = 5000; + if ([MyRootClass sharedInstance].count != 5000) + abort (); + + /* Just a final check. */ + if (shared_root.count != 5000) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/objc.dg/property/dotsyntax-7.m b/gcc/testsuite/objc.dg/property/dotsyntax-7.m new file mode 100644 index 00000000000..15c1725d833 --- /dev/null +++ b/gcc/testsuite/objc.dg/property/dotsyntax-7.m @@ -0,0 +1,48 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test dot syntax of a casted expression. */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +- (int) count; +- (void) setCount: (int)count; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} +@end + +int main (void) +{ + id object = [[MyRootClass alloc] init]; + + ((MyRootClass *)object).count = 200; + if (((MyRootClass *)object).count != 200) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/objc.dg/property/dotsyntax-8.m b/gcc/testsuite/objc.dg/property/dotsyntax-8.m new file mode 100644 index 00000000000..35dfda40c9d --- /dev/null +++ b/gcc/testsuite/objc.dg/property/dotsyntax-8.m @@ -0,0 +1,62 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test the 'dot syntax' with typedefs. */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +static int c; + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +- (int) count; +- (void) setCount: (int)count; ++ (int) classCount; ++ (void) setClassCount: (int)count; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} ++ (int) classCount +{ + return c; +} ++ (void) setClassCount: (int)count +{ + c = count; +} +@end + +typedef MyRootClass MyType; + +int main (void) +{ + MyType *object = [[MyRootClass alloc] init]; + + object.count = 1974; + if (object.count != 1974) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/objc.dg/property/dotsyntax-9.m b/gcc/testsuite/objc.dg/property/dotsyntax-9.m new file mode 100644 index 00000000000..61a5c0eb8c6 --- /dev/null +++ b/gcc/testsuite/objc.dg/property/dotsyntax-9.m @@ -0,0 +1,77 @@ +/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test that setter/getters for dot-syntax are properly found even if + not declared in the @interface, but available in the local + @implementation before the current line (ie, [object name] can be + compiled in that case, so object.name should be compiled too). */ + +#include <stdlib.h> +#include <objc/objc.h> +#include <objc/runtime.h> + +static int c; + +@interface MyRootClass +{ + Class isa; + int a; +} ++ (id) initialize; ++ (id) alloc; +- (id) init; +@end + +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (int) count +{ + return a; +} +- (void) setCount: (int)count +{ + a = count; +} ++ (int) classCount +{ + return c; +} ++ (void) setClassCount: (int)count +{ + c = count; +} +- (int) testMe +{ + self.count = 400; + if (self.count != 400) + abort (); + + return self.count; +} ++ (int) testMe +{ + self.classCount = 4000; + if (self.classCount != 4000) + abort (); + + return self.classCount; +} +@end + +int main (void) +{ + MyRootClass *object = [[MyRootClass alloc] init]; + + if ([object testMe] != 400) + abort (); + + if ([MyRootClass testMe] != 4000) + abort (); + + return 0; +} + + diff --git a/gcc/testsuite/objc.dg/torture/forward-1.m b/gcc/testsuite/objc.dg/torture/forward-1.m index 086d69ef35e..518bf274e6d 100644 --- a/gcc/testsuite/objc.dg/torture/forward-1.m +++ b/gcc/testsuite/objc.dg/torture/forward-1.m @@ -1,6 +1,6 @@ /* { dg-do run } */ /* See if -forward::/-performv:: is able to work. */ -/* { dg-skip-if "PR36610" { *-*-* } { "-fgnu-runtime" } { "" } } */ +/* { dg-xfail-run-if "PR36610" { ! { { i?86-*-* x86_64-*-* } && ilp32 } } { "-fgnu-runtime" } { "" } } */ /* { dg-skip-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ #include <stdio.h> diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index a8284083067..7e7e2b152ee 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -341,7 +341,11 @@ rhs_to_tree (tree type, gimple stmt) { location_t loc = gimple_location (stmt); enum tree_code code = gimple_assign_rhs_code (stmt); - if (get_gimple_rhs_class (code) == GIMPLE_BINARY_RHS) + if (get_gimple_rhs_class (code) == GIMPLE_TERNARY_RHS) + return fold_build3_loc (loc, code, type, gimple_assign_rhs1 (stmt), + gimple_assign_rhs2 (stmt), + gimple_assign_rhs3 (stmt)); + else if (get_gimple_rhs_class (code) == GIMPLE_BINARY_RHS) return fold_build2_loc (loc, code, type, gimple_assign_rhs1 (stmt), gimple_assign_rhs2 (stmt)); else if (get_gimple_rhs_class (code) == GIMPLE_UNARY_RHS) diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 0dc8b15ea10..b9c6908e2b3 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -7339,7 +7339,17 @@ emit_note_insn_var_location (void **varp, void *data) NOTE_DURING_CALL_P (note) = true; } else - note = emit_note_before (NOTE_INSN_VAR_LOCATION, insn); + { + /* Make sure that the call related notes come first. */ + while (NEXT_INSN (insn) + && NOTE_P (insn) + && NOTE_DURING_CALL_P (insn)) + insn = NEXT_INSN (insn); + if (NOTE_P (insn) && NOTE_DURING_CALL_P (insn)) + note = emit_note_after (NOTE_INSN_VAR_LOCATION, insn); + else + note = emit_note_before (NOTE_INSN_VAR_LOCATION, insn); + } NOTE_VAR_LOCATION (note) = note_vl; clear: diff --git a/gcc/varasm.c b/gcc/varasm.c index 4739410081a..fe60bb2397d 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6611,6 +6611,16 @@ default_emit_except_table_label (FILE * stream ATTRIBUTE_UNUSED) the class of label and LABELNO is the number within the class. */ void +default_generate_internal_label (char *buf, const char *prefix, + unsigned long labelno) +{ + ASM_GENERATE_INTERNAL_LABEL (buf, prefix, labelno); +} + +/* This is how to output an internal numbered label where PREFIX is + the class of label and LABELNO is the number within the class. */ + +void default_internal_label (FILE *stream, const char *prefix, unsigned long labelno) { diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index ea864d33dcb..21099ab697d 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,9 @@ +2010-11-07 Ian Lance Taylor <iant@google.com> + + PR target/46089 + * config/i386/morestack.S (__morestack_large_model): New + function. + 2010-10-23 Nathan Froyd <froydnj@codesourcery.com> * config/libbid/bid_gcc_intrinsics.h (LIBGCC2_WORDS_BIG_ENDIAN): diff --git a/libgcc/config/i386/morestack.S b/libgcc/config/i386/morestack.S index 79abba3ead1..10fa1fdf73a 100644 --- a/libgcc/config/i386/morestack.S +++ b/libgcc/config/i386/morestack.S @@ -488,6 +488,40 @@ DW.ref.__gcc_personality_v0: #endif #endif +#ifdef __x86_64__ + +# This entry point is used for the large model. With this entry point +# the upper 32 bits of %r10 hold the argument size and the lower 32 +# bits hold the new stack frame size. There doesn't seem to be a way +# to know in the assembler code that we are assembling for the large +# model, and there doesn't seem to be a large model multilib anyhow. +# If one is developed, then the non-PIC code is probably OK since we +# will probably be close to the morestack code, but the PIC code +# almost certainly needs to be changed. FIXME. + + .text + .global __morestack_large_model + .hidden __morestack_large_model + +#ifdef __ELF__ + .type __morestack_large_model,@function +#endif + +__morestack_large_model: + + .cfi_startproc + + movq %r10, %r11 + andl $0xffffffff, %r10d + sarq $32, %r11 + jmp __morestack + + .cfi_endproc +#ifdef __ELF__ + .size __morestack_large_model, . - __morestack_large_model +#endif + +#endif /* __x86_64__ */ # Initialize the stack test value when the program starts or when a # new thread starts. We don't know how large the main stack is, so we diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8ea46f0847d..d49f970a157 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,106 @@ +2010-11-08 Jason Merrill <jason@redhat.com> + + * testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Adjust + expected error. + +2010-11-08 Benjamin Kosnik <bkoz@redhat.com> + + * include/std/complex (operator==, !=): Mark constexpr. + * testsuite/26_numerics/complex/comparison_operators/constexpr.cc: New. + +2010-11-08 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/stl_tree.h (_Rb_tree<>::_M_erase_aux): Add. + (_Rb_tree<>::erase(iterator)): Fix in C++0x mode to take + const_iterator; remove redundant overload in C++03 mode. + (_Rb_tree<>::erase(iterator, iterator)): Likewise. + * include/bits/stl_map.h (map<>::erase): Adjust. + (map<>::insert): Fix signature in C++0x mode. + * include/bits/stl_set.h (set<>::erase): Likewise. + (set<>::insert): Likewise. + * include/bits/stl_multimap.h (multimap<>::erase): Likewise. + (multimap<>::insert): Likewise. + * include/bits/stl_multiset.h (multiset<>::erase): Likewise. + (multiset<>::insert): Fix signature in C++0x mode. + * include/profile/set.h: Adjust. + * include/profile/multiset.h: Likewise. + * include/profile/map.h: Likewise. + * include/profile/multimap.h: Likewise. + * testsuite/util/exception/safety.h (erase_base, insert_base): + Update. + +2010-11-07 Paolo Carlini <paolo.carlini@oracle.com> + + * include/profile/unordered_map (unordered_map<>::operator[](_Key&&)): + Add. + +2010-11-07 Paolo Carlini <paolo.carlini@oracle.com> + + * include/profile/bitset (bitset<>::bitset(), bitset<>:: + bitset(unsigned long long)): Add constexpr specifier. + +2010-11-07 Paolo Carlini <paolo.carlini@oracle.com> + + * include/debug/bitset: Do not derive from _Safe_sequence_base in + C++0x mode, otherwise std::bitset isn't a literal type anymore; + adjust everywhere. + + * include/debug/bitset (bitset<>::bitset(), bitset<>:: + bitset(unsigned long long)): Add missing constexpr specifier. + +2010-11-05 Benjamin Kosnik <bkoz@redhat.com> + + * doc/doxygen/user.cfg.in: Add typeindex. + + * testsuite/util/testsuite_common_types.h (constexpr_comparison_eq_ne, + constexpr_comparison_operators): New. + * testsuite/20_util/duration/comparisons: Move... + * testsuite/20_util/duration/comparison_operators: ...here. + * testsuite/20_util/duration/comparison_operators/constexpr.cc: New. + * testsuite/20_util/time_point/comparison_operators/constexpr.cc: Add. + + * testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: Adjust line + numbers. + * testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Same. + * testsuite/29_atomics/atomic/cons/assign_neg.cc: Same. + * testsuite/29_atomics/atomic/cons/copy_neg.cc: Same. + +2010-11-05 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/shared_ptr.h (shared_ptr<>::__shared_ptr(), + shared_ptr<>::shared_ptr(nullptr_t), weak_ptr<>::weak_ptr(), + enable_shared_from_this::enable_shared_from_this()): Add constexpr + specifier. + * include/bits/shared_ptr_base.h (__shared_count::__shared_count(), + __shared_count::__shared_count(), __shared_ptr<>::__shared_ptr(), + __shared_ptr<>::__shared_ptr(nullptr_t), __weak_ptr<>::__weak_ptr(), + __enable_shared_from_this::__enable_shared_from_this()): Likewise. + * include/bits/unique_ptr.h (default_delete, + unique_ptr<>::unique_ptr(), unique_ptr<>::unique_ptr(nullptr_t)): + Likewise. + * testsuite/20_util/default_delete/cons/constexpr.cc: Do not xfail. + * testsuite/20_util/shared_ptr/cons/constexpr.cc: Remove, the test + cannot work for a non-literal type like std::shared_ptr. + * testsuite/20_util/weak_ptr/cons/constexpr.cc: Likewise. + * testsuite/util/testsuite_common_types.h: Add comments. + * testsuite/20_util/unique_ptr/cons/constexpr.cc: Likewise. + * testsuite/20_util/shared_ptr/cons/43820.cc: Adjust dg-error line + numbers. + * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Likewise. + +2010-11-05 Benjamin Kosnik <bkoz@redhat.com> + + * doc/doxygen/user.cfg.in: Remove tr1_impl headers. + + * testsuite/tr1/4_metaprogramming/integral_constant/requirements/ + constexpr_data.cc: New. + + * testsuite/util/testsuite_tr1.h (LType, LTypeDerived, NLType): New. + * testsuite/20_util/is_literal_type/value.cc: New. + * testsuite/20_util/is_literal_type/requirements/typedefs.cc: Name. + * testsuite/20_util/is_literal_type/requirements/ + explicit_instantiation.cc: New. + 2010-11-04 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/46303 diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in index 8550aa54bf1..32ea7481fb9 100644 --- a/libstdc++-v3/doc/doxygen/user.cfg.in +++ b/libstdc++-v3/doc/doxygen/user.cfg.in @@ -586,6 +586,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \ @srcdir@/libsupc++/cxxabi.h \ @srcdir@/libsupc++/cxxabi-forced.h \ @srcdir@/libsupc++/exception \ + @srcdir@/libsupc++/exception_defines.h \ @srcdir@/libsupc++/exception_ptr.h \ @srcdir@/libsupc++/initializer_list \ @srcdir@/libsupc++/nested_exception.h \ @@ -630,6 +631,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \ include/system_error \ include/thread \ include/tuple \ + include/typeindex \ include/type_traits \ include/unordered_map \ include/unordered_set \ @@ -665,6 +667,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \ include/backward/strstream \ include/debug/bitset \ include/debug/deque \ + include/debug/forward_list \ include/debug/list \ include/debug/map \ include/debug/set \ @@ -674,6 +677,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \ include/debug/vector \ include/profile/bitset \ include/profile/deque \ + include/profile/forward_list \ include/profile/list \ include/profile/map \ include/profile/set \ @@ -707,20 +711,6 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \ include/tr1/ctime \ include/tr1/cwchar \ include/tr1/cwctype \ - include/tr1_impl/array \ - include/tr1_impl/cctype \ - include/tr1_impl/cfenv \ - include/tr1_impl/cinttypes \ - include/tr1_impl/cmath \ - include/tr1_impl/complex \ - include/tr1_impl/cstdint \ - include/tr1_impl/cstdio \ - include/tr1_impl/cstdlib \ - include/tr1_impl/cwchar \ - include/tr1_impl/cwctype \ - include/tr1_impl/type_traits \ - include/tr1_impl/utility \ - include/tr1_impl \ include/decimal/decimal \ include/ \ include/@host_alias@/bits \ @@ -728,6 +718,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \ include/bits \ include/debug \ include/parallel \ + include/precompiled \ include/profile \ include/profile/impl \ include/ext \ diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h index 2d9e6f771a6..0e6f7a6d0b3 100644 --- a/libstdc++-v3/include/bits/shared_ptr.h +++ b/libstdc++-v3/include/bits/shared_ptr.h @@ -95,7 +95,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) * @brief Construct an empty %shared_ptr. * @post use_count()==0 && get()==0 */ - shared_ptr() : __shared_ptr<_Tp>() { } + constexpr shared_ptr() + : __shared_ptr<_Tp>() { } /** * @brief Construct a %shared_ptr that owns the pointer @a __p. @@ -104,7 +105,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) * @throw std::bad_alloc, in which case @c delete @a __p is called. */ template<typename _Tp1> - explicit shared_ptr(_Tp1* __p) : __shared_ptr<_Tp>(__p) { } + explicit shared_ptr(_Tp1* __p) + : __shared_ptr<_Tp>(__p) { } /** * @brief Construct a %shared_ptr that owns the pointer @a __p @@ -256,7 +258,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) * @param __p A null pointer constant. * @post use_count() == 0 && get() == nullptr */ - shared_ptr(nullptr_t __p) : __shared_ptr<_Tp>(__p) { } + constexpr shared_ptr(nullptr_t __p) + : __shared_ptr<_Tp>(__p) { } template<typename _Tp1> shared_ptr& @@ -387,7 +390,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) class weak_ptr : public __weak_ptr<_Tp> { public: - weak_ptr() : __weak_ptr<_Tp>() { } + constexpr weak_ptr() + : __weak_ptr<_Tp>() { } template<typename _Tp1, typename = typename std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> @@ -466,7 +470,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) class enable_shared_from_this { protected: - enable_shared_from_this() { } + constexpr enable_shared_from_this() { } enable_shared_from_this(const enable_shared_from_this&) { } diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 4a30ea4da6a..d39050fcc8d 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -443,7 +443,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) class __shared_count { public: - __shared_count() : _M_pi(0) // nothrow + constexpr __shared_count() : _M_pi(0) // nothrow { } template<typename _Ptr> @@ -635,7 +635,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) class __weak_count { public: - __weak_count() : _M_pi(0) // nothrow + constexpr __weak_count() : _M_pi(0) // nothrow { } __weak_count(const __shared_count<_Lp>& __r) : _M_pi(__r._M_pi) // nothrow @@ -751,11 +751,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std) public: typedef _Tp element_type; - __shared_ptr() : _M_ptr(0), _M_refcount() // never throws + constexpr __shared_ptr() + : _M_ptr(0), _M_refcount() // never throws { } template<typename _Tp1> - explicit __shared_ptr(_Tp1* __p) : _M_ptr(__p), _M_refcount(__p) + explicit __shared_ptr(_Tp1* __p) + : _M_ptr(__p), _M_refcount(__p) { __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) static_assert( sizeof(_Tp1) > 0, "incomplete type" ); @@ -856,7 +858,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) #endif /* TODO: use delegating constructor */ - __shared_ptr(nullptr_t) : _M_ptr(0), _M_refcount() // never throws + constexpr __shared_ptr(nullptr_t) + : _M_ptr(0), _M_refcount() // never throws { } template<typename _Tp1> @@ -1163,7 +1166,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) public: typedef _Tp element_type; - __weak_ptr() : _M_ptr(0), _M_refcount() // never throws + constexpr __weak_ptr() + : _M_ptr(0), _M_refcount() // never throws { } // Generated copy constructor, assignment, destructor are fine. @@ -1324,7 +1328,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) class __enable_shared_from_this { protected: - __enable_shared_from_this() { } + constexpr __enable_shared_from_this() { } __enable_shared_from_this(const __enable_shared_from_this&) { } diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index 5d6a98b75b2..9614a12f106 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -510,7 +510,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) */ void insert(std::initializer_list<value_type> __list) - { insert (__list.begin(), __list.end()); } + { insert(__list.begin(), __list.end()); } #endif /** @@ -537,7 +537,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * Insertion requires logarithmic time (if the hint is not taken). */ iterator +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + insert(const_iterator __position, const value_type& __x) +#else insert(iterator __position, const value_type& __x) +#endif { return _M_t._M_insert_unique_(__position, __x); } /** @@ -570,7 +574,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * the pointer is the user's responsibility. */ iterator - erase(iterator __position) + erase(const_iterator __position) { return _M_t.erase(__position); } #else /** @@ -619,7 +623,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * in any way. Managing the pointer is the user's responsibility. */ iterator - erase(iterator __first, iterator __last) + erase(const_iterator __first, const_iterator __last) { return _M_t.erase(__first, __last); } #else /** diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index 82a80f27eb4..1a01ffecb6a 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -459,7 +459,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * Insertion requires logarithmic time (if the hint is not taken). */ iterator +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + insert(const_iterator __position, const value_type& __x) +#else insert(iterator __position, const value_type& __x) +#endif { return _M_t._M_insert_equal_(__position, __x); } /** @@ -506,7 +510,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * responsibility. */ iterator - erase(iterator __position) + erase(const_iterator __position) { return _M_t.erase(__position); } #else /** @@ -552,10 +556,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * This function erases a sequence of elements from a %multimap. * Note that this function only erases the elements, and that if * the elements themselves are pointers, the pointed-to memory is not - * touched in any way. Managing the pointer is the user's responsibility. + * touched in any way. Managing the pointer is the user's + * responsibility. */ iterator - erase(iterator __first, iterator __last) + erase(const_iterator __first, const_iterator __last) { return _M_t.erase(__first, __last); } #else // _GLIBCXX_RESOLVE_LIB_DEFECTS @@ -569,7 +574,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * This function erases a sequence of elements from a %multimap. * Note that this function only erases the elements, and that if * the elements themselves are pointers, the pointed-to memory is not - * touched in any way. Managing the pointer is the user's responsibility. + * touched in any way. Managing the pointer is the user's + * responsibility. */ void erase(iterator __first, iterator __last) diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index cfe849bf79a..20d7f507899 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -417,7 +417,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * Insertion requires logarithmic time (if the hint is not taken). */ iterator +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + insert(const_iterator __position, const value_type& __x) +#else insert(iterator __position, const value_type& __x) +#endif { return _M_t._M_insert_equal_(__position, __x); } /** @@ -463,7 +467,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * responsibility. */ iterator - erase(iterator __position) + erase(const_iterator __position) { return _M_t.erase(__position); } #else /** @@ -509,10 +513,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * This function erases a sequence of elements from a %multiset. * Note that this function only erases the elements, and that if * the elements themselves are pointers, the pointed-to memory is not - * touched in any way. Managing the pointer is the user's responsibility. + * touched in any way. Managing the pointer is the user's + * responsibility. */ iterator - erase(iterator __first, iterator __last) + erase(const_iterator __first, const_iterator __last) { return _M_t.erase(__first, __last); } #else /** @@ -524,7 +529,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * This function erases a sequence of elements from a %multiset. * Note that this function only erases the elements, and that if * the elements themselves are pointers, the pointed-to memory is not - * touched in any way. Managing the pointer is the user's responsibility. + * touched in any way. Managing the pointer is the user's + * responsibility. */ void erase(iterator __first, iterator __last) diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index ce5bc6c15f2..211b67e1960 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -429,7 +429,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * Insertion requires logarithmic time (if the hint is not taken). */ iterator +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + insert(const_iterator __position, const value_type& __x) +#else insert(iterator __position, const value_type& __x) +#endif { return _M_t._M_insert_unique_(__position, __x); } /** @@ -472,10 +476,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * This function erases an element, pointed to by the given iterator, * from a %set. Note that this function only erases the element, and * that if the element is itself a pointer, the pointed-to memory is not - * touched in any way. Managing the pointer is the user's responsibility. + * touched in any way. Managing the pointer is the user's + * responsibility. */ iterator - erase(iterator __position) + erase(const_iterator __position) { return _M_t.erase(__position); } #else /** @@ -485,7 +490,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * This function erases an element, pointed to by the given iterator, * from a %set. Note that this function only erases the element, and * that if the element is itself a pointer, the pointed-to memory is not - * touched in any way. Managing the pointer is the user's responsibility. + * touched in any way. Managing the pointer is the user's + * responsibility. */ void erase(iterator __position) @@ -523,7 +529,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * in any way. Managing the pointer is the user's responsibility. */ iterator - erase(iterator __first, iterator __last) + erase(const_iterator __first, const_iterator __last) { return _M_t.erase(__first, __last); } #else /** diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 4e9fdf73b55..b85398de3f3 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -702,22 +702,30 @@ _GLIBCXX_BEGIN_NAMESPACE(std) void _M_insert_equal(_InputIterator __first, _InputIterator __last); + private: + void + _M_erase_aux(const_iterator __position); + + void + _M_erase_aux(const_iterator __first, const_iterator __last); + + public: #ifdef __GXX_EXPERIMENTAL_CXX0X__ // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 130. Associative erase should return an iterator. iterator - erase(iterator __position); - - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // DR 130. Associative erase should return an iterator. - const_iterator - erase(const_iterator __position); + erase(const_iterator __position) + { + const_iterator __result = __position; + ++__result; + _M_erase_aux(__position); + return iterator(static_cast<_Link_type> + (const_cast<_Base_ptr>(__result._M_node))); + } #else void - erase(iterator __position); - - void - erase(const_iterator __position); + erase(const_iterator __position) + { _M_erase_aux(__position); } #endif size_type erase(const key_type& __x); @@ -726,18 +734,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 130. Associative erase should return an iterator. iterator - erase(iterator __first, iterator __last); - - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // DR 130. Associative erase should return an iterator. - const_iterator - erase(const_iterator __first, const_iterator __last); + erase(const_iterator __first, const_iterator __last) + { + _M_erase_aux(__first, __last); + return iterator(static_cast<_Link_type> + (const_cast<_Base_ptr>(__last._M_node))); + } #else void - erase(iterator __first, iterator __last); - - void - erase(const_iterator __first, const_iterator __last); + erase(const_iterator __first, const_iterator __last) + { _M_erase_aux(__first, __last); } #endif void erase(const key_type* __first, const key_type* __last); @@ -1353,64 +1359,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _M_insert_equal_(end(), *__first); } -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // DR 130. Associative erase should return an iterator. template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> - typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator - _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: - erase(iterator __position) - { - iterator __result = __position; - ++__result; - _Link_type __y = - static_cast<_Link_type>(_Rb_tree_rebalance_for_erase - (__position._M_node, - this->_M_impl._M_header)); - _M_destroy_node(__y); - --_M_impl._M_node_count; - return __result; - } - - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // DR 130. Associative erase should return an iterator. - template<typename _Key, typename _Val, typename _KeyOfValue, - typename _Compare, typename _Alloc> - typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator - _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: - erase(const_iterator __position) - { - const_iterator __result = __position; - ++__result; - _Link_type __y = - static_cast<_Link_type>(_Rb_tree_rebalance_for_erase - (const_cast<_Base_ptr>(__position._M_node), - this->_M_impl._M_header)); - _M_destroy_node(__y); - --_M_impl._M_node_count; - return __result; - } -#else - template<typename _Key, typename _Val, typename _KeyOfValue, - typename _Compare, typename _Alloc> - inline void - _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: - erase(iterator __position) - { - _Link_type __y = - static_cast<_Link_type>(_Rb_tree_rebalance_for_erase - (__position._M_node, - this->_M_impl._M_header)); - _M_destroy_node(__y); - --_M_impl._M_node_count; - } - - template<typename _Key, typename _Val, typename _KeyOfValue, - typename _Compare, typename _Alloc> - inline void + void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: - erase(const_iterator __position) + _M_erase_aux(const_iterator __position) { _Link_type __y = static_cast<_Link_type>(_Rb_tree_rebalance_for_erase @@ -1419,68 +1372,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _M_destroy_node(__y); --_M_impl._M_node_count; } -#endif - - template<typename _Key, typename _Val, typename _KeyOfValue, - typename _Compare, typename _Alloc> - typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type - _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: - erase(const _Key& __x) - { - pair<iterator, iterator> __p = equal_range(__x); - const size_type __old_size = size(); - erase(__p.first, __p.second); - return __old_size - size(); - } - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // DR 130. Associative erase should return an iterator. - template<typename _Key, typename _Val, typename _KeyOfValue, - typename _Compare, typename _Alloc> - typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator - _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: - erase(iterator __first, iterator __last) - { - if (__first == begin() && __last == end()) - { - clear(); - return end(); - } - else - { - while (__first != __last) - erase(__first++); - return __last; - } - } - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // DR 130. Associative erase should return an iterator. - template<typename _Key, typename _Val, typename _KeyOfValue, - typename _Compare, typename _Alloc> - typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator - _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: - erase(const_iterator __first, const_iterator __last) - { - if (__first == begin() && __last == end()) - { - clear(); - return end(); - } - else - { - while (__first != __last) - erase(__first++); - return __last; - } - } -#else template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> void _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: - erase(iterator __first, iterator __last) + _M_erase_aux(const_iterator __first, const_iterator __last) { if (__first == begin() && __last == end()) clear(); @@ -1491,17 +1388,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> - void + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: - erase(const_iterator __first, const_iterator __last) + erase(const _Key& __x) { - if (__first == begin() && __last == end()) - clear(); - else - while (__first != __last) - erase(__first++); + pair<iterator, iterator> __p = equal_range(__x); + const size_type __old_size = size(); + erase(__p.first, __p.second); + return __old_size - size(); } -#endif template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index ebbc521873a..4dc4dddb28e 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -46,20 +46,20 @@ _GLIBCXX_BEGIN_NAMESPACE(std) /// Primary template, default_delete. template<typename _Tp> struct default_delete - { - default_delete() { } + { + constexpr default_delete() { } - template<typename _Up, typename = typename - std::enable_if<std::is_convertible<_Up*, _Tp*>::value>::type> - default_delete(const default_delete<_Up>&) { } + template<typename _Up, typename = typename + std::enable_if<std::is_convertible<_Up*, _Tp*>::value>::type> + default_delete(const default_delete<_Up>&) { } - void - operator()(_Tp* __ptr) const - { - static_assert(sizeof(_Tp)>0, - "can't delete pointer to incomplete type"); - delete __ptr; - } + void + operator()(_Tp* __ptr) const + { + static_assert(sizeof(_Tp)>0, + "can't delete pointer to incomplete type"); + delete __ptr; + } }; // _GLIBCXX_RESOLVE_LIB_DEFECTS @@ -68,6 +68,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<typename _Tp> struct default_delete<_Tp[]> { + constexpr default_delete() { } + void operator()(_Tp* __ptr) const { @@ -108,8 +110,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) "constructed with null function pointer deleter"); // Constructors. - unique_ptr() - : _M_t(pointer(), deleter_type()) + constexpr unique_ptr() + : _M_t() { } explicit @@ -129,7 +131,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { static_assert(!std::is_reference<deleter_type>::value, "rvalue deleter bound to reference"); } - unique_ptr(nullptr_t) + constexpr unique_ptr(nullptr_t) : _M_t(pointer(), deleter_type()) { } @@ -271,7 +273,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) "constructed with null function pointer deleter"); // Constructors. - unique_ptr() + constexpr unique_ptr() : _M_t(pointer(), deleter_type()) { } @@ -292,7 +294,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) "rvalue deleter bound to reference"); } /* TODO: use delegating constructor */ - unique_ptr(nullptr_t) + constexpr unique_ptr(nullptr_t) : _M_t(pointer(), deleter_type()) { } diff --git a/libstdc++-v3/include/debug/bitset b/libstdc++-v3/include/debug/bitset index 739dcfd38f1..abbd8413a2b 100644 --- a/libstdc++-v3/include/debug/bitset +++ b/libstdc++-v3/include/debug/bitset @@ -41,37 +41,50 @@ namespace __debug /// Class std::bitset with additional safety/checking/debug instrumentation. template<size_t _Nb> class bitset - : public _GLIBCXX_STD_D::bitset<_Nb>, - public __gnu_debug::_Safe_sequence_base + : public _GLIBCXX_STD_D::bitset<_Nb> +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + , public __gnu_debug::_Safe_sequence_base +#endif { typedef _GLIBCXX_STD_D::bitset<_Nb> _Base; - typedef __gnu_debug::_Safe_sequence_base _Safe_base; public: // bit reference: class reference - : private _Base::reference, public __gnu_debug::_Safe_iterator_base + : private _Base::reference +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + , public __gnu_debug::_Safe_iterator_base +#endif { typedef typename _Base::reference _Base_ref; friend class bitset; reference(); - reference(const _Base_ref& __base, bitset* __seq) - : _Base_ref(__base), _Safe_iterator_base(__seq, false) + reference(const _Base_ref& __base, + bitset* __seq __attribute__((__unused__))) + : _Base_ref(__base) +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + , _Safe_iterator_base(__seq, false) +#endif { } public: reference(const reference& __x) - : _Base_ref(__x), _Safe_iterator_base(__x, false) + : _Base_ref(__x) +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + , _Safe_iterator_base(__x, false) +#endif { } reference& operator=(bool __x) { +#ifndef __GXX_EXPERIMENTAL_CXX0X__ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_write) ._M_iterator(*this)); +#endif *static_cast<_Base_ref*>(this) = __x; return *this; } @@ -79,12 +92,14 @@ namespace __debug reference& operator=(const reference& __x) { +#ifndef __GXX_EXPERIMENTAL_CXX0X__ _GLIBCXX_DEBUG_VERIFY(! __x._M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(__x)); _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_write) ._M_iterator(*this)); +#endif *static_cast<_Base_ref*>(this) = __x; return *this; } @@ -92,36 +107,42 @@ namespace __debug bool operator~() const { +#ifndef __GXX_EXPERIMENTAL_CXX0X__ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(*this)); +#endif return ~(*static_cast<const _Base_ref*>(this)); } operator bool() const { +#ifndef __GXX_EXPERIMENTAL_CXX0X__ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(*this)); +#endif return *static_cast<const _Base_ref*>(this); } reference& flip() { +#ifndef __GXX_EXPERIMENTAL_CXX0X__ _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_flip) ._M_iterator(*this)); +#endif _Base_ref::flip(); return *this; } }; // 23.3.5.1 constructors: - bitset() : _Base() { } + _GLIBCXX_CONSTEXPR bitset() : _Base() { } #ifdef __GXX_EXPERIMENTAL_CXX0X__ - bitset(unsigned long long __val) + constexpr bitset(unsigned long long __val) #else bitset(unsigned long __val) #endif @@ -147,7 +168,7 @@ namespace __debug _CharT __zero, _CharT __one = _CharT('1')) : _Base(__str, __pos, __n, __zero, __one) { } - bitset(const _Base& __x) : _Base(__x), _Safe_base() { } + bitset(const _Base& __x) : _Base(__x) { } #ifdef __GXX_EXPERIMENTAL_CXX0X__ template<typename _CharT> diff --git a/libstdc++-v3/include/profile/bitset b/libstdc++-v3/include/profile/bitset index b8b1e65f9e5..d7ecf81ff43 100644 --- a/libstdc++-v3/include/profile/bitset +++ b/libstdc++-v3/include/profile/bitset @@ -95,10 +95,10 @@ namespace __profile }; // 23.3.5.1 constructors: - bitset() : _Base() { } + _GLIBCXX_CONSTEXPR bitset() : _Base() { } #ifdef __GXX_EXPERIMENTAL_CXX0X__ - bitset(unsigned long long __val) + constexpr bitset(unsigned long long __val) #else bitset(unsigned long __val) #endif diff --git a/libstdc++-v3/include/profile/map.h b/libstdc++-v3/include/profile/map.h index 3f668af176c..5bc9ab9f81b 100644 --- a/libstdc++-v3/include/profile/map.h +++ b/libstdc++-v3/include/profile/map.h @@ -251,17 +251,22 @@ namespace __profile size_type size_before = size(); _Base::insert(__list); __profcxx_map_to_unordered_map_insert(this, size_before, - size() - size_before); + size() - size_before); } #endif iterator +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + insert(const_iterator __position, const value_type& __x) +#else insert(iterator __position, const value_type& __x) +#endif { size_type size_before = size(); - return iterator(_Base::insert(__position, __x)); + iterator __i = iterator(_Base::insert(__position, __x)); __profcxx_map_to_unordered_map_insert(this, size_before, - size() - size_before); + size() - size_before); + return __i; } template<typename _InputIterator> @@ -276,7 +281,7 @@ namespace __profile #ifdef __GXX_EXPERIMENTAL_CXX0X__ iterator - erase(iterator __position) + erase(const_iterator __position) { iterator __i = _Base::erase(__position); __profcxx_map_to_unordered_map_erase(this, size(), 1); @@ -306,31 +311,18 @@ namespace __profile #ifdef __GXX_EXPERIMENTAL_CXX0X__ iterator - erase(iterator __first, iterator __last) - { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 151. can't currently clear() empty container - while (__first != __last) - this->erase(__first++); - return __last; - } + erase(const_iterator __first, const_iterator __last) + { return iterator(_Base::erase(__first, __last)); } #else void erase(iterator __first, iterator __last) - { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 151. can't currently clear() empty container - while (__first != __last) - this->erase(__first++); - } + { _Base::erase(__first, __last); } #endif void swap(map& __x) - { - _Base::swap(__x); - } + { _Base::swap(__x); } void clear() diff --git a/libstdc++-v3/include/profile/multimap.h b/libstdc++-v3/include/profile/multimap.h index 2897614050c..6fe7f5bc0d9 100644 --- a/libstdc++-v3/include/profile/multimap.h +++ b/libstdc++-v3/include/profile/multimap.h @@ -192,22 +192,22 @@ namespace __profile #endif iterator +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + insert(const_iterator __position, const value_type& __x) +#else insert(iterator __position, const value_type& __x) - { - return iterator(_Base::insert(__position, __x)); - } +#endif + { return iterator(_Base::insert(__position, __x)); } template<typename _InputIterator> void insert(_InputIterator __first, _InputIterator __last) - { - _Base::insert(__first, __last); - } + { _Base::insert(__first, __last); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ iterator - erase(iterator __position) - { return _Base::erase(__position); } + erase(const_iterator __position) + { return iterator(_Base::erase(__position)); } #else void erase(iterator __position) @@ -230,30 +230,17 @@ namespace __profile #ifdef __GXX_EXPERIMENTAL_CXX0X__ iterator - erase(iterator __first, iterator __last) - { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 151. can't currently clear() empty container - while (__first != __last) - this->erase(__first++); - return __last; - } + erase(const_iterator __first, const_iterator __last) + { return iterator(_Base::erase(__first, __last)); } #else void erase(iterator __first, iterator __last) - { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 151. can't currently clear() empty container - while (__first != __last) - this->erase(__first++); - } + { _Base::erase(__first, __last); } #endif void swap(multimap& __x) - { - _Base::swap(__x); - } + { _Base::swap(__x); } void clear() diff --git a/libstdc++-v3/include/profile/multiset.h b/libstdc++-v3/include/profile/multiset.h index 3c113ef88d5..d66fa0cd97c 100644 --- a/libstdc++-v3/include/profile/multiset.h +++ b/libstdc++-v3/include/profile/multiset.h @@ -184,17 +184,17 @@ namespace __profile { return iterator(_Base::insert(__x)); } iterator +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + insert(const_iterator __position, const value_type& __x) +#else insert(iterator __position, const value_type& __x) - { - return iterator(_Base::insert(__position, __x)); - } +#endif + { return iterator(_Base::insert(__position, __x)); } template<typename _InputIterator> - void - insert(_InputIterator __first, _InputIterator __last) - { - _Base::insert(__first, __last); - } + void + insert(_InputIterator __first, _InputIterator __last) + { _Base::insert(__first, __last); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ void @@ -204,8 +204,8 @@ namespace __profile #ifdef __GXX_EXPERIMENTAL_CXX0X__ iterator - erase(iterator __position) - { return _Base::erase(__position); } + erase(const_iterator __position) + { return iterator(_Base::erase(__position)); } #else void erase(iterator __position) @@ -228,30 +228,17 @@ namespace __profile #ifdef __GXX_EXPERIMENTAL_CXX0X__ iterator - erase(iterator __first, iterator __last) - { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 151. can't currently clear() empty container - while (__first != __last) - this->erase(__first++); - return __last; - } + erase(const_iterator __first, const_iterator __last) + { return iterator(_Base::erase(__first, __last)); } #else void erase(iterator __first, iterator __last) - { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 151. can't currently clear() empty container - while (__first != __last) - this->erase(__first++); - } + { _Base::erase(__first, __last); } #endif void swap(multiset& __x) - { - _Base::swap(__x); - } + { _Base::swap(__x); } void clear() diff --git a/libstdc++-v3/include/profile/set.h b/libstdc++-v3/include/profile/set.h index 42acf72699a..f6941ebbee9 100644 --- a/libstdc++-v3/include/profile/set.h +++ b/libstdc++-v3/include/profile/set.h @@ -189,17 +189,17 @@ namespace __profile } iterator +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + insert(const_iterator __position, const value_type& __x) +#else insert(iterator __position, const value_type& __x) - { - return iterator(_Base::insert(__position, __x)); - } +#endif + { return iterator(_Base::insert(__position, __x)); } template <typename _InputIterator> void insert(_InputIterator __first, _InputIterator __last) - { - _Base::insert(__first, __last); - } + { _Base::insert(__first, __last); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ void @@ -209,8 +209,8 @@ namespace __profile #ifdef __GXX_EXPERIMENTAL_CXX0X__ iterator - erase(iterator __position) - { return _Base::erase(__position); } + erase(const_iterator __position) + { return iterator(_Base::erase(__position)); } #else void erase(iterator __position) @@ -232,30 +232,17 @@ namespace __profile #ifdef __GXX_EXPERIMENTAL_CXX0X__ iterator - erase(iterator __first, iterator __last) - { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 151. can't currently clear() empty container - while (__first != __last) - this->erase(__first++); - return __last; - } + erase(const_iterator __first, const_iterator __last) + { return iterator(_Base::erase(__first, __last)); } #else void erase(iterator __first, iterator __last) - { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 151. can't currently clear() empty container - while (__first != __last) - this->erase(__first++); - } + { _Base::erase(__first, __last); } #endif void swap(set& __x) - { - _Base::swap(__x); - } + { _Base::swap(__x); } void clear() diff --git a/libstdc++-v3/include/profile/unordered_map b/libstdc++-v3/include/profile/unordered_map index 18563d87508..49345cc53ae 100644 --- a/libstdc++-v3/include/profile/unordered_map +++ b/libstdc++-v3/include/profile/unordered_map @@ -232,17 +232,27 @@ namespace __profile _Base::insert(__first, __last); _M_profile_resize(__old_size, _Base::bucket_count()); } - - // operator [] + + // operator[] + mapped_type& + operator[](const _Key& __k) + { + size_type __old_size = _Base::bucket_count(); + mapped_type& __res = _M_base()[__k]; + size_type __new_size = _Base::bucket_count(); + _M_profile_resize(__old_size, _Base::bucket_count()); + return __res; + } + mapped_type& - operator[](const _Key& _k) + operator[](_Key&& __k) { size_type __old_size = _Base::bucket_count(); - mapped_type& __res = _M_base()[_k]; + mapped_type& __res = _M_base()[std::move(__k)]; size_type __new_size = _Base::bucket_count(); _M_profile_resize(__old_size, _Base::bucket_count()); return __res; - } + } void swap(unordered_map& __x) diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 46a198c7e92..ffdadc3757e 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -447,17 +447,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) //@{ /// Return true if @a x is equal to @a y. template<typename _Tp> - inline bool + inline _GLIBCXX_CONSTEXPR bool operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __x.real() == __y.real() && __x.imag() == __y.imag(); } template<typename _Tp> - inline bool + inline _GLIBCXX_CONSTEXPR bool operator==(const complex<_Tp>& __x, const _Tp& __y) { return __x.real() == __y && __x.imag() == _Tp(); } template<typename _Tp> - inline bool + inline _GLIBCXX_CONSTEXPR bool operator==(const _Tp& __x, const complex<_Tp>& __y) { return __x == __y.real() && _Tp() == __y.imag(); } //@} @@ -465,17 +465,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) //@{ /// Return false if @a x is equal to @a y. template<typename _Tp> - inline bool + inline _GLIBCXX_CONSTEXPR bool operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) { return __x.real() != __y.real() || __x.imag() != __y.imag(); } template<typename _Tp> - inline bool + inline _GLIBCXX_CONSTEXPR bool operator!=(const complex<_Tp>& __x, const _Tp& __y) { return __x.real() != __y || __x.imag() != _Tp(); } template<typename _Tp> - inline bool + inline _GLIBCXX_CONSTEXPR bool operator!=(const _Tp& __x, const complex<_Tp>& __y) { return __x != __y.real() || _Tp() != __y.imag(); } //@} diff --git a/libstdc++-v3/testsuite/20_util/default_delete/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/default_delete/cons/constexpr.cc index 897394a57b2..091f1b6fc36 100644 --- a/libstdc++-v3/testsuite/20_util/default_delete/cons/constexpr.cc +++ b/libstdc++-v3/testsuite/20_util/default_delete/cons/constexpr.cc @@ -1,4 +1,4 @@ -// { dg-do compile { xfail *-*-* } } +// { dg-do compile } // { dg-options "-std=gnu++0x" } // Copyright (C) 2010 Free Software Foundation, Inc. @@ -24,6 +24,6 @@ int main() { __gnu_test::constexpr_default_constructible test; - test.operator()<std::default_delete<int>>(); // { dg-excess-errors "" } + test.operator()<std::default_delete<int>>(); return 0; } diff --git a/libstdc++-v3/testsuite/20_util/duration/comparisons/1.cc b/libstdc++-v3/testsuite/20_util/duration/comparison_operators/1.cc index 31ac42ddcee..35151f2ad54 100644 --- a/libstdc++-v3/testsuite/20_util/duration/comparisons/1.cc +++ b/libstdc++-v3/testsuite/20_util/duration/comparison_operators/1.cc @@ -1,12 +1,12 @@ // { dg-options "-std=gnu++0x" } // { dg-require-cstdint "" } -// Copyright (C) 2008 Free Software Foundation +// Copyright (C) 2008, 2009 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, or (at your option) +// Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, @@ -15,9 +15,8 @@ // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -// USA. +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. // 20.8.3 Class template duration [time.duration] diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/duration/comparison_operators/constexpr.cc index 20db7615ba8..94338cee316 100644 --- a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc +++ b/libstdc++-v3/testsuite/20_util/duration/comparison_operators/constexpr.cc @@ -1,4 +1,4 @@ -// { dg-do compile { xfail *-*-* } } +// { dg-do compile } // { dg-options "-std=gnu++0x" } // Copyright (C) 2010 Free Software Foundation, Inc. @@ -18,15 +18,12 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -#include <memory> +#include <chrono> #include <testsuite_common_types.h> int main() { - __gnu_test::constexpr_default_constructible test1; - test1.operator()<std::unique_ptr<int>>(); // { dg-excess-errors "" } - - __gnu_test::constexpr_single_value_constructible test2; - test2.operator()<std::unique_ptr<int>, std::nullptr_t>(); // { dg-excess-errors "" } + __gnu_test::constexpr_comparison_operators test; + test.operator()<std::chrono::nanoseconds>(); return 0; } diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc index 3b43769bff3..6669a1e89f8 100644 --- a/libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc +++ b/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc @@ -1,5 +1,6 @@ -// { dg-do compile { xfail *-*-* } } // { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2010 Free Software Foundation, Inc. // @@ -18,15 +19,12 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -#include <memory> -#include <testsuite_common_types.h> +// NB: This file is for testing type_traits with NO OTHER INCLUDES. -int main() +#include <type_traits> + +namespace std { - __gnu_test::constexpr_default_constructible test; - test.operator()<std::weak_ptr<int>>(); // { dg-excess-errors "" } - // test.operator()<std::__weak_ptr<int>>(); - // test.operator()<std::__weak_count<__gnu_cxx::__default_lock_policy>>(); - // test.operator()<std::_Sp_counted_base<__gnu_cxx::__default_lock_policy>>(); - return 0; + typedef short test_type; + template struct is_literal_type<test_type>; } diff --git a/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/typedefs.cc new file mode 100644 index 00000000000..25bc88f29fb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_literal_type<int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_literal_type/value.cc b/libstdc++-v3/testsuite/20_util/is_literal_type/value.cc new file mode 100644 index 00000000000..77a6902b768 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_literal_type/value.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-23 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_literal_type; + using namespace __gnu_test; + + VERIFY( (test_category<is_literal_type, int>(true)) ); + VERIFY( (test_category<is_literal_type, unsigned char>(true)) ); + + VERIFY( (test_category<is_literal_type, TType>(true)) ); + VERIFY( (test_category<is_literal_type, PODType>(true)) ); + + VERIFY( (test_category<is_literal_type, NType>(false)) ); + VERIFY( (test_category<is_literal_type, SLType>(false)) ); + + VERIFY( (test_category<is_literal_type, LType>(true)) ); + VERIFY( (test_category<is_literal_type, LType[5]>(true)) ); + + VERIFY( (test_category<is_literal_type, NLType>(false)) ); + VERIFY( (test_category<is_literal_type, NLType[5]>(false)) ); + + VERIFY( (test_category<is_literal_type, LTypeDerived>(true)) ); + VERIFY( (test_category<is_literal_type, LTypeDerived[5]>(true)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc b/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc index fa4c85ee77e..e7f448deca1 100644 --- a/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc +++ b/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc @@ -52,6 +52,6 @@ test04() // { dg-error "denominator cannot be zero" "" { target *-*-* } 153 } // { dg-error "out of range" "" { target *-*-* } 154 } // { dg-error "non-constant expression" "" { target *-*-* } 59 } -// { dg-error "is not a constant expression" "" { target *-*-* } 59 } +// { dg-error "overflow in constant expression" "" { target *-*-* } 59 } // { dg-error "not a member" "" { target *-*-* } 162 } // { dg-error "not a valid template argument" "" { target *-*-* } 164 } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc index fb6cc8f5b72..f30fd35c182 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc @@ -32,9 +32,9 @@ void test01() { X* px = 0; std::shared_ptr<X> p1(px); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 762 } + // { dg-error "incomplete" "" { target *-*-* } 764 } std::shared_ptr<X> p9(ap()); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 854 } + // { dg-error "incomplete" "" { target *-*-* } 856 } } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/time_point/comparison_operators/constexpr.cc index d040ea49666..427c5137021 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc +++ b/libstdc++-v3/testsuite/20_util/time_point/comparison_operators/constexpr.cc @@ -1,4 +1,4 @@ -// { dg-do compile { xfail *-*-* } } +// { dg-do compile } // { dg-options "-std=gnu++0x" } // Copyright (C) 2010 Free Software Foundation, Inc. @@ -18,16 +18,13 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -#include <memory> +#include <chrono> #include <testsuite_common_types.h> int main() { - __gnu_test::constexpr_default_constructible test1; - test1.operator()<std::shared_ptr<int>>(); // { dg-excess-errors "" } - - __gnu_test::constexpr_single_value_constructible test2; - test2.operator()<std::shared_ptr<int>, std::nullptr_t>(); // { dg-excess-errors "" } - + using namespace std::chrono; + __gnu_test::constexpr_comparison_operators test; + test.operator()<time_point<system_clock>>(); return 0; } diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc index 42a4da992a4..4bc950f1c8a 100644 --- a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc @@ -41,9 +41,9 @@ main() return 0; } -// { dg-warning "note" "" { target *-*-* } 347 } -// { dg-warning "note" "" { target *-*-* } 1079 } -// { dg-warning "note" "" { target *-*-* } 465 } +// { dg-warning "note" "" { target *-*-* } 350 } +// { dg-warning "note" "" { target *-*-* } 1082 } +// { dg-warning "note" "" { target *-*-* } 467 } // { dg-warning "note" "" { target *-*-* } 580 } // { dg-warning "note" "" { target *-*-* } 1027 } // { dg-warning "note" "" { target *-*-* } 340 } diff --git a/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc b/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc new file mode 100644 index 00000000000..85c3ab7b4aa --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <complex> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_comparison_eq_ne test; + test.operator()<std::complex<float>>(); + test.operator()<std::complex<float>, float>(); + test.operator()<float,std::complex<float>>(); + + test.operator()<std::complex<double>>(); + test.operator()<std::complex<double>, double>(); + test.operator()<double,std::complex<double>>(); + + test.operator()<std::complex<long double>>(); + test.operator()<std::complex<long double>, long double>(); + test.operator()<long double,std::complex<long double>>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc index 9272c7eb3da..6b04cf81db0 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc @@ -28,5 +28,5 @@ int main() return 0; } -// { dg-error "deleted" "" { target *-*-* } 544 } +// { dg-error "deleted" "" { target *-*-* } 571 } // { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc index 19b3a150c19..cdd95fd1b49 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc @@ -28,5 +28,5 @@ int main() return 0; } -// { dg-error "deleted" "" { target *-*-* } 583 } +// { dg-error "deleted" "" { target *-*-* } 610 } // { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc index 12da321abd8..265878d39df 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc @@ -29,5 +29,5 @@ int main() return 0; } -// { dg-error "deleted" "" { target *-*-* } 544 } +// { dg-error "deleted" "" { target *-*-* } 571 } // { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc index e334f1b0447..acb8006ac46 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc @@ -29,5 +29,5 @@ int main() return 0; } -// { dg-error "deleted" "" { target *-*-* } 583 } +// { dg-error "deleted" "" { target *-*-* } 610 } // { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/integral_constant/requirements/constexpr_data.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/integral_constant/requirements/constexpr_data.cc new file mode 100644 index 00000000000..52497e1f443 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/integral_constant/requirements/constexpr_data.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_data + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v __attribute__((unused)) (_Ttesttype::value); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + test.operator()<std::integral_constant<unsigned short, 69>>(); + test.operator()<std::integral_constant<bool, true>>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/util/exception/safety.h b/libstdc++-v3/testsuite/util/exception/safety.h index cab31e22854..9468bffd8d5 100644 --- a/libstdc++-v3/testsuite/util/exception/safety.h +++ b/libstdc++-v3/testsuite/util/exception/safety.h @@ -251,91 +251,93 @@ namespace __gnu_test struct erase_base { typedef typename _Tp::iterator iterator; + typedef typename _Tp::const_iterator const_iterator; - iterator (_Tp::* _F_erase_point)(iterator); - iterator (_Tp::* _F_erase_range)(iterator, iterator); + iterator (_Tp::* _F_erase_point)(const_iterator); + iterator (_Tp::* _F_erase_range)(const_iterator, const_iterator); erase_base() : _F_erase_point(&_Tp::erase), _F_erase_range(&_Tp::erase) { } }; - // Specialization, as forward_list has erase_after. - template<typename _Tp1, typename _Tp2> - struct erase_base<std::forward_list<_Tp1, _Tp2>> + // Specializations, old C++03 signatures. + template<typename _Tp1, typename _Tp2, typename _Tp3> + struct erase_base<std::basic_string<_Tp1, _Tp2, _Tp3>> { - typedef std::forward_list<_Tp1, _Tp2> container_type; + typedef std::basic_string<_Tp1, _Tp2, _Tp3> container_type; typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; - iterator (container_type::* _F_erase_point)(const_iterator); - iterator (container_type::* _F_erase_range)(const_iterator, - const_iterator); + iterator (container_type::* _F_erase_point)(iterator); + iterator (container_type::* _F_erase_range)(iterator, iterator); erase_base() - : _F_erase_point(&container_type::erase_after), - _F_erase_range(&container_type::erase_after) { } + : _F_erase_point(&container_type::erase), + _F_erase_range(&container_type::erase) { } }; - // Specializations for the unordered containers. template<typename _Tp1, typename _Tp2, typename _Tp3, - typename _Tp4, typename _Tp5> - struct erase_base<std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>> + template <typename, typename, typename> class _Tp4> + struct erase_base<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>> { - typedef std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5> + typedef __gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4> container_type; typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; - iterator (container_type::* _F_erase_point)(const_iterator); - iterator (container_type::* _F_erase_range)(const_iterator, - const_iterator); + iterator (container_type::* _F_erase_point)(iterator); + iterator (container_type::* _F_erase_range)(iterator, iterator); erase_base() : _F_erase_point(&container_type::erase), _F_erase_range(&container_type::erase) { } }; - template<typename _Tp1, typename _Tp2, typename _Tp3, - typename _Tp4, typename _Tp5> - struct erase_base<std::unordered_multimap<_Tp1, _Tp2, _Tp3, - _Tp4, _Tp5>> + template<typename _Tp1, typename _Tp2> + struct erase_base<std::deque<_Tp1, _Tp2>> { - typedef std::unordered_multimap<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5> - container_type; + typedef std::deque<_Tp1, _Tp2> container_type; typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; - iterator (container_type::* _F_erase_point)(const_iterator); - iterator (container_type::* _F_erase_range)(const_iterator, - const_iterator); + iterator (container_type::* _F_erase_point)(iterator); + iterator (container_type::* _F_erase_range)(iterator, iterator); + + erase_base() + : _F_erase_point(&container_type::erase), + _F_erase_range(&container_type::erase) { } + }; + + template<typename _Tp1, typename _Tp2> + struct erase_base<std::list<_Tp1, _Tp2>> + { + typedef std::list<_Tp1, _Tp2> container_type; + typedef typename container_type::iterator iterator; + + iterator (container_type::* _F_erase_point)(iterator); + iterator (container_type::* _F_erase_range)(iterator, iterator); erase_base() : _F_erase_point(&container_type::erase), _F_erase_range(&container_type::erase) { } }; - template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4> - struct erase_base<std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4>> + template<typename _Tp1, typename _Tp2> + struct erase_base<std::vector<_Tp1, _Tp2>> { - typedef std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4> - container_type; + typedef std::vector<_Tp1, _Tp2> container_type; typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; - iterator (container_type::* _F_erase_point)(const_iterator); - iterator (container_type::* _F_erase_range)(const_iterator, - const_iterator); + iterator (container_type::* _F_erase_point)(iterator); + iterator (container_type::* _F_erase_range)(iterator, iterator); erase_base() : _F_erase_point(&container_type::erase), _F_erase_range(&container_type::erase) { } }; - template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4> - struct erase_base<std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4>> + // Specialization, as forward_list has erase_after. + template<typename _Tp1, typename _Tp2> + struct erase_base<std::forward_list<_Tp1, _Tp2>> { - typedef std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4> - container_type; + typedef std::forward_list<_Tp1, _Tp2> container_type; typedef typename container_type::iterator iterator; typedef typename container_type::const_iterator const_iterator; @@ -344,8 +346,8 @@ namespace __gnu_test const_iterator); erase_base() - : _F_erase_point(&container_type::erase), - _F_erase_range(&container_type::erase) { } + : _F_erase_point(&container_type::erase_after), + _F_erase_range(&container_type::erase_after) { } }; template<typename _Tp, @@ -633,109 +635,87 @@ namespace __gnu_test struct insert_base { typedef typename _Tp::iterator iterator; + typedef typename _Tp::const_iterator const_iterator; typedef typename _Tp::value_type value_type; - iterator (_Tp::* _F_insert_point)(iterator, const value_type&); + iterator (_Tp::* _F_insert_point)(const_iterator, const value_type&); insert_base() : _F_insert_point(&_Tp::insert) { } }; - // Specialization, as string insertion has a different signature. - template<typename _Tp1, typename _Tp2, typename _Tp3> - struct insert_base<std::basic_string<_Tp1, _Tp2, _Tp3>> + // Specializations, old C++03 signatures. + template<typename _Tp1, typename _Tp2> + struct insert_base<std::deque<_Tp1, _Tp2>> { - typedef std::basic_string<_Tp1, _Tp2, _Tp3> container_type; + typedef std::deque<_Tp1, _Tp2> container_type; typedef typename container_type::iterator iterator; typedef typename container_type::value_type value_type; - iterator (container_type::* _F_insert_point)(iterator, value_type); + iterator (container_type::* _F_insert_point)(iterator, + const value_type&); insert_base() : _F_insert_point(&container_type::insert) { } }; - template<typename _Tp1, typename _Tp2, typename _Tp3, - template <typename, typename, typename> class _Tp4> - struct insert_base<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>> + template<typename _Tp1, typename _Tp2> + struct insert_base<std::list<_Tp1, _Tp2>> { - typedef __gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4> - container_type; + typedef std::list<_Tp1, _Tp2> container_type; typedef typename container_type::iterator iterator; typedef typename container_type::value_type value_type; - iterator (container_type::* _F_insert_point)(iterator, value_type); + iterator (container_type::* _F_insert_point)(iterator, + const value_type&); insert_base() : _F_insert_point(&container_type::insert) { } }; - // Specialization, as forward_list insertion has a different signature. template<typename _Tp1, typename _Tp2> - struct insert_base<std::forward_list<_Tp1, _Tp2>> + struct insert_base<std::vector<_Tp1, _Tp2>> { - typedef std::forward_list<_Tp1, _Tp2> container_type; + typedef std::vector<_Tp1, _Tp2> container_type; typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; typedef typename container_type::value_type value_type; - iterator (container_type::* _F_insert_point)(const_iterator, - const value_type&); - - insert_base() : _F_insert_point(&container_type::insert_after) { } - }; - - // Likewise for the unordered containers. - template<typename _Tp1, typename _Tp2, typename _Tp3, - typename _Tp4, typename _Tp5> - struct insert_base<std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>> - { - typedef std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5> - container_type; - typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; - typedef typename container_type::value_type value_type; - - iterator (container_type::* _F_insert_point)(const_iterator, + iterator (container_type::* _F_insert_point)(iterator, const value_type&); insert_base() : _F_insert_point(&container_type::insert) { } }; - template<typename _Tp1, typename _Tp2, typename _Tp3, - typename _Tp4, typename _Tp5> - struct insert_base<std::unordered_multimap<_Tp1, _Tp2, _Tp3, - _Tp4, _Tp5>> + // Specialization, as string insertion has a different signature. + template<typename _Tp1, typename _Tp2, typename _Tp3> + struct insert_base<std::basic_string<_Tp1, _Tp2, _Tp3>> { - typedef std::unordered_multimap<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5> - container_type; + typedef std::basic_string<_Tp1, _Tp2, _Tp3> container_type; typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; typedef typename container_type::value_type value_type; - iterator (container_type::* _F_insert_point)(const_iterator, - const value_type&); + iterator (container_type::* _F_insert_point)(iterator, value_type); insert_base() : _F_insert_point(&container_type::insert) { } }; - template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4> - struct insert_base<std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4>> + // Likewise for __versa_string. + template<typename _Tp1, typename _Tp2, typename _Tp3, + template <typename, typename, typename> class _Tp4> + struct insert_base<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>> { - typedef std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4> + typedef __gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4> container_type; typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; typedef typename container_type::value_type value_type; - iterator (container_type::* _F_insert_point)(const_iterator, - const value_type&); + iterator (container_type::* _F_insert_point)(iterator, value_type); insert_base() : _F_insert_point(&container_type::insert) { } }; - template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4> - struct insert_base<std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4>> + // Specialization, as forward_list has insert_after. + template<typename _Tp1, typename _Tp2> + struct insert_base<std::forward_list<_Tp1, _Tp2>> { - typedef std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4> - container_type; + typedef std::forward_list<_Tp1, _Tp2> container_type; typedef typename container_type::iterator iterator; typedef typename container_type::const_iterator const_iterator; typedef typename container_type::value_type value_type; @@ -743,7 +723,7 @@ namespace __gnu_test iterator (container_type::* _F_insert_point)(const_iterator, const value_type&); - insert_base() : _F_insert_point(&container_type::insert) { } + insert_base() : _F_insert_point(&container_type::insert_after) { } }; template<typename _Tp, diff --git a/libstdc++-v3/testsuite/util/testsuite_common_types.h b/libstdc++-v3/testsuite/util/testsuite_common_types.h index a402bcf6b48..c78f9450417 100644 --- a/libstdc++-v3/testsuite/util/testsuite_common_types.h +++ b/libstdc++-v3/testsuite/util/testsuite_common_types.h @@ -462,8 +462,35 @@ namespace __gnu_test } }; - // Generator to test standard layout #ifdef __GXX_EXPERIMENTAL_CXX0X__ + + struct constexpr_comparison_eq_ne + { + template<typename _Tp1, typename _Tp2 = _Tp1> + void + operator()() + { + static_assert(_Tp1() == _Tp2(), "eq"); + static_assert(!(_Tp1() != _Tp2()), "ne"); + } + }; + + struct constexpr_comparison_operators + { + template<typename _Tp> + void + operator()() + { + static_assert(!(_Tp() < _Tp()), "less"); + static_assert(_Tp() <= _Tp(), "leq"); + static_assert(!(_Tp() > _Tp()), "more"); + static_assert(_Tp() >= _Tp(), "meq"); + static_assert(_Tp() == _Tp(), "eq"); + static_assert(!(_Tp() != _Tp()), "ne"); + } + }; + + // Generator to test standard layout struct has_trivial_cons_dtor { template<typename _Tp> @@ -615,6 +642,7 @@ namespace __gnu_test // Generator to test default constructor. struct constexpr_default_constructible { + // NB: _Tp must be a literal type. template<typename _Tp> void operator()() @@ -633,6 +661,7 @@ namespace __gnu_test struct constexpr_single_value_constructible { + // NB: _Tbasetype and _Ttesttype must be literal types. template<typename _Ttesttype, typename _Tbasetype> void operator()() diff --git a/libstdc++-v3/testsuite/util/testsuite_tr1.h b/libstdc++-v3/testsuite/util/testsuite_tr1.h index 5aac18292bb..6a48a309e18 100644 --- a/libstdc++-v3/testsuite/util/testsuite_tr1.h +++ b/libstdc++-v3/testsuite/util/testsuite_tr1.h @@ -57,7 +57,7 @@ namespace __gnu_test // For testing tr1/type_traits/extent, which has a second template // parameter. template<template<typename, unsigned> class Property, - typename Type, unsigned Uint> + typename Type, unsigned Uint> bool test_property(typename Property<Type, Uint>::value_type value) { @@ -80,7 +80,7 @@ namespace __gnu_test #endif template<template<typename, typename> class Relationship, - typename Type1, typename Type2> + typename Type1, typename Type2> bool test_relationship(bool value) { @@ -188,6 +188,33 @@ namespace __gnu_test int j; }; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + struct LType // literal type + { + int _M_i; + + constexpr LType(int __i) : _M_i(__i) { } + }; + + struct LTypeDerived : public LType + { + constexpr LTypeDerived(int __i) : LType(__i) { } + }; + + struct NLType // not literal type + { + int _M_i; + + NLType() : _M_i(0) { } + + constexpr NLType(int __i) : _M_i(__i) { } + + NLType(const NLType& __other) : _M_i(__other._M_i) { } + + ~NLType() { _M_i = 0; } + }; +#endif + int truncate_float(float x) { return (int)x; } long truncate_double(double x) { return (long)x; } @@ -251,7 +278,7 @@ namespace __gnu_test // For use in 8_c_compatibility. template<typename R, typename T> - typename __gnu_cxx::__enable_if<std::__are_same<R, T>::__value, + typename __gnu_cxx::__enable_if<std::__are_same<R, T>::__value, bool>::__type check_ret_type(T) { return true; } |