diff options
Diffstat (limited to 'gcc')
104 files changed, 1830 insertions, 745 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 21204a009ec..2564a7df092 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,215 @@ +2011-05-23 Joseph Myers <joseph@codesourcery.com> + + * optc-save-gen.awk: New. Based on optc-gen.awk. Don't generate + parts of output shared with the driver. + * optc-gen.awk: Don't generate parts of output not shared with the + driver. + * opth-gen.awk: Remove GCC_DRIVER conditionals. + * doc/options.texi (SourcerInclude): Mention options-save.c. + * Makefile.in (GCC_OBJS): Use options.o instead of gcc-options.o. + (OBJS): Add options-save.o. + (options-save.c, options-save.o): New. + (options.o): Update dependencies. + (gcc-options.o): Remove. + (mostlyclean): Remove options-save.c. + +2011-05-23 Jakub Jelinek <jakub@redhat.com> + + PR debug/49032 + * dbxout.c: Include cgraph.h. + (dbxout_expand_expr): If a VAR_DECL is TREE_STATIC, not written + and without value expr, return NULL if no varpool node exists for + it or if it is not needed. + * Makefile.in (dbxout.o): Depend on $(CGRAPH_H). + + PR c/49120 + * c-decl.c (start_decl): Convert expr to void_type_node. + +2011-05-23 Richard Sandiford <rdsandiford@googlemail.com> + + PR rtl-optimization/48826 + * emit-rtl.c (try_split): When splitting a call that is followed + by a NOTE_INSN_CALL_ARG_LOCATION, move the note after the new call. + +2011-05-23 Jakub Jelinek <jakub@redhat.com> + + * cfgexpand.c (expand_debug_expr): For unused non-addressable + parameters passed in memory prefer using DECL_INCOMING_RTL over + the pseudos it will be copied into. + +2011-05-23 H.J. Lu <hongjiu.lu@intel.com> + + PR target/47315 + * config/i386/i386.c (ix86_option_override_internal): Save the + initial options after checking vzeroupper. + +2011-05-23 David Li <davidxl@google.com> + + PR tree-optimization/48988 + * tree-ssa-uninit.c (convert_control_dep_chain_into_preds): + Initialize has_valid_pred for each pred chain. + +2011-05-23 Richard Guenther <rguenther@suse.de> + + * gimple.c (gimple_types_compatible_p_1): Always compare type names. + (iterative_hash_gimple_type): Always hash type names. + +2011-05-23 Nathan Froyd <froydnj@codesourcery.com> + + * c-typeck.c (build_function_call_vec): Tweak call to + check_function_arguments. + +2011-05-23 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/49115 + * tree-ssa-alias.c (stmt_kills_ref_p_1): If the assignment + is not necessarily carried out, do not claim it kills the ref. + * tree-ssa-dce.c (mark_aliased_reaching_defs_necessary_1): Likewise. + +2011-05-23 Richard Guenther <rguenther@suse.de> + + PR middle-end/15419 + * builtins.c (fold_builtin_memory_op): Be less restrictive about + what pointer types we accept for folding. + +2011-05-23 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + * gthr-gnat.c: Remove. + * gthr-gnat.h: Remove. + * Makefile.in (LIB2ADDEH): Remove $(srcdir)/gthr-gnat.c. + * config/t-freebsd (LIB2ADDEH): Likewise. + * config/t-linux (LIB2ADDEH): Likewise. + * config/t-sol2 (LIB2ADDEH): Likewise. + * config/ia64/t-vms (LIB2ADDEH): Likewise. + * configure.ac (target_thread_file): Remove gnat handling. + * configure: Regenerate. + * doc/install.texi (Configuration, --enable-threads): Remove gnat. + +2011-05-23 Tristan Gingold <gingold@adacore.com> + Eric Botcazou <ebotcazou@adacore.com> + + * gcov.c (create_file_names): If no object directory is specified, + keep the directory of the file. + +2011-05-23 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + * configure.ac (enable_threads): Remove irix; add lynx, tpf; sort list. + * configure: Regenerate. + +2011-05-23 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/48973 + * expr.c (expand_expr_real_2) <case LT_EXPR>: If do_store_flag + failed and the comparison has a single bit signed type, use + constm1_rtx instead of const1_rtx for true value. + (do_store_flag): If ops->type is single bit signed type, disable + signel bit test optimization and pass -1 instead of 1 as last + parameter to emit_store_flag_force. + +2011-05-23 Tom de Vries <tom@codesourcery.com> + + PR target/45098 + * tree-ssa-loop-niter.c (infer_loop_bounds_from_pointer_arith): New + function. + (infer_loop_bounds_from_undefined): Use new function. + +2011-05-22 Richard Sandiford <rdsandiford@googlemail.com> + + * config/mips/mips.h (SUBTARGET_ASM_OPTIMIZING_SPEC): Delete. + (ASM_SPEC): Add a -O* option here. Pass -O0 for -noasmopt, + -O1 for -fno-delayed-branch, -O2 if optimization is enabled, + and -O0 otherwise. + (EXTRA_SPECS): Remove subtarget_asm_optimizing_spec. + +2011-05-22 Eric Botcazou <ebotcazou@adacore.com> + + * cfgcleanup.c (try_forward_edges): Do not update BB_FORWARDER_BLOCK. + (try_optimize_cfg): Update BB_FORWARDER_BLOCK if try_forward_edges + returns true. + +2011-05-22 Richard Sandiford <rdsandiford@googlemail.com> + + * config/mips/mips.c (mips_default_arch): Honor MIPS_ISA_DEFAULT. + +2011-05-22 Eric Botcazou <ebotcazou@adacore.com> + + * config/sparc/sparc.c (sparc_delegitimize_address): Handle + UNSPEC_MOVE_PIC pattern. + +2011-05-22 Eric Botcazou <ebotcazou@adacore.com> + + * config.gcc (sparc-*-elf*): Add sparc/t-crtin. + (sparc-*-rtems*): Likewise. + (sparc64-*-elf*): Likewise. + (sparc64-*-rtems*): Likewise. + (sparc*-*-solaris2*): Likewise. Remove crti.o crtn.o extra parts. + * config/sparc/t-crtin: New file. + * config/sparc/t-sol2 (crti.o): Delete rule. + (crtn.o): Likewise. + * config/sparc/t-linux64 (EXTRA_MULTILIB_PARTS): Delete. + * config/sparc/t-sol2-64 (EXTRA_MULTILIB_PARTS): Likewise. + * config/sparc/sp64-elf.h (STARTFILE_SPEC): Tidy and add crti.o. + (ENDFILE_SPEC): Add crtn.o. + +2011-05-22 Tom de Vries <tom@codesourcery.com> + + PR middle-end/48689 + * fold-const.c (fold_checksum_tree): Guard TREE_CHAIN use with + CODE_CONTAINS_STRUCT (TS_COMMON). + +2011-05-22 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/49029 + * expmed.c (extract_fixed_bit_field): Test whether target can be used + only after deciding which mode to use. + +2011-05-22 Tom de Vries <tom@codesourcery.com> + + PR target/45098 + * tree-ssa-loop-ivopts.c (force_expr_to_var_cost): Fix const test + for call to get_shiftadd_cost. + +2011-05-22 Uros Bizjak <ubizjak@gmail.com> + + PR target/49104 + * config/i386/cpuid.h (bit_MMXEXT): New define. + +2011-05-22 Nick Clifton <nickc@redhat.com> + + * config/stormy16/stormy16.c (xstormy16_init_builtins): prevent + initialisation of non-existant args[2] element. Use args[] array + not arg[] array to pass arguments to build_function_type_list. + +2011-05-22 Ira Rosen <ira.rosen@linaro.org> + + PR tree-optimization/49087 + * tree-vect-loop.c (vect_is_slp_reduction): Fail if LHS has no uses. + +2011-05-21 Jason Merrill <jason@redhat.com> + + PR c++/49092 + * dwarf2out.c (tree_add_const_value_attribute_for_decl): Check for + static storage duration. + +2011-05-21 Eric Botcazou <ebotcazou@adacore.com> + + * config/sparc/sparc.md (setjmp): Handle PIC mode and use the hard + frame pointer. + +2011-05-21 Eric Botcazou <ebotcazou@adacore.com> + + * config/sparc/sparc.c (eligible_for_return_delay): Do not return + false if there are call-saved registers here... + (sparc_can_use_return_insn_p): ...but here instead. + (save_or_restore_regs): Fix thinko. + (sparc_expand_prologue): Use current_function_is_leaf. + (sparc_frame_pointer_required): Likewise. + +2011-05-21 Nick Clifton <nickc@redhat.com> + + PR target/49098 + * config/rx/rx.c (rx_memory_move_cost): Note unused parameters. + 2011-05-21 Nicola Pero <nicola.pero@meta-innovation.com> * gengtype.c (walk_type): Implemented "atomic" GTY option. @@ -8,8 +220,7 @@ * opt-read.awk: New. Split out of optc-gen.awk and opth-gen.awk. * optc-gen.awk: Move common code to opt-read.awk. * opth-gen.awk: Likewise. - * Makefile.in (options.c, s-options-h): Update to use - opt-read.awk. + * Makefile.in (options.c, s-options-h): Update to use opt-read.awk. 2011-05-20 Nathan Froyd <froydnj@codesourcery.com> diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index b0b6bea98df..258b76419f8 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20110521 +20110524 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index e47e1253151..2d5049eee9a 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -680,7 +680,7 @@ CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ # Additional sources to handle exceptions; overridden by targets as needed. LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \ - $(srcdir)/unwind-sjlj.c $(srcdir)/gthr-gnat.c $(srcdir)/unwind-c.c + $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c LIB2ADDEHSTATIC = $(LIB2ADDEH) LIB2ADDEHSHARED = $(LIB2ADDEH) LIB2ADDEHDEP = $(UNWIND_H) unwind-pe.h unwind.inc unwind-dw2-fde.h unwind-dw2.h @@ -1169,7 +1169,7 @@ CXX_TARGET_OBJS=@cxx_target_objs@ FORTRAN_TARGET_OBJS=@fortran_target_objs@ # Object files for gcc driver. -GCC_OBJS = gcc.o opts-common.o gcc-options.o vec.o ggc-none.o +GCC_OBJS = gcc.o opts-common.o options.o vec.o ggc-none.o # Language-specific object files shared by all C-family front ends. C_COMMON_OBJS = c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o \ @@ -1343,6 +1343,7 @@ OBJS = \ omp-low.o \ optabs.o \ options.o \ + options-save.o \ opts-common.o \ opts-global.o \ opts.o \ @@ -2279,6 +2280,12 @@ options.c: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opt-read.awk \ -f $(srcdir)/optc-gen.awk \ -v header_name="config.h system.h coretypes.h tm.h" < $< > $@ +options-save.c: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opt-read.awk \ + $(srcdir)/optc-save-gen.awk + $(AWK) -f $(srcdir)/opt-functions.awk -f $(srcdir)/opt-read.awk \ + -f $(srcdir)/optc-save-gen.awk \ + -v header_name="config.h system.h coretypes.h tm.h" < $< > $@ + options.h: s-options-h ; @true s-options-h: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opt-read.awk \ $(srcdir)/opth-gen.awk @@ -2288,13 +2295,11 @@ s-options-h: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opt-read.awk \ $(SHELL) $(srcdir)/../move-if-change tmp-options.h options.h $(STAMP) $@ -options.o: options.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TARGET_H) $(FLAGS_H) \ +options.o: options.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) $(OPTS_H) intl.h $(OPTIONS_C_EXTRA) -gcc-options.o: options.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(OPTS_H) intl.h \ - $(OPTIONS_C_EXTRA) - $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(OUTPUT_OPTION) \ - -DGCC_DRIVER options.c +options-save.o: options-save.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TARGET_H) $(FLAGS_H) \ + $(TM_H) $(OPTS_H) intl.h $(OPTIONS_C_EXTRA) dumpvers: dumpvers.c @@ -3011,7 +3016,8 @@ optabs.o : optabs.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ dbxout.o : dbxout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ $(RTL_H) $(FLAGS_H) $(REGS_H) debug.h $(TM_P_H) $(TARGET_H) $(FUNCTION_H) \ langhooks.h insn-config.h reload.h $(GSTAB_H) xcoffout.h output.h dbxout.h \ - toplev.h $(DIAGNOSTIC_CORE_H) $(GGC_H) $(OBSTACK_H) $(EXPR_H) gt-dbxout.h + toplev.h $(DIAGNOSTIC_CORE_H) $(GGC_H) $(OBSTACK_H) $(EXPR_H) $(CGRAPH_H) \ + gt-dbxout.h debug.o : debug.c debug.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) sdbout.o : sdbout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) debug.h \ $(TREE_H) $(GGC_H) $(RTL_H) $(REGS_H) $(FLAGS_H) insn-config.h \ @@ -4520,7 +4526,7 @@ mostlyclean: lang.mostlyclean -rm -f build/* -rm -f mddeps.mk # Delete other built files. - -rm -f specs.h options.c options.h + -rm -f specs.h options.c options.h options-save.c # Delete the stamp and temporary files. -rm -f s-* tmp-* stamp-* stmp-* -rm -f */stamp-* */tmp-* diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 8c297ded371..d6e9d9d7909 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2011-05-21 Joseph Myers <joseph@codesourcery.com> + + PR ada/49097 + * gcc-interface/Make-lang.in (gnatbind$(exeext)): Depend on + $(LIBDEPS). + 2011-05-20 Joseph Myers <joseph@codesourcery.com> * gcc-interface/Make-lang.in (EXTRA_GNATBIND_OBJS): Remove diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index 14c94092915..66b03f4c6cb 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -484,7 +484,7 @@ gnat1$(exeext): $(TARGET_ADA_SRCS) $(GNAT1_OBJS) $(ADA_BACKEND) $(LIBDEPS) $(GCC_LINK) -o $@ $(GNAT1_OBJS) $(ADA_BACKEND) $(LIBS) $(SYSLIBS) $(BACKENDLIBS) $(CFLAGS) $(RM) stamp-gnatlib2-rts stamp-tools -gnatbind$(exeext): ada/b_gnatb.o $(CONFIG_H) $(GNATBIND_OBJS) +gnatbind$(exeext): ada/b_gnatb.o $(CONFIG_H) $(GNATBIND_OBJS) $(LIBDEPS) $(GCC_LINK) -o $@ ada/b_gnatb.o $(GNATBIND_OBJS) $(LIBS) $(SYSLIBS) $(CFLAGS) # use cross-gcc diff --git a/gcc/builtins.c b/gcc/builtins.c index bd61f29a616..a23237dd94a 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -8509,6 +8509,9 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src, Perhaps we ought to inherit type from non-VOID argument here? */ STRIP_NOPS (src); STRIP_NOPS (dest); + if (!POINTER_TYPE_P (TREE_TYPE (src)) + || !POINTER_TYPE_P (TREE_TYPE (dest))) + return NULL_TREE; /* As we fold (void *)(p + CST) to (void *)p + CST undo this here. */ if (TREE_CODE (src) == POINTER_PLUS_EXPR) { @@ -8525,8 +8528,7 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src, dest = build1 (NOP_EXPR, TREE_TYPE (tem), dest); } srctype = TREE_TYPE (TREE_TYPE (src)); - if (srctype - && TREE_CODE (srctype) == ARRAY_TYPE + if (TREE_CODE (srctype) == ARRAY_TYPE && !tree_int_cst_equal (TYPE_SIZE_UNIT (srctype), len)) { srctype = TREE_TYPE (srctype); @@ -8534,21 +8536,15 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src, src = build1 (NOP_EXPR, build_pointer_type (srctype), src); } desttype = TREE_TYPE (TREE_TYPE (dest)); - if (desttype - && TREE_CODE (desttype) == ARRAY_TYPE + if (TREE_CODE (desttype) == ARRAY_TYPE && !tree_int_cst_equal (TYPE_SIZE_UNIT (desttype), len)) { desttype = TREE_TYPE (desttype); STRIP_NOPS (dest); dest = build1 (NOP_EXPR, build_pointer_type (desttype), dest); } - if (!srctype || !desttype - || TREE_ADDRESSABLE (srctype) - || TREE_ADDRESSABLE (desttype) - || !TYPE_SIZE_UNIT (srctype) - || !TYPE_SIZE_UNIT (desttype) - || TREE_CODE (TYPE_SIZE_UNIT (srctype)) != INTEGER_CST - || TREE_CODE (TYPE_SIZE_UNIT (desttype)) != INTEGER_CST) + if (TREE_ADDRESSABLE (srctype) + || TREE_ADDRESSABLE (desttype)) return NULL_TREE; src_align = get_pointer_alignment (src, BIGGEST_ALIGNMENT); diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 3843f7710f8..a7cc965f78f 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -3942,7 +3942,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, return 0; if (expr) - add_stmt (expr); + add_stmt (fold_convert (void_type_node, expr)); if (TREE_CODE (decl) != FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (decl))) warning (OPT_Wmain, "%q+D is usually a function", decl); diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7fa73314501..593086e8874 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,20 @@ +2011-05-23 Jason Merrill <jason@redhat.com> + + PR c++/48106 + * c-common.c (c_common_get_narrower): New. + (shorten_binary_op, shorten_compare, warn_for_sign_compare): Use it. + +2011-05-23 Nathan Froyd <froydnj@codesourcery.com> + + * c-common.h (check_function_arguments): Tweak prototype of + check_function_arguments. + * c-common.c (check_function_arguments): Likewise. Adjust + calls to check_function_nonnull, check_function_format, and + check_function_sentinel. + (check_function_sentinel): Take a FUNCTION_TYPE rather than + separate attributes and typelist arguments. Use + FOREACH_FUNCTION_ARGS to iterate over argument types. + 2011-05-15 Paolo Carlini <paolo.carlini@oracle.com> * c-common.c (c_common_reswords): Reorder. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 8fc68eb6fea..b822553ed87 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1765,6 +1765,28 @@ vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note) return false; } +/* Like tree.c:get_narrower, but retain conversion from C++0x scoped enum + to integral type. */ + +static tree +c_common_get_narrower (tree op, int *unsignedp_ptr) +{ + op = get_narrower (op, unsignedp_ptr); + + if (TREE_CODE (TREE_TYPE (op)) == ENUMERAL_TYPE + && ENUM_IS_SCOPED (TREE_TYPE (op))) + { + /* C++0x scoped enumerations don't implicitly convert to integral + type; if we stripped an explicit conversion to a larger type we + need to replace it so common_type will still work. */ + tree type = (lang_hooks.types.type_for_size + (TYPE_PRECISION (TREE_TYPE (op)), + TYPE_UNSIGNED (TREE_TYPE (op)))); + op = fold_convert (type, op); + } + return op; +} + /* This is a helper function of build_binary_op. For certain operations if both args were extended from the same @@ -1777,7 +1799,8 @@ vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note) Eg, (short)-1 | (unsigned short)-1 is (int)-1 but calculated in (unsigned short) it would be (unsigned short)-1. */ -tree shorten_binary_op (tree result_type, tree op0, tree op1, bool bitwise) +tree +shorten_binary_op (tree result_type, tree op0, tree op1, bool bitwise) { int unsigned0, unsigned1; tree arg0, arg1; @@ -1803,8 +1826,8 @@ tree shorten_binary_op (tree result_type, tree op0, tree op1, bool bitwise) op0 = convert (result_type, op0); op1 = convert (result_type, op1); - arg0 = get_narrower (op0, &unsigned0); - arg1 = get_narrower (op1, &unsigned1); + arg0 = c_common_get_narrower (op0, &unsigned0); + arg1 = c_common_get_narrower (op1, &unsigned1); /* UNS is 1 if the operation to be done is an unsigned one. */ uns = TYPE_UNSIGNED (result_type); @@ -3301,8 +3324,8 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, /* Throw away any conversions to wider types already present in the operands. */ - primop0 = get_narrower (op0, &unsignedp0); - primop1 = get_narrower (op1, &unsignedp1); + primop0 = c_common_get_narrower (op0, &unsignedp0); + primop1 = c_common_get_narrower (op1, &unsignedp1); /* If primopN is first sign-extended from primopN's precision to opN's precision, then zero-extended from opN's precision to @@ -7479,20 +7502,23 @@ check_function_nonnull (tree attrs, int nargs, tree *argarray) array ARGARRAY. */ static void -check_function_sentinel (tree attrs, int nargs, tree *argarray, tree typelist) +check_function_sentinel (const_tree fntype, int nargs, tree *argarray) { - tree attr = lookup_attribute ("sentinel", attrs); + tree attr = lookup_attribute ("sentinel", TYPE_ATTRIBUTES (fntype)); if (attr) { int len = 0; int pos = 0; tree sentinel; + function_args_iterator iter; + tree t; /* Skip over the named arguments. */ - while (typelist && len < nargs) + FOREACH_FUNCTION_ARGS (fntype, t, iter) { - typelist = TREE_CHAIN (typelist); + if (len == nargs) + break; len++; } @@ -7937,26 +7963,24 @@ handle_no_split_stack_attribute (tree *node, tree name, return NULL_TREE; } -/* Check for valid arguments being passed to a function. - ATTRS is a list of attributes. There are NARGS arguments in the array - ARGARRAY. TYPELIST is the list of argument types for the function. - */ +/* Check for valid arguments being passed to a function with FNTYPE. + There are NARGS arguments in the array ARGARRAY. */ void -check_function_arguments (tree attrs, int nargs, tree *argarray, tree typelist) +check_function_arguments (const_tree fntype, int nargs, tree *argarray) { /* Check for null being passed in a pointer argument that must be non-null. We also need to do this if format checking is enabled. */ if (warn_nonnull) - check_function_nonnull (attrs, nargs, argarray); + check_function_nonnull (TYPE_ATTRIBUTES (fntype), nargs, argarray); /* Check for errors in format strings. */ if (warn_format || warn_missing_format_attribute) - check_function_format (attrs, nargs, argarray); + check_function_format (TYPE_ATTRIBUTES (fntype), nargs, argarray); if (warn_format) - check_function_sentinel (attrs, nargs, argarray, typelist); + check_function_sentinel (fntype, nargs, argarray); } /* Generic argument checking recursion routine. PARAM is the argument to @@ -9370,16 +9394,16 @@ warn_for_sign_compare (location_t location, have all bits set that are set in the ~ operand when it is extended. */ - op0 = get_narrower (op0, &unsignedp0); - op1 = get_narrower (op1, &unsignedp1); + op0 = c_common_get_narrower (op0, &unsignedp0); + op1 = c_common_get_narrower (op1, &unsignedp1); if ((TREE_CODE (op0) == BIT_NOT_EXPR) ^ (TREE_CODE (op1) == BIT_NOT_EXPR)) { if (TREE_CODE (op0) == BIT_NOT_EXPR) - op0 = get_narrower (TREE_OPERAND (op0, 0), &unsignedp0); + op0 = c_common_get_narrower (TREE_OPERAND (op0, 0), &unsignedp0); if (TREE_CODE (op1) == BIT_NOT_EXPR) - op1 = get_narrower (TREE_OPERAND (op1, 0), &unsignedp1); + op1 = c_common_get_narrower (TREE_OPERAND (op1, 0), &unsignedp1); if (host_integerp (op0, 0) || host_integerp (op1, 0)) { diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 7136b017dcb..89d4b80bded 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -687,7 +687,7 @@ extern void finish_fname_decls (void); extern const char *fname_as_string (int); extern tree fname_decl (location_t, unsigned, tree); -extern void check_function_arguments (tree, int, tree *, tree); +extern void check_function_arguments (const_tree, int, tree *); extern void check_function_arguments_recurse (void (*) (void *, tree, unsigned HOST_WIDE_INT), diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 6016db2783f..e609611ab58 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2808,8 +2808,7 @@ build_function_call_vec (location_t loc, tree function, VEC(tree,gc) *params, return error_mark_node; /* Check that the arguments to the function are valid. */ - check_function_arguments (TYPE_ATTRIBUTES (fntype), nargs, argarray, - TYPE_ARG_TYPES (fntype)); + check_function_arguments (fntype, nargs, argarray); if (name != NULL_TREE && !strncmp (IDENTIFIER_POINTER (name), "__builtin_", 10)) diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index 179cd00ad0c..c36af89a137 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -599,9 +599,6 @@ try_forward_edges (int mode, basic_block b) + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE); - if (!FORWARDER_BLOCK_P (b) && forwarder_block_p (b)) - b->flags |= BB_FORWARDER_BLOCK; - do { edge t; @@ -2693,7 +2690,10 @@ try_optimize_cfg (int mode) /* Simplify branch to branch. */ if (try_forward_edges (mode, b)) - changed_here = true; + { + update_forwarder_flag (b); + changed_here = true; + } /* Look for shared code between blocks. */ if ((mode & CLEANUP_CROSSJUMP) diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index ecf2510a0f4..b22ba71375f 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3160,6 +3160,20 @@ expand_debug_expr (tree exp) ENTRY_VALUE_EXP (op0) = incoming; goto adjust_mode; } + if (incoming + && MEM_P (incoming) + && !TREE_ADDRESSABLE (SSA_NAME_VAR (exp)) + && GET_MODE (incoming) != BLKmode + && (XEXP (incoming, 0) == virtual_incoming_args_rtx + || (GET_CODE (XEXP (incoming, 0)) == PLUS + && XEXP (XEXP (incoming, 0), 0) + == virtual_incoming_args_rtx + && CONST_INT_P (XEXP (XEXP (incoming, 0), + 1))))) + { + op0 = incoming; + goto adjust_mode; + } op0 = expand_debug_expr (SSA_NAME_VAR (exp)); if (!op0) return NULL; diff --git a/gcc/common.opt b/gcc/common.opt index 1cae3e924e3..f13326bcc58 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -759,6 +759,9 @@ Driver Undocumented ; function parameters used in other parameters and the return type. ; First selectable in G++ 4.6. ; +; 6: The version of the ABI that doesn't promote scoped enums to int. +; First selectable in G++ 4.7. +; ; Additional positive integers will be assigned as new versions of ; the ABI become the default version of the ABI. fabi-version= diff --git a/gcc/config.gcc b/gcc/config.gcc index 46e16c13334..475c4e3cf3a 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -2439,12 +2439,12 @@ sparc-*-elf*) tmake_file="sparc/t-elf" ;; esac - tmake_file="${tmake_file} sparc/t-crtfm" + tmake_file="${tmake_file} sparc/t-crtin sparc/t-crtfm" extra_parts="crtbegin.o crtend.o" ;; sparc-*-rtems*) tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h sparc/sp-elf.h sparc/rtemself.h rtems.h newlib-stdint.h" - tmake_file="sparc/t-elf sparc/t-crtfm t-rtems" + tmake_file="sparc/t-elf sparc/t-crtin sparc/t-crtfm t-rtems" extra_parts="crtbegin.o crtend.o" ;; sparc-*-linux*) @@ -2502,7 +2502,7 @@ sparc*-*-solaris2*) tm_file="${tm_file} sol2-gld.h sparc/sol2-gld-bi.h" fi tm_file="${tm_file} tm-dwarf2.h" - tmake_file="t-sol2 sparc/t-sol2 sparc/t-sol2-64 sparc/t-crtfm" + tmake_file="t-sol2 sparc/t-sol2 sparc/t-sol2-64 sparc/t-crtin sparc/t-crtfm" if test x$gnu_ld = xyes; then tmake_file="$tmake_file t-slibgcc-elf-ver" else @@ -2515,7 +2515,7 @@ sparc*-*-solaris2*) cxx_target_objs="sol2-c.o" extra_objs="sol2.o" tm_p_file="${tm_p_file} sol2-protos.h" - extra_parts="crt1.o crti.o crtn.o gcrt1.o gmon.o crtbegin.o crtend.o" + extra_parts="crt1.o gcrt1.o gmon.o crtbegin.o crtend.o" case ${enable_threads}:${have_pthread_h}:${have_thread_h} in "":yes:* | yes:yes:* ) thread_file=posix @@ -2529,13 +2529,13 @@ sparc-wrs-vxworks) sparc64-*-elf*) tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h sparc/sysv4.h sparc/sp64-elf.h" extra_options="${extra_options} sparc/little-endian.opt" - tmake_file="${tmake_file} sparc/t-crtfm" + tmake_file="${tmake_file} sparc/t-crtin sparc/t-crtfm" extra_parts="crtbegin.o crtend.o" ;; sparc64-*-rtems*) tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h sparc/sysv4.h sparc/sp64-elf.h sparc/rtemself.h rtems.h" extra_options="${extra_options} sparc/little-endian.opt" - tmake_file="${tmake_file} sparc/t-crtfm t-rtems" + tmake_file="${tmake_file} sparc/t-crtin sparc/t-crtfm t-rtems" extra_parts="crtbegin.o crtend.o" ;; sparc64-*-linux*) diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h index e9d0fab6f39..3c3f47b0030 100644 --- a/gcc/config/i386/cpuid.h +++ b/gcc/config/i386/cpuid.h @@ -57,6 +57,7 @@ #define bit_TBM (1 << 21) /* %edx */ +#define bit_MMXEXT (1 << 22) #define bit_LM (1 << 29) #define bit_3DNOWP (1 << 30) #define bit_3DNOW (1 << 31) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 0709be819fd..854e376b58e 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4191,11 +4191,6 @@ ix86_option_override_internal (bool main_args_p) #endif } - /* Save the initial options in case the user does function specific options */ - if (main_args_p) - target_option_default_node = target_option_current_node - = build_target_option_node (); - if (TARGET_AVX) { /* When not optimize for size, enable vzeroupper optimization for @@ -4217,6 +4212,12 @@ ix86_option_override_internal (bool main_args_p) /* Disable vzeroupper pass if TARGET_AVX is disabled. */ target_flags &= ~MASK_VZEROUPPER; } + + /* Save the initial options in case the user does function specific + options. */ + if (main_args_p) + target_option_default_node = target_option_current_node + = build_target_option_node (); } /* Return TRUE if VAL is passed in register with 256bit AVX modes. */ diff --git a/gcc/config/ia64/t-vms b/gcc/config/ia64/t-vms index d77a2cf3796..bcd753401f1 100644 --- a/gcc/config/ia64/t-vms +++ b/gcc/config/ia64/t-vms @@ -1,4 +1,4 @@ -# Copyright (C) 2009 +# Copyright (C) 2009, 2011 # Free Software Foundation, Inc. # # This file is part of GCC. @@ -32,7 +32,7 @@ $(T)crtinitS.o: $(srcdir)/config/ia64/vms-crtinit.asm $(GCC_PASSES) $(GCC_FOR_TARGET) -I. -c -o $(T)crtinitS.o -x assembler-with-cpp \ $(srcdir)/config/ia64/vms-crtinit.asm -LIB2ADDEH += $(srcdir)/config/ia64/fde-vms.c $(srcdir)/gthr-gnat.c +LIB2ADDEH += $(srcdir)/config/ia64/fde-vms.c # Shared library macros shlib_version:=$(shell echo $(BASEVER_c) | sed -e 's/\./,/' -e 's/\.//g') diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index f293579f5a5..26028192db5 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -15239,12 +15239,14 @@ mips_cpu_info_from_opt (int opt) static const struct mips_cpu_info * mips_default_arch (void) { -#ifdef MIPS_CPU_STRING_DEFAULT +#if defined (MIPS_CPU_STRING_DEFAULT) unsigned int i; for (i = 0; i < ARRAY_SIZE (mips_cpu_info_table); i++) if (strcmp (mips_cpu_info_table[i].name, MIPS_CPU_STRING_DEFAULT) == 0) return mips_cpu_info_table + i; gcc_unreachable (); +#elif defined (MIPS_ISA_DEFAULT) + return mips_cpu_info_from_isa (MIPS_ISA_DEFAULT); #else /* 'from-abi' makes a good default: you get whatever the ABI requires. */ diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index 366970e677a..92e932a29c9 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -1079,14 +1079,6 @@ struct mips_cpu_info { #endif -/* SUBTARGET_ASM_OPTIMIZING_SPEC handles passing optimization options - to the assembler. It may be overridden by subtargets. */ -#ifndef SUBTARGET_ASM_OPTIMIZING_SPEC -#define SUBTARGET_ASM_OPTIMIZING_SPEC "\ -%{noasmopt:-O0} \ -%{!noasmopt:%{O:-O2} %{O1:-O2} %{O2:-O2} %{O3:-O3}}" -#endif - /* SUBTARGET_ASM_DEBUGGING_SPEC handles passing debugging options to the assembler. It may be overridden by subtargets. @@ -1123,7 +1115,7 @@ struct mips_cpu_info { %{mmt} %{mno-mt} \ %{mfix-vr4120} %{mfix-vr4130} \ %{mfix-24k} \ -%(subtarget_asm_optimizing_spec) \ +%{noasmopt:-O0; O0|fno-delayed-branch:-O1; O*:-O2; :-O1} \ %(subtarget_asm_debugging_spec) \ %{mabi=*} %{!mabi=*: %(asm_abi_default_spec)} \ %{mgp32} %{mgp64} %{march=*} %{mxgot:-xgot} \ @@ -1181,7 +1173,6 @@ struct mips_cpu_info { #define EXTRA_SPECS \ { "subtarget_cc1_spec", SUBTARGET_CC1_SPEC }, \ { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \ - { "subtarget_asm_optimizing_spec", SUBTARGET_ASM_OPTIMIZING_SPEC }, \ { "subtarget_asm_debugging_spec", SUBTARGET_ASM_DEBUGGING_SPEC }, \ { "subtarget_asm_spec", SUBTARGET_ASM_SPEC }, \ { "asm_abi_default_spec", "-" MULTILIB_ABI_DEFAULT }, \ diff --git a/gcc/config/rx/rx.c b/gcc/config/rx/rx.c index cedb0e073ed..70d41593fb1 100644 --- a/gcc/config/rx/rx.c +++ b/gcc/config/rx/rx.c @@ -2636,7 +2636,9 @@ rx_trampoline_init (rtx tramp, tree fndecl, rtx chain) } static int -rx_memory_move_cost (enum machine_mode mode, reg_class_t regclass, bool in) +rx_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, + reg_class_t regclass ATTRIBUTE_UNUSED, + bool in) { return (in ? 2 : 0) + REGISTER_MOVE_COST (mode, regclass, regclass); } diff --git a/gcc/config/sparc/sp64-elf.h b/gcc/config/sparc/sp64-elf.h index 0ee9d08cee0..492f90fd490 100644 --- a/gcc/config/sparc/sp64-elf.h +++ b/gcc/config/sparc/sp64-elf.h @@ -50,18 +50,13 @@ along with GCC; see the file COPYING3. If not see %{mlittle-endian:-EL} \ " -/* We need something a little simpler for the embedded environment. - Profiling doesn't really work yet so we just copy the default. */ #undef STARTFILE_SPEC -#define STARTFILE_SPEC "\ -%{!shared:%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}} \ -crtbegin.o%s \ -" +#define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s" #undef ENDFILE_SPEC #define ENDFILE_SPEC \ "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ - crtend.o%s" + crtend.o%s crtn.o%s" /* Use the default (for now). */ #undef LIB_SPEC diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 10b35f250e9..bd7d12a6553 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -2808,11 +2808,6 @@ eligible_for_return_delay (rtx trial) if (get_attr_length (trial) != 1) return 0; - /* If there are any call-saved registers, we should scan TRIAL if it - does not reference them. For now just make it easy. */ - if (num_gfregs) - return 0; - /* If the function uses __builtin_eh_return, the eh_return machinery occupies the delay slot. */ if (crtl->calls_eh_return) @@ -3620,13 +3615,17 @@ sparc_delegitimize_address (rtx x) { x = delegitimize_mem_from_attrs (x); - if (GET_CODE (x) == LO_SUM - && GET_CODE (XEXP (x, 1)) == UNSPEC - && XINT (XEXP (x, 1), 1) == UNSPEC_TLSLE) - { - x = XVECEXP (XEXP (x, 1), 0, 0); - gcc_assert (GET_CODE (x) == SYMBOL_REF); - } + if (GET_CODE (x) == LO_SUM && GET_CODE (XEXP (x, 1)) == UNSPEC) + switch (XINT (XEXP (x, 1), 1)) + { + case UNSPEC_MOVE_PIC: + case UNSPEC_TLSLE: + x = XVECEXP (XEXP (x, 1), 0, 0); + gcc_assert (GET_CODE (x) == SYMBOL_REF); + break; + default: + break; + } /* This is generated by mov{si,di}_pic_label_ref in PIC mode. */ if (GET_CODE (x) == MINUS @@ -4400,7 +4399,7 @@ save_or_restore_regs (int low, int high, rtx base, int offset, int action) emit_move_insn (gen_rtx_REG (mode, regno), mem); /* Always preserve double-word alignment. */ - offset = (offset + 7) & -8; + offset = (offset + 8) & -8; } } @@ -4507,7 +4506,7 @@ sparc_expand_prologue (void) example, the regrename pass has special provisions to not rename to non-leaf registers in a leaf function. */ sparc_leaf_function_p - = optimize > 0 && leaf_function_p () && only_leaf_regs_used (); + = optimize > 0 && current_function_is_leaf && only_leaf_regs_used (); /* Need to use actual_fsize, since we are also allocating space for our callee (and our own register save area). */ @@ -4637,6 +4636,7 @@ bool sparc_can_use_return_insn_p (void) { return sparc_prologue_data_valid_p + && num_gfregs == 0 && (actual_fsize == 0 || !sparc_leaf_function_p); } @@ -9796,7 +9796,7 @@ sparc_expand_compare_and_swap_12 (rtx result, rtx mem, rtx oldval, rtx newval) bool sparc_frame_pointer_required (void) { - return !(leaf_function_p () && only_leaf_regs_used ()); + return !(current_function_is_leaf && only_leaf_regs_used ()); } /* The way this is structured, we can't eliminate SFP in favor of SP diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md index 853bd2fbdcc..5e16179a62b 100644 --- a/gcc/config/sparc/sparc.md +++ b/gcc/config/sparc/sparc.md @@ -6507,8 +6507,8 @@ (const_int 4)))]) ;; For __builtin_setjmp we need to flush register windows iff the function -;; calls alloca as well, because otherwise the register window might be -;; saved after %sp adjustment and thus setjmp would crash +;; calls alloca as well, because otherwise the current register window might +;; be saved after the %sp adjustment and thus setjmp would crash. (define_expand "builtin_setjmp_setup" [(match_operand 0 "register_operand" "r")] "" @@ -6547,19 +6547,26 @@ (eq_attr "pic" "true") (const_int 4)] (const_int 3)))]) -;; Pattern for use after a setjmp to store FP and the return register -;; into the stack area. +;; Pattern for use after a setjmp to store registers into the save area. (define_expand "setjmp" [(const_int 0)] "" { rtx mem; - + + if (flag_pic) + { + mem = gen_rtx_MEM (Pmode, + plus_constant (stack_pointer_rtx, + SPARC_STACK_BIAS + 7 * UNITS_PER_WORD)); + emit_insn (gen_rtx_SET (VOIDmode, mem, pic_offset_table_rtx)); + } + mem = gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx, SPARC_STACK_BIAS + 14 * UNITS_PER_WORD)); - emit_insn (gen_rtx_SET (VOIDmode, mem, frame_pointer_rtx)); + emit_insn (gen_rtx_SET (VOIDmode, mem, hard_frame_pointer_rtx)); mem = gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx, diff --git a/gcc/config/sparc/t-crtin b/gcc/config/sparc/t-crtin new file mode 100644 index 00000000000..2612bac89f6 --- /dev/null +++ b/gcc/config/sparc/t-crtin @@ -0,0 +1,6 @@ +EXTRA_PARTS += crti.o crtn.o + +$(T)crti.o: $(srcdir)/config/sparc/sol2-ci.asm $(GCC_PASSES) + $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/sparc/sol2-ci.asm +$(T)crtn.o: $(srcdir)/config/sparc/sol2-cn.asm $(GCC_PASSES) + $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/sparc/sol2-cn.asm diff --git a/gcc/config/sparc/t-linux64 b/gcc/config/sparc/t-linux64 index 4a7de459539..74d04898d9f 100644 --- a/gcc/config/sparc/t-linux64 +++ b/gcc/config/sparc/t-linux64 @@ -31,9 +31,6 @@ MULTILIB_OSDIRNAMES = ../lib64 $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR) LIBGCC = stmp-multilib INSTALL_LIBGCC = install-multilib -EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o \ - crtfastmath.o - CRTSTUFF_T_CFLAGS = `if test x$$($(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) \ -print-multi-os-directory) \ = x../lib64; then echo -mcmodel=medany; fi` diff --git a/gcc/config/sparc/t-sol2 b/gcc/config/sparc/t-sol2 index 9db0c13b8e8..b7f665b1b7b 100644 --- a/gcc/config/sparc/t-sol2 +++ b/gcc/config/sparc/t-sol2 @@ -26,10 +26,6 @@ $(T)gmon.o: $(srcdir)/config/sparc/gmon-sol2.c $(GCC_PASSES) \ # Assemble startup files. $(T)crt1.o: $(srcdir)/config/sparc/sol2-c1.asm $(GCC_PASSES) $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crt1.o -x assembler-with-cpp $(srcdir)/config/sparc/sol2-c1.asm -$(T)crti.o: $(srcdir)/config/sparc/sol2-ci.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/sparc/sol2-ci.asm -$(T)crtn.o: $(srcdir)/config/sparc/sol2-cn.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/sparc/sol2-cn.asm $(T)gcrt1.o: $(srcdir)/config/sparc/sol2-c1.asm $(GCC_PASSES) $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -DGCRT1 -o $(T)gcrt1.o -x assembler-with-cpp $(srcdir)/config/sparc/sol2-c1.asm diff --git a/gcc/config/sparc/t-sol2-64 b/gcc/config/sparc/t-sol2-64 index a9f4ec1e2cd..1802239d3cf 100644 --- a/gcc/config/sparc/t-sol2-64 +++ b/gcc/config/sparc/t-sol2-64 @@ -5,6 +5,3 @@ MULTILIB_OSDIRNAMES = . sparcv9 LIBGCC = stmp-multilib INSTALL_LIBGCC = install-multilib - -EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o gmon.o crt1.o crti.o crtn.o gcrt1.o \ - crtfastmath.o diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c index 1a90e16da08..6edc2c1873b 100644 --- a/gcc/config/stormy16/stormy16.c +++ b/gcc/config/stormy16/stormy16.c @@ -2266,7 +2266,7 @@ xstormy16_init_builtins (void) gcc_assert (n_args <= (int) ARRAY_SIZE (args)); - for (a = n_args; a >= 0; a--) + for (a = n_args - 1; a >= 0; a--) args[a] = NULL_TREE; for (a = n_args; a >= 0; a--) @@ -2284,9 +2284,9 @@ xstormy16_init_builtins (void) else args[a-1] = arg; } - ftype = build_function_type_list (ret_type, arg[0], arg[1], NULL_TREE); + ftype = build_function_type_list (ret_type, args[0], args[1], NULL_TREE); add_builtin_function (s16builtins[i].name, ftype, - i, BUILT_IN_MD, NULL, NULL); + i, BUILT_IN_MD, NULL, NULL_TREE); } } @@ -2407,7 +2407,8 @@ combine_bnp (rtx insn) { /* LT and GE conditionals should have a sign extend before them. */ - for (and_insn = prev_real_insn (insn); and_insn; + for (and_insn = prev_real_insn (insn); + and_insn != NULL_RTX; and_insn = prev_real_insn (and_insn)) { int and_code = recog_memoized (and_insn); @@ -2436,7 +2437,8 @@ combine_bnp (rtx insn) else { /* EQ and NE conditionals have an AND before them. */ - for (and_insn = prev_real_insn (insn); and_insn; + for (and_insn = prev_real_insn (insn); + and_insn != NULL_RTX; and_insn = prev_real_insn (and_insn)) { if (recog_memoized (and_insn) == CODE_FOR_andhi3 @@ -2481,7 +2483,8 @@ combine_bnp (rtx insn) } } } - if (!and_insn) + + if (and_insn == NULL_RTX) return; for (load = shift ? prev_real_insn (shift) : prev_real_insn (and_insn); diff --git a/gcc/config/t-freebsd b/gcc/config/t-freebsd index c1b086ea116..276e2d7a5ad 100644 --- a/gcc/config/t-freebsd +++ b/gcc/config/t-freebsd @@ -6,5 +6,5 @@ TARGET_LIBGCC2_CFLAGS += -fPIC # Use unwind-dw2-fde-glibc LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde-glibc.c \ - $(srcdir)/unwind-sjlj.c $(srcdir)/gthr-gnat.c $(srcdir)/unwind-c.c + $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c LIB2ADDEHDEP = unwind.inc unwind-dw2-fde.h unwind-dw2-fde.c diff --git a/gcc/config/t-linux b/gcc/config/t-linux index 1a7d79e211a..38b3b58d9f4 100644 --- a/gcc/config/t-linux +++ b/gcc/config/t-linux @@ -1,5 +1,5 @@ # Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, -# 2004 Free Software Foundation, Inc. +# 2004, 2011 Free Software Foundation, Inc. # # This file is part of GCC. # @@ -28,5 +28,5 @@ SHLIB_MAPFILES += $(srcdir)/config/libgcc-glibc.ver # Use unwind-dw2-fde-glibc LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde-glibc.c \ - $(srcdir)/unwind-sjlj.c $(srcdir)/gthr-gnat.c $(srcdir)/unwind-c.c + $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c LIB2ADDEHDEP = unwind.inc unwind-dw2-fde.h unwind-dw2-fde.c diff --git a/gcc/config/t-sol2 b/gcc/config/t-sol2 index 1604b9e499f..9e06665a34a 100644 --- a/gcc/config/t-sol2 +++ b/gcc/config/t-sol2 @@ -32,5 +32,5 @@ sol2.o: $(srcdir)/config/sol2.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ # Use unwind-dw2-fde-glibc.c. Unless linker support and dl_iterate_phdr # are present, automatically falls back to unwind-dw2-fde.c. LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde-glibc.c \ - $(srcdir)/unwind-sjlj.c $(srcdir)/gthr-gnat.c $(srcdir)/unwind-c.c + $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c LIB2ADDEHDEP = unwind.inc unwind-dw2-fde.h unwind-dw2-fde.c diff --git a/gcc/configure b/gcc/configure index a054764333a..274af3eccd7 100755 --- a/gcc/configure +++ b/gcc/configure @@ -10794,8 +10794,8 @@ case ${enable_threads} in # default target_thread_file='single' ;; - aix | dce | gnat | irix | posix | posix95 | rtems | \ - single | vxworks | win32 | mipssde) + aix | dce | lynx | mipssde | nks | posix | posix95 | rtems | \ + single | tpf | vxworks | win32) target_thread_file=${enable_threads} ;; *) diff --git a/gcc/configure.ac b/gcc/configure.ac index ff6d5e90157..9ace66db9cb 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1340,8 +1340,8 @@ case ${enable_threads} in # default target_thread_file='single' ;; - aix | dce | gnat | irix | posix | posix95 | rtems | \ - single | vxworks | win32 | mipssde) + aix | dce | lynx | mipssde | nks | posix | posix95 | rtems | \ + single | tpf | vxworks | win32) target_thread_file=${enable_threads} ;; *) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0d1968f5a5e..ee2c9d9ecd2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,66 @@ +2011-05-23 Jason Merrill <jason@redhat.com> + + * pt.c (tsubst_copy_and_build): Use current_class_name. + + PR c++/49102 + * call.c (convert_arg_to_ellipsis): Call force_rvalue. + + PR c++/49105 + * typeck.c (cp_build_c_cast): Don't strip cv-quals when + converting to reference. + (build_static_cast_1): Update for glvalues. + + PR c++/49105 + * typeck.c (build_const_cast_1): Handle rvalue references. + + PR c++/47263 + * decl.c (use_eh_spec_block): Do use an EH spec block for a + lambda op(). + + PR c++/49058 + * call.c (splice_viable): Be strict in templates. + + PR c++/47336 + * error.c (dump_template_bindings): Suppress access control. + + PR c++/47544 + * pt.c (instantiate_decl): Handle =default. + + PR c++/48617 + * pt.c (invalid_nontype_parm_type_p): Allow DECLTYPE_TYPE. + +2011-05-23 Nathan Froyd <froydnj@codesourcery.com> + + * call.c (build_over_call): Tweak call to check_function_arguments. + * typeck.c (cp_build_function_call_vec): Likewise. + +2011-05-23 Jonathan Wakely <jwakely.gcc@gmail.com> + + PR c++/18016 + * init.c (perform_member_init): Check for self-initialization. + +2011-05-22 Jason Merrill <jason@redhat.com> + + PR c++/48647 + * typeck.c (composite_pointer_type_r): Return error_mark_node + on error in SFINAE context. + 2011-05-20 Jason Merrill <jason@redhat.com> + PR c++/48945 + * decl.c (grokdeclarator): Don't add set const function-cv-qual + for constexpr fns to memfn_quals, just add it to the type. + (revert_static_member_fn): Don't complain about quals. + (check_static_quals): New. + (grokfndecl): Call it. + (start_preparsed_function): Don't call revert_static_member_fn. + + PR c++/48945 + * decl.c (revert_static_member_fn): Ignore const on constexpr fn. + + PR c++/48780 + * cvt.c (type_promotes_to): Don't promote scoped enums. + PR c++/49066 * decl.c (duplicate_decls): Preserve DECL_DELETED_FN. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 09ad4aea25e..ff3dc062b2e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3009,6 +3009,11 @@ splice_viable (struct z_candidate *cands, struct z_candidate **last_viable; struct z_candidate **cand; + /* Be strict inside templates, since build_over_call won't actually + do the conversions to get pedwarns. */ + if (processing_template_decl) + strict_p = true; + viable = NULL; last_viable = &viable; *any_viable_p = false; @@ -5900,10 +5905,13 @@ convert_arg_to_ellipsis (tree arg) /* In a template (or ill-formed code), we can have an incomplete type even after require_complete_type, in which case we don't know whether it has trivial copy or not. */ - && COMPLETE_TYPE_P (arg_type) - && (type_has_nontrivial_copy_init (arg_type) - || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (arg_type))) + && COMPLETE_TYPE_P (arg_type)) { + /* Build up a real lvalue-to-rvalue conversion in case the + copy constructor is trivial but not callable. */ + if (CLASS_TYPE_P (arg_type)) + force_rvalue (arg, tf_warning_or_error); + /* [expr.call] 5.2.2/7: Passing a potentially-evaluated argument of class type (Clause 9) with a non-trivial copy constructor or a non-trivial destructor @@ -5915,7 +5923,9 @@ convert_arg_to_ellipsis (tree arg) If the call appears in the context of a sizeof expression, it is not potentially-evaluated. */ - if (cp_unevaluated_operand == 0) + if (cp_unevaluated_operand == 0 + && (type_has_nontrivial_copy_init (arg_type) + || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (arg_type))) error ("cannot pass objects of non-trivially-copyable " "type %q#T through %<...%>", arg_type); } @@ -6477,8 +6487,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) gcc_assert (j <= nargs); nargs = j; - check_function_arguments (TYPE_ATTRIBUTES (TREE_TYPE (fn)), - nargs, argarray, TYPE_ARG_TYPES (TREE_TYPE (fn))); + check_function_arguments (TREE_TYPE (fn), nargs, argarray); /* Avoid actually calling copy constructors and copy assignment operators, if possible. */ diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index db4ea46e46a..e5d5361ac28 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1616,6 +1616,10 @@ type_promotes_to (tree type) if (TREE_CODE (type) == BOOLEAN_TYPE) type = integer_type_node; + /* scoped enums don't promote. */ + else if (SCOPED_ENUM_P (type) && abi_version_at_least (6)) + ; + /* Normally convert enums to int, but convert wide enums to something wider. */ else if (TREE_CODE (type) == ENUMERAL_TYPE @@ -1626,6 +1630,9 @@ type_promotes_to (tree type) int precision = MAX (TYPE_PRECISION (type), TYPE_PRECISION (integer_type_node)); tree totype = c_common_type_for_size (precision, 0); + if (SCOPED_ENUM_P (type)) + warning (OPT_Wabi, "scoped enum %qT will not promote to an integral " + "type in a future version of GCC", type); if (TREE_CODE (type) == ENUMERAL_TYPE) type = ENUM_UNDERLYING_TYPE (type); if (TYPE_UNSIGNED (type) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index eae7d8ec69b..234daafb8a1 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6960,6 +6960,17 @@ build_this_parm (tree type, cp_cv_quals quals) return parm; } +/* DECL is a static member function. Complain if it was declared + with function-cv-quals. */ + +static void +check_static_quals (tree decl, cp_cv_quals quals) +{ + if (quals != TYPE_UNQUALIFIED) + error ("static member function %q#D declared with type qualifiers", + decl); +} + /* CTYPE is class type, or null if non-class. TYPE is type this FUNCTION_DECL should have, either FUNCTION_TYPE or METHOD_TYPE. @@ -7241,6 +7252,9 @@ grokfndecl (tree ctype, if (decl == error_mark_node) return NULL_TREE; + if (DECL_STATIC_FUNCTION_P (decl)) + check_static_quals (decl, quals); + if (attrlist) { cplus_decl_attributes (&decl, *attrlist, 0); @@ -7290,9 +7304,11 @@ grokfndecl (tree ctype, if (DECL_STATIC_FUNCTION_P (old_decl) && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE) - /* Remove the `this' parm added by grokclassfn. - XXX Isn't this done in start_function, too? */ - revert_static_member_fn (decl); + { + /* Remove the `this' parm added by grokclassfn. */ + revert_static_member_fn (decl); + check_static_quals (decl, quals); + } if (DECL_ARTIFICIAL (old_decl)) { error ("definition of implicitly-declared %qD", old_decl); @@ -9356,12 +9372,6 @@ grokdeclarator (const cp_declarator *declarator, if (ctype == NULL_TREE && decl_context == FIELD && friendp == 0) ctype = current_class_type; - /* A constexpr non-static member function is implicitly const. */ - if (constexpr_p && ctype && staticp == 0 - && TREE_CODE (type) == FUNCTION_TYPE - && sfk != sfk_constructor && sfk != sfk_destructor) - memfn_quals |= TYPE_QUAL_CONST; - /* Now TYPE has the actual type. */ if (returned_attrs) @@ -9733,7 +9743,12 @@ grokdeclarator (const cp_declarator *declarator, if (ctype && TREE_CODE (type) == FUNCTION_TYPE && staticp < 2 && !NEW_DELETE_OPNAME_P (unqualified_id)) - type = build_memfn_type (type, ctype, memfn_quals); + { + cp_cv_quals real_quals = memfn_quals; + if (constexpr_p && sfk != sfk_constructor && sfk != sfk_destructor) + real_quals |= TYPE_QUAL_CONST; + type = build_memfn_type (type, ctype, real_quals); + } { tree decl; @@ -12373,12 +12388,8 @@ start_preparsed_function (tree decl1, tree attrs, int flags) /* Sometimes we don't notice that a function is a static member, and build a METHOD_TYPE for it. Fix that up now. */ - if (ctype != NULL_TREE && DECL_STATIC_FUNCTION_P (decl1) - && TREE_CODE (TREE_TYPE (decl1)) == METHOD_TYPE) - { - revert_static_member_fn (decl1); - ctype = NULL_TREE; - } + gcc_assert (!(ctype != NULL_TREE && DECL_STATIC_FUNCTION_P (decl1) + && TREE_CODE (TREE_TYPE (decl1)) == METHOD_TYPE)); /* Set up current_class_type, and enter the scope of the class, if appropriate. */ @@ -12748,7 +12759,7 @@ use_eh_spec_block (tree fn) not creating the EH_SPEC_BLOCK we save a little memory, and we avoid spurious warnings about unreachable code. */ - && !DECL_ARTIFICIAL (fn)); + && !DECL_DEFAULTED_FN (fn)); } /* Store the parameter declarations into the current function declaration. @@ -13575,12 +13586,11 @@ void revert_static_member_fn (tree decl) { tree stype = static_fn_type (decl); + cp_cv_quals quals = type_memfn_quals (stype); + + if (quals != TYPE_UNQUALIFIED) + stype = apply_memfn_quals (stype, TYPE_UNQUALIFIED); - if (type_memfn_quals (stype) != TYPE_UNQUALIFIED) - { - error ("static member function %q#D declared with type qualifiers", decl); - stype = apply_memfn_quals (stype, TYPE_UNQUALIFIED); - } TREE_TYPE (decl) = stype; if (DECL_ARGUMENTS (decl)) diff --git a/gcc/cp/error.c b/gcc/cp/error.c index e580fd92158..a6648cc6647 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -313,7 +313,9 @@ dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames) pp_cxx_whitespace (cxx_pp); pp_equal (cxx_pp); pp_cxx_whitespace (cxx_pp); + push_deferring_access_checks (dk_no_check); t = tsubst (t, args, tf_none, NULL_TREE); + pop_deferring_access_checks (); /* Strip typedefs. We can't just use TFF_CHASE_TYPEDEF because pp_simple_type_specifier doesn't know about it. */ t = strip_typedefs (t); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 7d7adbe0405..5f30275ae5b 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -501,6 +501,17 @@ perform_member_init (tree member, tree init) if (decl == error_mark_node) return; + if (warn_init_self && init && TREE_CODE (init) == TREE_LIST + && TREE_CHAIN (init) == NULL_TREE) + { + tree val = TREE_VALUE (init); + if (TREE_CODE (val) == COMPONENT_REF && TREE_OPERAND (val, 1) == member + && TREE_OPERAND (val, 0) == current_class_ref) + warning_at (DECL_SOURCE_LOCATION (current_function_decl), + OPT_Wuninitialized, "%qD is initialized with itself", + member); + } + if (init == void_type_node) { /* mem() means value-initialization. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d72596f5525..dbff91e617d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13017,8 +13017,7 @@ tsubst_copy_and_build (tree t, else inform (EXPR_LOC_OR_HERE (t), "use %<%T::%D%> instead", - TYPE_IDENTIFIER (current_class_type), - function); + current_class_name, function); } else inform (0, "%q+D declared here, later in the " @@ -17432,7 +17431,8 @@ instantiate_decl (tree d, int defer_ok, args = gen_args; if (TREE_CODE (d) == FUNCTION_DECL) - pattern_defined = (DECL_SAVED_TREE (code_pattern) != NULL_TREE); + pattern_defined = (DECL_SAVED_TREE (code_pattern) != NULL_TREE + || DECL_DEFAULTED_OUTSIDE_CLASS_P (code_pattern)); else pattern_defined = ! DECL_IN_AGGR_P (code_pattern); @@ -17627,6 +17627,8 @@ instantiate_decl (tree d, int defer_ok, cp_finish_decl (d, init, const_init, NULL_TREE, 0); pop_nested_class (); } + else if (TREE_CODE (d) == FUNCTION_DECL && DECL_DEFAULTED_FN (code_pattern)) + synthesize_method (d); else if (TREE_CODE (d) == FUNCTION_DECL) { htab_t saved_local_specializations; @@ -18089,6 +18091,8 @@ invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain) return 0; else if (TREE_CODE (type) == TYPENAME_TYPE) return 0; + else if (TREE_CODE (type) == DECLTYPE_TYPE) + return 0; if (complain & tf_error) error ("%q#T is not a valid type for a template constant parameter", type); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 7791efcaa8f..69b25d39645 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -516,7 +516,8 @@ composite_pointer_type_r (tree t1, tree t2, { if (complain & tf_error) composite_pointer_error (DK_PERMERROR, t1, t2, operation); - + else + return error_mark_node; result_type = void_type_node; } result_type = cp_build_qualified_type (result_type, @@ -527,9 +528,13 @@ composite_pointer_type_r (tree t1, tree t2, if (TYPE_PTR_TO_MEMBER_P (t1)) { if (!same_type_p (TYPE_PTRMEM_CLASS_TYPE (t1), - TYPE_PTRMEM_CLASS_TYPE (t2)) - && (complain & tf_error)) - composite_pointer_error (DK_PERMERROR, t1, t2, operation); + TYPE_PTRMEM_CLASS_TYPE (t2))) + { + if (complain & tf_error) + composite_pointer_error (DK_PERMERROR, t1, t2, operation); + else + return error_mark_node; + } result_type = build_ptrmem_type (TYPE_PTRMEM_CLASS_TYPE (t1), result_type); } @@ -3266,8 +3271,7 @@ cp_build_function_call_vec (tree function, VEC(tree,gc) **params, /* Check for errors in format strings and inappropriately null parameters. */ - check_function_arguments (TYPE_ATTRIBUTES (fntype), nargs, argarray, - parm_types); + check_function_arguments (fntype, nargs, argarray); ret = build_cxx_call (function, nargs, argarray); @@ -5764,11 +5768,11 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, return convert_from_reference (rvalue (cp_fold_convert (type, expr))); } - /* "An lvalue of type cv1 T1 can be cast to type rvalue reference to + /* "A glvalue of type cv1 T1 can be cast to type rvalue reference to cv2 T2 if cv2 T2 is reference-compatible with cv1 T1 (8.5.3)." */ if (TREE_CODE (type) == REFERENCE_TYPE && TYPE_REF_IS_RVALUE (type) - && real_lvalue_p (expr) + && lvalue_or_rvalue_with_address_p (expr) && reference_related_p (TREE_TYPE (type), intype) && (c_cast_p || at_least_as_qualified_p (TREE_TYPE (type), intype))) { @@ -6237,14 +6241,29 @@ build_const_cast_1 (tree dst_type, tree expr, tsubst_flags_t complain, /* [expr.const.cast] - An lvalue of type T1 can be explicitly converted to an lvalue of - type T2 using the cast const_cast<T2&> (where T1 and T2 are object - types) if a pointer to T1 can be explicitly converted to the type - pointer to T2 using a const_cast. */ + For two object types T1 and T2, if a pointer to T1 can be explicitly + converted to the type "pointer to T2" using a const_cast, then the + following conversions can also be made: + + -- an lvalue of type T1 can be explicitly converted to an lvalue of + type T2 using the cast const_cast<T2&>; + + -- a glvalue of type T1 can be explicitly converted to an xvalue of + type T2 using the cast const_cast<T2&&>; and + + -- if T1 is a class type, a prvalue of type T1 can be explicitly + converted to an xvalue of type T2 using the cast const_cast<T2&&>. */ + if (TREE_CODE (dst_type) == REFERENCE_TYPE) { reference_type = dst_type; - if (! real_lvalue_p (expr)) + if (!TYPE_REF_IS_RVALUE (dst_type) + ? real_lvalue_p (expr) + : (CLASS_TYPE_P (TREE_TYPE (dst_type)) + ? lvalue_p (expr) + : lvalue_or_rvalue_with_address_p (expr))) + /* OK. */; + else { if (complain & tf_error) error ("invalid const_cast of an rvalue of type %qT to type %qT", @@ -6429,7 +6448,7 @@ cp_build_c_cast (tree type, tree expr, tsubst_flags_t complain) if (!CLASS_TYPE_P (type)) type = TYPE_MAIN_VARIANT (type); result_type = TREE_TYPE (result); - if (!CLASS_TYPE_P (result_type)) + if (!CLASS_TYPE_P (result_type) && TREE_CODE (type) != REFERENCE_TYPE) result_type = TYPE_MAIN_VARIANT (result_type); /* If the type of RESULT does not match TYPE, perform a const_cast to make it match. If the static_cast or diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 3190803f9c4..be43ed3dae7 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -91,6 +91,7 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "obstack.h" #include "expr.h" +#include "cgraph.h" #ifdef XCOFF_DEBUGGING_INFO #include "xcoffout.h" @@ -2470,6 +2471,20 @@ dbxout_expand_expr (tree expr) disable debug info for these variables. */ if (!targetm.have_tls && DECL_THREAD_LOCAL_P (expr)) return NULL; + if (TREE_STATIC (expr) + && !TREE_ASM_WRITTEN (expr) + && !DECL_HAS_VALUE_EXPR_P (expr) + && !TREE_PUBLIC (expr) + && DECL_RTL_SET_P (expr) + && MEM_P (DECL_RTL (expr))) + { + /* If this is a var that might not be actually output, + return NULL, otherwise stabs might reference an undefined + symbol. */ + struct varpool_node *node = varpool_get_node (expr); + if (!node || !node->needed) + return NULL; + } /* FALLTHRU */ case PARM_DECL: diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 904b805dc61..418fa48fcce 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -1106,12 +1106,6 @@ like C++ and Java. The possibilities for @var{lib} are: AIX thread support. @item dce DCE thread support. -@item gnat -Ada tasking support. For non-Ada programs, this setting is equivalent -to @samp{single}. When used in conjunction with the Ada run time, it -causes GCC to use the same thread primitives as Ada uses. This option -is necessary when using both Ada and the back end exception handling, -which is the default for most Ada targets. @item lynx LynxOS thread support. @item mipssde diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 133e236593f..a0db1d3b5ed 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1840,6 +1840,8 @@ Version 5 corrects the mangling of attribute const/volatile on function pointer types, decltype of a plain decl, and use of a function parameter in the declaration of another parameter. +Version 6 corrects the promotion behavior of C++0x scoped enums. + See also @option{-Wabi}. @item -fno-access-control diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi index edab7a9da66..0a54183d831 100644 --- a/gcc/doc/options.texi +++ b/gcc/doc/options.texi @@ -71,7 +71,8 @@ name of the include file. @item A variable record to record any additional files that the -@file{options.c} file should include. This is useful to provide +@file{options.c} or @file{options-save.c} file should include. This +is useful to provide inline functions needed for target variables and/or @code{#ifdef} sequences to properly set up the initialization. These records have two fields: the string @samp{SourceInclude} and the name of the diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index b85a55ec67c..55453a3622c 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -17719,7 +17719,9 @@ tree_add_const_value_attribute_for_decl (dw_die_ref var_die, tree decl) if (!decl || (TREE_CODE (decl) != VAR_DECL - && TREE_CODE (decl) != CONST_DECL)) + && TREE_CODE (decl) != CONST_DECL) + || (TREE_CODE (decl) == VAR_DECL + && !TREE_STATIC (decl))) return false; if (TREE_READONLY (decl) diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 2e073b5da1f..988072b2cbf 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -3470,17 +3470,40 @@ try_split (rtx pat, rtx trial, int last) } /* If we are splitting a CALL_INSN, look for the CALL_INSN - in SEQ and copy our CALL_INSN_FUNCTION_USAGE to it. */ + in SEQ and copy any additional information across. */ if (CALL_P (trial)) { for (insn = insn_last; insn ; insn = PREV_INSN (insn)) if (CALL_P (insn)) { - rtx *p = &CALL_INSN_FUNCTION_USAGE (insn); + rtx next, *p; + + /* Add the old CALL_INSN_FUNCTION_USAGE to whatever the + target may have explicitly specified. */ + p = &CALL_INSN_FUNCTION_USAGE (insn); while (*p) p = &XEXP (*p, 1); *p = CALL_INSN_FUNCTION_USAGE (trial); + + /* If the old call was a sibling call, the new one must + be too. */ SIBLING_CALL_P (insn) = SIBLING_CALL_P (trial); + + /* If the new call is the last instruction in the sequence, + it will effectively replace the old call in-situ. Otherwise + we must move any following NOTE_INSN_CALL_ARG_LOCATION note + so that it comes immediately after the new call. */ + if (NEXT_INSN (insn)) + { + next = NEXT_INSN (trial); + if (next + && NOTE_P (next) + && NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION) + { + remove_insn (next); + add_insn_after (next, insn, NULL); + } + } } } diff --git a/gcc/expmed.c b/gcc/expmed.c index 18a65929f78..5527c1e7112 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -1769,8 +1769,6 @@ extract_fixed_bit_field (enum machine_mode tmode, rtx op0, /* To extract a signed bit-field, first shift its msb to the msb of the word, then arithmetic-shift its lsb to the lsb of the word. */ op0 = force_reg (mode, op0); - if (mode != tmode) - target = 0; /* Find the narrowest integer mode that contains the field. */ @@ -1782,6 +1780,9 @@ extract_fixed_bit_field (enum machine_mode tmode, rtx op0, break; } + if (mode != tmode) + target = 0; + if (GET_MODE_BITSIZE (mode) != (bitsize + bitpos)) { int amount = GET_MODE_BITSIZE (mode) - (bitsize + bitpos); diff --git a/gcc/expr.c b/gcc/expr.c index dde55711067..971432c19af 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -8105,7 +8105,10 @@ expand_expr_real_2 (sepops ops, rtx target, enum machine_mode tmode, op1 = gen_label_rtx (); jumpifnot_1 (code, treeop0, treeop1, op1, -1); - emit_move_insn (target, const1_rtx); + if (TYPE_PRECISION (type) == 1 && !TYPE_UNSIGNED (type)) + emit_move_insn (target, constm1_rtx); + else + emit_move_insn (target, const1_rtx); emit_label (op1); return target; @@ -10050,7 +10053,8 @@ do_store_flag (sepops ops, rtx target, enum machine_mode mode) if ((code == NE || code == EQ) && TREE_CODE (arg0) == BIT_AND_EXPR && integer_zerop (arg1) - && integer_pow2p (TREE_OPERAND (arg0, 1))) + && integer_pow2p (TREE_OPERAND (arg0, 1)) + && (TYPE_PRECISION (ops->type) != 1 || TYPE_UNSIGNED (ops->type))) { tree type = lang_hooks.types.type_for_mode (mode, unsignedp); return expand_expr (fold_single_bit_test (loc, @@ -10070,7 +10074,9 @@ do_store_flag (sepops ops, rtx target, enum machine_mode mode) /* Try a cstore if possible. */ return emit_store_flag_force (target, code, op0, op1, - operand_mode, unsignedp, 1); + operand_mode, unsignedp, + (TYPE_PRECISION (ops->type) == 1 + && !TYPE_UNSIGNED (ops->type)) ? -1 : 1); } diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ab68eab990c..d399c5376d2 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -13822,7 +13822,8 @@ recursive_label: if (TREE_CODE_CLASS (code) != tcc_type && TREE_CODE_CLASS (code) != tcc_declaration && code != TREE_LIST - && code != SSA_NAME) + && code != SSA_NAME + && CODE_CONTAINS_STRUCT (code, TS_COMMON)) fold_checksum_tree (TREE_CHAIN (expr), ctx, ht); switch (TREE_CODE_CLASS (code)) { diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 45ca79c6d86..55994c3140e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,15 @@ +2011-05-22 Thomas Koenig <tkoenig@gcc.gnu.org> + + * frontend-passes.c (cfe_register_funcs): Also register + character functions if their charlens are known and constant. + Also register allocatable functions. + +2011-05-21 Janus Weil <janus@gcc.gnu.org> + + PR fortran/48699 + * match.c (select_type_set_tmp): Make the temporary ALLOCATABLE if the + selector is ALLOCATABLE. + 2011-05-20 Janus Weil <janus@gcc.gnu.org> PR fortran/48706 diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 186cbb43304..0137a9ddbf2 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -137,8 +137,7 @@ optimize_expr (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, /* Callback function for common function elimination, called from cfe_expr_0. - Put all eligible function expressions into expr_array. We can't do - allocatable functions. */ + Put all eligible function expressions into expr_array. */ static int cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, @@ -148,8 +147,10 @@ cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, if ((*e)->expr_type != EXPR_FUNCTION) return 0; - /* We don't do character functions (yet). */ - if ((*e)->ts.type == BT_CHARACTER) + /* We don't do character functions with unknown charlens. */ + if ((*e)->ts.type == BT_CHARACTER + && ((*e)->ts.u.cl == NULL || (*e)->ts.u.cl->length == NULL + || (*e)->ts.u.cl->length->expr_type != EXPR_CONSTANT)) return 0; /* If we don't know the shape at compile time, we create an allocatable @@ -163,9 +164,6 @@ cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, is specified. */ if ((*e)->value.function.esym) { - if ((*e)->value.function.esym->attr.allocatable) - return 0; - /* Don't create an array temporary for elemental functions. */ if ((*e)->value.function.esym->attr.elemental && (*e)->rank > 0) return 0; @@ -181,9 +179,10 @@ cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, if ((*e)->value.function.isym) { /* Conversions are handled on the fly by the middle end, - transpose during trans-* stages. */ + transpose during trans-* stages and TRANSFER by the middle end. */ if ((*e)->value.function.isym->id == GFC_ISYM_CONVERSION - || (*e)->value.function.isym->id == GFC_ISYM_TRANSPOSE) + || (*e)->value.function.isym->id == GFC_ISYM_TRANSPOSE + || (*e)->value.function.isym->id == GFC_ISYM_TRANSFER) return 0; /* Don't create an array temporary for elemental functions, diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index f1c953adcbe..75f2a7fc570 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -4533,7 +4533,11 @@ select_type_set_tmp (gfc_typespec *ts) gfc_get_sym_tree (name, gfc_current_ns, &tmp, false); gfc_add_type (tmp->n.sym, ts, NULL); gfc_set_sym_referenced (tmp->n.sym); - gfc_add_pointer (&tmp->n.sym->attr, NULL); + if (select_type_stack->selector->ts.type == BT_CLASS && + CLASS_DATA (select_type_stack->selector)->attr.allocatable) + gfc_add_allocatable (&tmp->n.sym->attr, NULL); + else + gfc_add_pointer (&tmp->n.sym->attr, NULL); gfc_add_flavor (&tmp->n.sym->attr, FL_VARIABLE, name, NULL); if (ts->type == BT_CLASS) gfc_build_class_symbol (&tmp->n.sym->ts, &tmp->n.sym->attr, diff --git a/gcc/gcov.c b/gcc/gcov.c index dcbadce4b14..94a1c350c80 100644 --- a/gcc/gcov.c +++ b/gcc/gcov.c @@ -652,13 +652,12 @@ release_structures (void) } } -/* Generate the names of the graph and data files. If OBJECT_DIRECTORY - is not specified, these are looked for in the current directory, - and named from the basename of the FILE_NAME sans extension. If - OBJECT_DIRECTORY is specified and is a directory, the files are in - that directory, but named from the basename of the FILE_NAME, sans - extension. Otherwise OBJECT_DIRECTORY is taken to be the name of - the object *file*, and the data files are named from that. */ +/* Generate the names of the graph and data files. If OBJECT_DIRECTORY + is not specified, these are named from FILE_NAME sans extension. If + OBJECT_DIRECTORY is specified and is a directory, the files are in that + directory, but named from the basename of the FILE_NAME, sans extension. + Otherwise OBJECT_DIRECTORY is taken to be the name of the object *file* + and the data files are named from that. */ static void create_file_names (const char *file_name) @@ -691,8 +690,8 @@ create_file_names (const char *file_name) else { name = XNEWVEC (char, length + 1); - name[0] = 0; - base = 1; + strcpy (name, file_name); + base = 0; } if (base) diff --git a/gcc/gimple.c b/gcc/gimple.c index 4c7fbfc8235..d6c79aa1f5c 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -3587,6 +3587,10 @@ gimple_types_compatible_p_1 (tree t1, tree t2, type_pair_t p, SCCs this assumption may get revisited. */ state->u.same_p = 1; + /* The struct tags shall compare equal. */ + if (!compare_type_names_p (t1, t2, false)) + goto different_types; + /* If their attributes are not the same they can't be the same type. */ if (!attribute_list_equal (TYPE_ATTRIBUTES (t1), TYPE_ATTRIBUTES (t2))) goto different_types; @@ -3797,10 +3801,6 @@ gimple_types_compatible_p_1 (tree t1, tree t2, type_pair_t p, { tree f1, f2; - /* The struct tags shall compare equal. */ - if (!compare_type_names_p (t1, t2, false)) - goto different_types; - /* For aggregate types, all the fields must be the same. */ for (f1 = TYPE_FIELDS (t1), f2 = TYPE_FIELDS (t2); f1 && f2; @@ -4093,7 +4093,8 @@ iterative_hash_gimple_type (tree type, hashval_t val, smaller sets; when searching for existing matching types to merge, only existing types having the same features as the new type will be checked. */ - v = iterative_hash_hashval_t (TREE_CODE (type), 0); + v = iterative_hash_name (TYPE_NAME (type), 0); + v = iterative_hash_hashval_t (TREE_CODE (type), v); v = iterative_hash_hashval_t (TYPE_QUALS (type), v); v = iterative_hash_hashval_t (TREE_ADDRESSABLE (type), v); @@ -4175,8 +4176,6 @@ iterative_hash_gimple_type (tree type, hashval_t val, unsigned nf; tree f; - v = iterative_hash_name (TYPE_NAME (type), v); - for (f = TYPE_FIELDS (type), nf = 0; f; f = TREE_CHAIN (f)) { v = iterative_hash_name (DECL_NAME (f), v); diff --git a/gcc/gthr-gnat.c b/gcc/gthr-gnat.c deleted file mode 100644 index 4730bd392cf..00000000000 --- a/gcc/gthr-gnat.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Threads compatibility routines for libgcc2. */ -/* Compile this one with gcc. */ -/* Copyright (C) 2003, 2004, 2009 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC 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. - -GCC 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. - -Under Section 7 of GPL version 3, you are granted additional -permissions described in the GCC Runtime Library Exception, version -3.1, as published by the Free Software Foundation. - -You should have received a copy of the GNU General Public License and -a copy of the GCC Runtime Library Exception along with this program; -see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -<http://www.gnu.org/licenses/>. */ - -#include "gthr-gnat.h" - -#ifndef HIDE_EXPORTS -#pragma GCC visibility push(default) -#endif - -#ifdef __cplusplus -#define UNUSED(x) -#else -#define UNUSED(x) x __attribute__((unused)) -#endif - -void __gnat_default_lock (void); -void __gnat_default_unlock (void); - -void -__gnat_default_lock (void) -{ - return; -} - -void -__gnat_default_unlock (void) -{ - return; -} - -static void (*__gnat_task_lock) (void) = *__gnat_default_lock; -static void (*__gnat_task_unlock) (void) = *__gnat_default_unlock; - - void -__gnat_install_locks (void (*lock) (void), void (*unlock) (void)) -{ - __gnat_task_lock = lock; - __gnat_task_unlock = unlock; -} - -int -__gthread_active_p (void) -{ - return 0; -} - -int -__gthread_mutex_lock (__gthread_mutex_t * UNUSED (mutex)) -{ - __gnat_task_lock (); - return 0; -} - -int -__gthread_mutex_unlock (__gthread_mutex_t * UNUSED (mutex)) -{ - __gnat_task_unlock (); - return 0; -} - -#ifndef HIDE_EXPORTS -#pragma GCC visibility pop -#endif diff --git a/gcc/gthr-gnat.h b/gcc/gthr-gnat.h deleted file mode 100644 index a10aa80c776..00000000000 --- a/gcc/gthr-gnat.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Threads compatibility routines for libgcc2. */ -/* Compile this one with gcc. */ -/* Copyright (C) 2003, 2004, 2008, 2009 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC 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. -GCC 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. - -Under Section 7 of GPL version 3, you are granted additional -permissions described in the GCC Runtime Library Exception, version -3.1, as published by the Free Software Foundation. - -You should have received a copy of the GNU General Public License and -a copy of the GCC Runtime Library Exception along with this program; -see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -<http://www.gnu.org/licenses/>. */ - -#ifndef GCC_GTHR_GNAT_H -#define GCC_GTHR_GNAT_H - -#ifndef HIDE_EXPORTS -#pragma GCC visibility push(default) -#endif - -/* Just provide compatibility for mutex handling. */ - -typedef int __gthread_mutex_t; - -#define __GTHREAD_MUTEX_INIT 0 - -extern void __gnat_install_locks (void (*) (void), void (*) (void)); -extern int __gthread_active_p (void); -extern int __gthread_mutex_lock (__gthread_mutex_t *); -extern int __gthread_mutex_unlock (__gthread_mutex_t *); - -#ifndef HIDE_EXPORTS -#pragma GCC visibility pop -#endif - -#endif /* ! GCC_GTHR_GNAT_H */ - diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 1b2bb353abb..0b8b595e63c 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,9 @@ +2011-05-21 Nicola Pero <nicola.pero@meta-innovation.com> + + * config-lang.in (gtfiles): Updated order of files to fix building + when the gcc/cp directory is missing, as in the case of some + release tarballs. + 2011-05-20 Nathan Froyd <froydnj@codesourcery.com> * objc-act.c (objc_compare_types): Use function_args_iterator diff --git a/gcc/objc/config-lang.in b/gcc/objc/config-lang.in index db5c5a59ec5..0de0650c0de 100644 --- a/gcc/objc/config-lang.in +++ b/gcc/objc/config-lang.in @@ -33,4 +33,7 @@ target_libs=target-libobjc # Most of the object files for cc1obj actually come from C. lang_requires="c" -gtfiles="\$(srcdir)/objc/objc-act.h \$(srcdir)/objc/objc-act.c \$(srcdir)/objc/objc-runtime-shared-support.c \$(srcdir)/objc/objc-gnu-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-02.c \$(srcdir)/c-parser.c \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-lang.h \$(srcdir)/c-objc-common.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/c-family/c-cppbuiltin.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c" +# Order is important. If you change this list, make sure you test +# building without C++ as well; that is, remove the gcc/cp directory, +# and build with --enable-languages=c,objc. +gtfiles="\$(srcdir)/c-family/c-objc.h \$(srcdir)/objc/objc-act.h \$(srcdir)/objc/objc-act.c \$(srcdir)/objc/objc-runtime-shared-support.c \$(srcdir)/objc/objc-gnu-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-02.c \$(srcdir)/c-parser.c \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-lang.h \$(srcdir)/c-objc-common.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-cppbuiltin.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c" diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index 2c4df708801..519b1e9306c 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -38,11 +38,6 @@ for (i = 1; i <= n_headers; i++) print "#include " quote "opts.h" quote print "#include " quote "intl.h" quote print "" -print "#ifndef GCC_DRIVER" -print "#include " quote "flags.h" quote -print "#include " quote "target.h" quote -print "#endif /* GCC_DRIVER */" -print "" if (n_extra_c_includes > 0) { for (i = 0; i < n_extra_c_includes; i++) { @@ -101,10 +96,6 @@ print "};" print "const unsigned int cl_enums_count = " n_enums ";" print "" -have_save = 0; -if (n_extra_target_vars) - have_save = 1 - print "const struct gcc_options global_options_init =\n{" for (i = 0; i < n_extra_vars; i++) { var = extra_vars[i] @@ -122,9 +113,6 @@ for (i = 0; i < n_extra_vars; i++) { print " " init ", /* " name " */" } for (i = 0; i < n_opts; i++) { - if (flag_set_p("Save", flags[i])) - have_save = 1; - name = var_name(flags[i]); if (name == "") continue; @@ -332,362 +320,4 @@ for (i = 0; i < n_opts; i++) { print "};" -print ""; -print "#if !defined(GCC_DRIVER) && !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS)" -print ""; -print "/* Save optimization variables into a structure. */" -print "void"; -print "cl_optimization_save (struct cl_optimization *ptr, struct gcc_options *opts)"; -print "{"; - -n_opt_char = 2; -n_opt_short = 0; -n_opt_int = 0; -n_opt_enum = 1; -n_opt_other = 0; -var_opt_char[0] = "optimize"; -var_opt_char[1] = "optimize_size"; -var_opt_range["optimize"] = "0, 255"; -var_opt_range["optimize_size"] = "0, 255"; -var_opt_enum[0] = "flag_fp_contract_mode"; - -# Sort by size to mimic how the structure is laid out to be friendlier to the -# cache. - -for (i = 0; i < n_opts; i++) { - if (flag_set_p("Optimization", flags[i])) { - name = var_name(flags[i]) - if(name == "") - continue; - - if(name in var_opt_seen) - continue; - - var_opt_seen[name]++; - otype = var_type_struct(flags[i]); - if (otype ~ "^((un)?signed +)?int *$") - var_opt_int[n_opt_int++] = name; - - else if (otype ~ "^((un)?signed +)?short *$") - var_opt_short[n_opt_short++] = name; - - else if (otype ~ ("^enum +[_" alnum "]+ *")) - var_opt_enum[n_opt_enum++] = name; - - else if (otype ~ "^((un)?signed +)?char *$") { - var_opt_char[n_opt_char++] = name; - if (otype ~ "^unsigned +char *$") - var_opt_range[name] = "0, 255" - else if (otype ~ "^signed +char *$") - var_opt_range[name] = "-128, 127" - } - else - var_opt_other[n_opt_other++] = name; - } -} - -for (i = 0; i < n_opt_char; i++) { - name = var_opt_char[i]; - if (var_opt_range[name] != "") - print " gcc_assert (IN_RANGE (opts->x_" name ", " var_opt_range[name] "));"; -} - -print ""; -for (i = 0; i < n_opt_other; i++) { - print " ptr->x_" var_opt_other[i] " = opts->x_" var_opt_other[i] ";"; -} - -for (i = 0; i < n_opt_int; i++) { - print " ptr->x_" var_opt_int[i] " = opts->x_" var_opt_int[i] ";"; -} - -for (i = 0; i < n_opt_enum; i++) { - print " ptr->x_" var_opt_enum[i] " = opts->x_" var_opt_enum[i] ";"; -} - -for (i = 0; i < n_opt_short; i++) { - print " ptr->x_" var_opt_short[i] " = opts->x_" var_opt_short[i] ";"; -} - -for (i = 0; i < n_opt_char; i++) { - print " ptr->x_" var_opt_char[i] " = opts->x_" var_opt_char[i] ";"; -} - -print "}"; - -print ""; -print "/* Restore optimization options from a structure. */"; -print "void"; -print "cl_optimization_restore (struct gcc_options *opts, struct cl_optimization *ptr)"; -print "{"; - -for (i = 0; i < n_opt_other; i++) { - print " opts->x_" var_opt_other[i] " = ptr->x_" var_opt_other[i] ";"; -} - -for (i = 0; i < n_opt_int; i++) { - print " opts->x_" var_opt_int[i] " = ptr->x_" var_opt_int[i] ";"; -} - -for (i = 0; i < n_opt_enum; i++) { - print " opts->x_" var_opt_enum[i] " = ptr->x_" var_opt_enum[i] ";"; -} - -for (i = 0; i < n_opt_short; i++) { - print " opts->x_" var_opt_short[i] " = ptr->x_" var_opt_short[i] ";"; -} - -for (i = 0; i < n_opt_char; i++) { - print " opts->x_" var_opt_char[i] " = ptr->x_" var_opt_char[i] ";"; -} - -print " targetm.override_options_after_change ();"; -print "}"; - -print ""; -print "/* Print optimization options from a structure. */"; -print "void"; -print "cl_optimization_print (FILE *file,"; -print " int indent_to,"; -print " struct cl_optimization *ptr)"; -print "{"; - -print " fputs (\"\\n\", file);"; -for (i = 0; i < n_opt_other; i++) { - print " if (ptr->x_" var_opt_other[i] ")"; - print " fprintf (file, \"%*s%s (%#lx)\\n\","; - print " indent_to, \"\","; - print " \"" var_opt_other[i] "\","; - print " (unsigned long)ptr->x_" var_opt_other[i] ");"; - print ""; -} - -for (i = 0; i < n_opt_int; i++) { - print " if (ptr->x_" var_opt_int[i] ")"; - print " fprintf (file, \"%*s%s (%#x)\\n\","; - print " indent_to, \"\","; - print " \"" var_opt_int[i] "\","; - print " ptr->x_" var_opt_int[i] ");"; - print ""; -} - -for (i = 0; i < n_opt_enum; i++) { - print " fprintf (file, \"%*s%s (%#x)\\n\","; - print " indent_to, \"\","; - print " \"" var_opt_enum[i] "\","; - print " (int) ptr->x_" var_opt_enum[i] ");"; - print ""; -} - -for (i = 0; i < n_opt_short; i++) { - print " if (ptr->x_" var_opt_short[i] ")"; - print " fprintf (file, \"%*s%s (%#x)\\n\","; - print " indent_to, \"\","; - print " \"" var_opt_short[i] "\","; - print " ptr->x_" var_opt_short[i] ");"; - print ""; -} - -for (i = 0; i < n_opt_char; i++) { - print " if (ptr->x_" var_opt_char[i] ")"; - print " fprintf (file, \"%*s%s (%#x)\\n\","; - print " indent_to, \"\","; - print " \"" var_opt_char[i] "\","; - print " ptr->x_" var_opt_char[i] ");"; - print ""; -} - -print "}"; - -print ""; -print "/* Save selected option variables into a structure. */" -print "void"; -print "cl_target_option_save (struct cl_target_option *ptr, struct gcc_options *opts)"; -print "{"; - -n_target_char = 0; -n_target_short = 0; -n_target_int = 0; -n_target_enum = 0; -n_target_other = 0; - -if (have_save) { - for (i = 0; i < n_opts; i++) { - if (flag_set_p("Save", flags[i])) { - name = var_name(flags[i]) - if(name == "") - name = "target_flags"; - - if(name in var_save_seen) - continue; - - var_save_seen[name]++; - otype = var_type_struct(flags[i]) - if (otype ~ "^((un)?signed +)?int *$") - var_target_int[n_target_int++] = name; - - else if (otype ~ "^((un)?signed +)?short *$") - var_target_short[n_target_short++] = name; - - else if (otype ~ ("^enum +[_" alnum "]+ *$")) - var_target_enum[n_target_enum++] = name; - - else if (otype ~ "^((un)?signed +)?char *$") { - var_target_char[n_target_char++] = name; - if (otype ~ "^unsigned +char *$") - var_target_range[name] = "0, 255" - else if (otype ~ "^signed +char *$") - var_target_range[name] = "-128, 127" - if (otype == var_type(flags[i])) - var_target_range[name] = "" - } - else - var_target_other[n_target_other++] = name; - } - } -} else { - var_target_int[n_target_int++] = "target_flags"; -} - -have_assert = 0; -for (i = 0; i < n_target_char; i++) { - name = var_target_char[i]; - if (var_target_range[name] != "") { - have_assert = 1; - print " gcc_assert (IN_RANGE (opts->x_" name ", " var_target_range[name] "));"; - } -} - -if (have_assert) - print ""; - -print " if (targetm.target_option.save)"; -print " targetm.target_option.save (ptr);"; -print ""; - -for (i = 0; i < n_extra_target_vars; i++) { - print " ptr->x_" extra_target_vars[i] " = opts->x_" extra_target_vars[i] ";"; -} - -for (i = 0; i < n_target_other; i++) { - print " ptr->x_" var_target_other[i] " = opts->x_" var_target_other[i] ";"; -} - -for (i = 0; i < n_target_enum; i++) { - print " ptr->x_" var_target_enum[i] " = opts->x_" var_target_enum[i] ";"; -} - -for (i = 0; i < n_target_int; i++) { - print " ptr->x_" var_target_int[i] " = opts->x_" var_target_int[i] ";"; -} - -for (i = 0; i < n_target_short; i++) { - print " ptr->x_" var_target_short[i] " = opts->x_" var_target_short[i] ";"; -} - -for (i = 0; i < n_target_char; i++) { - print " ptr->x_" var_target_char[i] " = opts->x_" var_target_char[i] ";"; -} - -print "}"; - -print ""; -print "/* Restore selected current options from a structure. */"; -print "void"; -print "cl_target_option_restore (struct gcc_options *opts, struct cl_target_option *ptr)"; -print "{"; - -for (i = 0; i < n_extra_target_vars; i++) { - print " opts->x_" extra_target_vars[i] " = ptr->x_" extra_target_vars[i] ";"; -} - -for (i = 0; i < n_target_other; i++) { - print " opts->x_" var_target_other[i] " = ptr->x_" var_target_other[i] ";"; -} - -for (i = 0; i < n_target_enum; i++) { - print " opts->x_" var_target_enum[i] " = ptr->x_" var_target_enum[i] ";"; -} - -for (i = 0; i < n_target_int; i++) { - print " opts->x_" var_target_int[i] " = ptr->x_" var_target_int[i] ";"; -} - -for (i = 0; i < n_target_short; i++) { - print " opts->x_" var_target_short[i] " = ptr->x_" var_target_short[i] ";"; -} - -for (i = 0; i < n_target_char; i++) { - print " opts->x_" var_target_char[i] " = ptr->x_" var_target_char[i] ";"; -} - -# This must occur after the normal variables in case the code depends on those -# variables. -print ""; -print " if (targetm.target_option.restore)"; -print " targetm.target_option.restore (ptr);"; - -print "}"; - -print ""; -print "/* Print optimization options from a structure. */"; -print "void"; -print "cl_target_option_print (FILE *file,"; -print " int indent,"; -print " struct cl_target_option *ptr)"; -print "{"; - -print " fputs (\"\\n\", file);"; -for (i = 0; i < n_target_other; i++) { - print " if (ptr->x_" var_target_other[i] ")"; - print " fprintf (file, \"%*s%s (%#lx)\\n\","; - print " indent, \"\","; - print " \"" var_target_other[i] "\","; - print " (unsigned long)ptr->x_" var_target_other[i] ");"; - print ""; -} - -for (i = 0; i < n_target_enum; i++) { - print " if (ptr->x_" var_target_enum[i] ")"; - print " fprintf (file, \"%*s%s (%#x)\\n\","; - print " indent, \"\","; - print " \"" var_target_enum[i] "\","; - print " ptr->x_" var_target_enum[i] ");"; - print ""; -} - -for (i = 0; i < n_target_int; i++) { - print " if (ptr->x_" var_target_int[i] ")"; - print " fprintf (file, \"%*s%s (%#x)\\n\","; - print " indent, \"\","; - print " \"" var_target_int[i] "\","; - print " ptr->x_" var_target_int[i] ");"; - print ""; -} - -for (i = 0; i < n_target_short; i++) { - print " if (ptr->x_" var_target_short[i] ")"; - print " fprintf (file, \"%*s%s (%#x)\\n\","; - print " indent, \"\","; - print " \"" var_target_short[i] "\","; - print " ptr->x_" var_target_short[i] ");"; - print ""; -} - -for (i = 0; i < n_target_char; i++) { - print " if (ptr->x_" var_target_char[i] ")"; - print " fprintf (file, \"%*s%s (%#x)\\n\","; - print " indent, \"\","; - print " \"" var_target_char[i] "\","; - print " ptr->x_" var_target_char[i] ");"; - print ""; -} - -print ""; -print " if (targetm.target_option.print)"; -print " targetm.target_option.print (file, indent, ptr);"; - -print "}"; -print "#endif"; - } diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk new file mode 100644 index 00000000000..4efc11598bf --- /dev/null +++ b/gcc/optc-save-gen.awk @@ -0,0 +1,415 @@ +# Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011 +# Free Software Foundation, Inc. +# Contributed by Kelley Cook, June 2004. +# Original code from Neil Booth, May 2003. +# +# This program 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 program 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 program; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# This Awk script reads in the option records generated from +# opt-gather.awk, combines the flags of duplicate options and generates a +# C file. +# + +# This program uses functions from opt-functions.awk and code from +# opt-read.awk. +# +# Usage: awk -f opt-functions.awk -f opt-read.awk -f optc-save-gen.awk \ +# [-v header_name=header.h] < inputfile > options-save.c + +# Dump that array of options into a C file. +END { +print "/* This file is auto-generated by optc-save-gen.awk. */" +print "" +n_headers = split(header_name, headers, " ") +for (i = 1; i <= n_headers; i++) + print "#include " quote headers[i] quote +print "#include " quote "opts.h" quote +print "#include " quote "intl.h" quote +print "" +print "#include " quote "flags.h" quote +print "#include " quote "target.h" quote +print "" + +if (n_extra_c_includes > 0) { + for (i = 0; i < n_extra_c_includes; i++) { + print "#include " quote extra_c_includes[i] quote + } + print "" +} + +have_save = 0; +if (n_extra_target_vars) + have_save = 1 + +for (i = 0; i < n_opts; i++) { + if (flag_set_p("Save", flags[i])) + have_save = 1; +} + +print "/* Save optimization variables into a structure. */" +print "void"; +print "cl_optimization_save (struct cl_optimization *ptr, struct gcc_options *opts)"; +print "{"; + +n_opt_char = 2; +n_opt_short = 0; +n_opt_int = 0; +n_opt_enum = 1; +n_opt_other = 0; +var_opt_char[0] = "optimize"; +var_opt_char[1] = "optimize_size"; +var_opt_range["optimize"] = "0, 255"; +var_opt_range["optimize_size"] = "0, 255"; +var_opt_enum[0] = "flag_fp_contract_mode"; + +# Sort by size to mimic how the structure is laid out to be friendlier to the +# cache. + +for (i = 0; i < n_opts; i++) { + if (flag_set_p("Optimization", flags[i])) { + name = var_name(flags[i]) + if(name == "") + continue; + + if(name in var_opt_seen) + continue; + + var_opt_seen[name]++; + otype = var_type_struct(flags[i]); + if (otype ~ "^((un)?signed +)?int *$") + var_opt_int[n_opt_int++] = name; + + else if (otype ~ "^((un)?signed +)?short *$") + var_opt_short[n_opt_short++] = name; + + else if (otype ~ ("^enum +[_" alnum "]+ *")) + var_opt_enum[n_opt_enum++] = name; + + else if (otype ~ "^((un)?signed +)?char *$") { + var_opt_char[n_opt_char++] = name; + if (otype ~ "^unsigned +char *$") + var_opt_range[name] = "0, 255" + else if (otype ~ "^signed +char *$") + var_opt_range[name] = "-128, 127" + } + else + var_opt_other[n_opt_other++] = name; + } +} + +for (i = 0; i < n_opt_char; i++) { + name = var_opt_char[i]; + if (var_opt_range[name] != "") + print " gcc_assert (IN_RANGE (opts->x_" name ", " var_opt_range[name] "));"; +} + +print ""; +for (i = 0; i < n_opt_other; i++) { + print " ptr->x_" var_opt_other[i] " = opts->x_" var_opt_other[i] ";"; +} + +for (i = 0; i < n_opt_int; i++) { + print " ptr->x_" var_opt_int[i] " = opts->x_" var_opt_int[i] ";"; +} + +for (i = 0; i < n_opt_enum; i++) { + print " ptr->x_" var_opt_enum[i] " = opts->x_" var_opt_enum[i] ";"; +} + +for (i = 0; i < n_opt_short; i++) { + print " ptr->x_" var_opt_short[i] " = opts->x_" var_opt_short[i] ";"; +} + +for (i = 0; i < n_opt_char; i++) { + print " ptr->x_" var_opt_char[i] " = opts->x_" var_opt_char[i] ";"; +} + +print "}"; + +print ""; +print "/* Restore optimization options from a structure. */"; +print "void"; +print "cl_optimization_restore (struct gcc_options *opts, struct cl_optimization *ptr)"; +print "{"; + +for (i = 0; i < n_opt_other; i++) { + print " opts->x_" var_opt_other[i] " = ptr->x_" var_opt_other[i] ";"; +} + +for (i = 0; i < n_opt_int; i++) { + print " opts->x_" var_opt_int[i] " = ptr->x_" var_opt_int[i] ";"; +} + +for (i = 0; i < n_opt_enum; i++) { + print " opts->x_" var_opt_enum[i] " = ptr->x_" var_opt_enum[i] ";"; +} + +for (i = 0; i < n_opt_short; i++) { + print " opts->x_" var_opt_short[i] " = ptr->x_" var_opt_short[i] ";"; +} + +for (i = 0; i < n_opt_char; i++) { + print " opts->x_" var_opt_char[i] " = ptr->x_" var_opt_char[i] ";"; +} + +print " targetm.override_options_after_change ();"; +print "}"; + +print ""; +print "/* Print optimization options from a structure. */"; +print "void"; +print "cl_optimization_print (FILE *file,"; +print " int indent_to,"; +print " struct cl_optimization *ptr)"; +print "{"; + +print " fputs (\"\\n\", file);"; +for (i = 0; i < n_opt_other; i++) { + print " if (ptr->x_" var_opt_other[i] ")"; + print " fprintf (file, \"%*s%s (%#lx)\\n\","; + print " indent_to, \"\","; + print " \"" var_opt_other[i] "\","; + print " (unsigned long)ptr->x_" var_opt_other[i] ");"; + print ""; +} + +for (i = 0; i < n_opt_int; i++) { + print " if (ptr->x_" var_opt_int[i] ")"; + print " fprintf (file, \"%*s%s (%#x)\\n\","; + print " indent_to, \"\","; + print " \"" var_opt_int[i] "\","; + print " ptr->x_" var_opt_int[i] ");"; + print ""; +} + +for (i = 0; i < n_opt_enum; i++) { + print " fprintf (file, \"%*s%s (%#x)\\n\","; + print " indent_to, \"\","; + print " \"" var_opt_enum[i] "\","; + print " (int) ptr->x_" var_opt_enum[i] ");"; + print ""; +} + +for (i = 0; i < n_opt_short; i++) { + print " if (ptr->x_" var_opt_short[i] ")"; + print " fprintf (file, \"%*s%s (%#x)\\n\","; + print " indent_to, \"\","; + print " \"" var_opt_short[i] "\","; + print " ptr->x_" var_opt_short[i] ");"; + print ""; +} + +for (i = 0; i < n_opt_char; i++) { + print " if (ptr->x_" var_opt_char[i] ")"; + print " fprintf (file, \"%*s%s (%#x)\\n\","; + print " indent_to, \"\","; + print " \"" var_opt_char[i] "\","; + print " ptr->x_" var_opt_char[i] ");"; + print ""; +} + +print "}"; + +print ""; +print "/* Save selected option variables into a structure. */" +print "void"; +print "cl_target_option_save (struct cl_target_option *ptr, struct gcc_options *opts)"; +print "{"; + +n_target_char = 0; +n_target_short = 0; +n_target_int = 0; +n_target_enum = 0; +n_target_other = 0; + +if (have_save) { + for (i = 0; i < n_opts; i++) { + if (flag_set_p("Save", flags[i])) { + name = var_name(flags[i]) + if(name == "") + name = "target_flags"; + + if(name in var_save_seen) + continue; + + var_save_seen[name]++; + otype = var_type_struct(flags[i]) + if (otype ~ "^((un)?signed +)?int *$") + var_target_int[n_target_int++] = name; + + else if (otype ~ "^((un)?signed +)?short *$") + var_target_short[n_target_short++] = name; + + else if (otype ~ ("^enum +[_" alnum "]+ *$")) + var_target_enum[n_target_enum++] = name; + + else if (otype ~ "^((un)?signed +)?char *$") { + var_target_char[n_target_char++] = name; + if (otype ~ "^unsigned +char *$") + var_target_range[name] = "0, 255" + else if (otype ~ "^signed +char *$") + var_target_range[name] = "-128, 127" + if (otype == var_type(flags[i])) + var_target_range[name] = "" + } + else + var_target_other[n_target_other++] = name; + } + } +} else { + var_target_int[n_target_int++] = "target_flags"; +} + +have_assert = 0; +for (i = 0; i < n_target_char; i++) { + name = var_target_char[i]; + if (var_target_range[name] != "") { + have_assert = 1; + print " gcc_assert (IN_RANGE (opts->x_" name ", " var_target_range[name] "));"; + } +} + +if (have_assert) + print ""; + +print " if (targetm.target_option.save)"; +print " targetm.target_option.save (ptr);"; +print ""; + +for (i = 0; i < n_extra_target_vars; i++) { + print " ptr->x_" extra_target_vars[i] " = opts->x_" extra_target_vars[i] ";"; +} + +for (i = 0; i < n_target_other; i++) { + print " ptr->x_" var_target_other[i] " = opts->x_" var_target_other[i] ";"; +} + +for (i = 0; i < n_target_enum; i++) { + print " ptr->x_" var_target_enum[i] " = opts->x_" var_target_enum[i] ";"; +} + +for (i = 0; i < n_target_int; i++) { + print " ptr->x_" var_target_int[i] " = opts->x_" var_target_int[i] ";"; +} + +for (i = 0; i < n_target_short; i++) { + print " ptr->x_" var_target_short[i] " = opts->x_" var_target_short[i] ";"; +} + +for (i = 0; i < n_target_char; i++) { + print " ptr->x_" var_target_char[i] " = opts->x_" var_target_char[i] ";"; +} + +print "}"; + +print ""; +print "/* Restore selected current options from a structure. */"; +print "void"; +print "cl_target_option_restore (struct gcc_options *opts, struct cl_target_option *ptr)"; +print "{"; + +for (i = 0; i < n_extra_target_vars; i++) { + print " opts->x_" extra_target_vars[i] " = ptr->x_" extra_target_vars[i] ";"; +} + +for (i = 0; i < n_target_other; i++) { + print " opts->x_" var_target_other[i] " = ptr->x_" var_target_other[i] ";"; +} + +for (i = 0; i < n_target_enum; i++) { + print " opts->x_" var_target_enum[i] " = ptr->x_" var_target_enum[i] ";"; +} + +for (i = 0; i < n_target_int; i++) { + print " opts->x_" var_target_int[i] " = ptr->x_" var_target_int[i] ";"; +} + +for (i = 0; i < n_target_short; i++) { + print " opts->x_" var_target_short[i] " = ptr->x_" var_target_short[i] ";"; +} + +for (i = 0; i < n_target_char; i++) { + print " opts->x_" var_target_char[i] " = ptr->x_" var_target_char[i] ";"; +} + +# This must occur after the normal variables in case the code depends on those +# variables. +print ""; +print " if (targetm.target_option.restore)"; +print " targetm.target_option.restore (ptr);"; + +print "}"; + +print ""; +print "/* Print optimization options from a structure. */"; +print "void"; +print "cl_target_option_print (FILE *file,"; +print " int indent,"; +print " struct cl_target_option *ptr)"; +print "{"; + +print " fputs (\"\\n\", file);"; +for (i = 0; i < n_target_other; i++) { + print " if (ptr->x_" var_target_other[i] ")"; + print " fprintf (file, \"%*s%s (%#lx)\\n\","; + print " indent, \"\","; + print " \"" var_target_other[i] "\","; + print " (unsigned long)ptr->x_" var_target_other[i] ");"; + print ""; +} + +for (i = 0; i < n_target_enum; i++) { + print " if (ptr->x_" var_target_enum[i] ")"; + print " fprintf (file, \"%*s%s (%#x)\\n\","; + print " indent, \"\","; + print " \"" var_target_enum[i] "\","; + print " ptr->x_" var_target_enum[i] ");"; + print ""; +} + +for (i = 0; i < n_target_int; i++) { + print " if (ptr->x_" var_target_int[i] ")"; + print " fprintf (file, \"%*s%s (%#x)\\n\","; + print " indent, \"\","; + print " \"" var_target_int[i] "\","; + print " ptr->x_" var_target_int[i] ");"; + print ""; +} + +for (i = 0; i < n_target_short; i++) { + print " if (ptr->x_" var_target_short[i] ")"; + print " fprintf (file, \"%*s%s (%#x)\\n\","; + print " indent, \"\","; + print " \"" var_target_short[i] "\","; + print " ptr->x_" var_target_short[i] ");"; + print ""; +} + +for (i = 0; i < n_target_char; i++) { + print " if (ptr->x_" var_target_char[i] ")"; + print " fprintf (file, \"%*s%s (%#x)\\n\","; + print " indent, \"\","; + print " \"" var_target_char[i] "\","; + print " ptr->x_" var_target_char[i] ");"; + print ""; +} + +print ""; +print " if (targetm.target_option.print)"; +print " targetm.target_option.print (file, indent, ptr);"; + +print "}"; + +} diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk index 7877d033b69..876e0f6336e 100644 --- a/gcc/opth-gen.awk +++ b/gcc/opth-gen.awk @@ -46,7 +46,7 @@ if (n_extra_h_includes > 0) { print "#if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS) && !defined(IN_RTS)" print "#ifndef GENERATOR_FILE" -print "#if !defined(GCC_DRIVER) && !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS)" +print "#if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS)" print "struct GTY(()) gcc_options" print "#else" print "struct gcc_options" @@ -127,7 +127,7 @@ print "" # Also, order the structure so that pointer fields occur first, then int # fields, and then char fields to provide the best packing. -print "#if !defined(GCC_DRIVER) && !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS)" +print "#if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS)" print "" print "/* Structure to save/restore optimization and target specific options. */"; print "struct GTY(()) cl_optimization"; diff --git a/gcc/po/ChangeLog b/gcc/po/ChangeLog index 7ebc82a56b4..cb258afea9b 100644 --- a/gcc/po/ChangeLog +++ b/gcc/po/ChangeLog @@ -1,3 +1,7 @@ +2011-05-23 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + * EXCLUDES: Remove gthr-gnat.c, gthr-gnat.h. + 2011-05-19 Joseph Myers <joseph@codesourcery.com> * zh_CN.po: Update. diff --git a/gcc/po/EXCLUDES b/gcc/po/EXCLUDES index f53f845c34b..7eb38b58012 100644 --- a/gcc/po/EXCLUDES +++ b/gcc/po/EXCLUDES @@ -1,4 +1,4 @@ -# Copyright (C) 2001, 2004, 2009, 2010 Free Software Foundation, Inc. +# Copyright (C) 2001, 2004, 2009, 2010, 2011 Free Software Foundation, Inc. # # This file is part of GCC. # @@ -32,8 +32,6 @@ gcov-io.h gcov-iov.c gthr-aix.h gthr-dce.h -gthr-gnat.c -gthr-gnat.h gthr-posix.c gthr-posix.h gthr-rtems.h diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d5fba0b51fd..2e433a8cd76 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,118 @@ +2011-05-24 Tom de Vries <tom@codesourcery.com> + + PR tree-optimization/49121 + * gcc.dg/tree-ssa/ivopt_infer_2.c: Adapt test. + +2011-05-23 Jason Merrill <jason@redhat.com> + + * g++.dg/cpp0x/defaulted28.C: New. + + * g++.dg/cpp0x/sfinae25.C: New. + + * g++.dg/cpp0x/rv-cast2.C: New. + + * g++.dg/cpp0x/enum14.C: New. + +2011-05-23 Jakub Jelinek <jakub@redhat.com> + + PR lto/49123 + * gcc.c-torture/execute/pr49123.c: New test. + + PR debug/49032 + * gcc.dg/debug/pr49032.c: New test. + + PR c/49120 + * gcc.dg/pr49120.c: New test. + +2011-05-23 H.J. Lu <hongjiu.lu@intel.com> + + PR target/47315 + * gcc.target/i386/pr47315.c: New test. + +2011-05-23 Jason Merrill <jason@redhat.com> + + * g++.dg/cpp0x/lambda/lambda-eh2.C: New. + + * g++.dg/cpp0x/sfinae24.C: New. + + * g++.dg/cpp0x/error3.C: New. + + * g++.dg/cpp0x/defaulted27.C: New. + + * g++.dg/cpp0x/decltype27.C: New. + +2011-05-23 Richard Guenther <rguenther@suse.de> + + * gcc.dg/tree-ssa/forwprop-11.c: Adjust and un-XFAIL. + +2011-05-23 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/40874 + * g++.dg/tree-ssa/pr40874.C: New testcase. + +2011-05-23 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/49115 + * g++.dg/torture/pr49115.C: New testcase. + +2011-05-23 Richard Guenther <rguenther@suse.de> + + PR middle-end/15419 + * gcc.dg/memcpy-3.c: New testcase. + +2011-05-23 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/48973 + * gcc.c-torture/execute/pr48973-1.c: New test. + * gcc.c-torture/execute/pr48973-2.c: New test. + +2011-05-23 Jonathan Wakely <jwakely.gcc@gmail.com> + + PR c++/18016 + * g++.dg/warn/pr18016.C: New. + +2011-05-23 Tom de Vries <tom@codesourcery.com> + + PR target/45098 + * gcc.target/arm/ivopts-6.c: New test. + +2011-05-22 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/49029 + * gcc.c-torture/compile/pr49029.c: New test. + +2011-05-22 Jason Merrill <jason@redhat.com> + + * g++.dg/cpp0x/sfinae23.C: New. + * g++.dg/cpp0x/sfinae8.C: Correct. + +2011-05-22 Thomas Koenig <tkoenig@gcc.gnu.org> + + * gfortran.dg/function_optimize_8.f90: New test case. + +2011-05-22 Ira Rosen <ira.rosen@linaro.org> + + PR tree-optimization/49087 + * gcc.dg/vect/O3-pr49087.c: New test. + +2011-05-21 Jason Merrill <jason@redhat.com> + + * g++.dg/debug/const5.C: New. + +2011-05-20 Jason Merrill <jason@redhat.com> + + * g++.dg/cpp0x/constexpr-static7.C: Extend. + + * g++.dg/cpp0x/constexpr-static7.C: New. + + * g++.dg/cpp0x/enum12.C: New. + * g++.dg/cpp0x/enum13.C: New. + +2011-05-21 Janus Weil <janus@gcc.gnu.org> + + PR fortran/48699 + * gfortran.dg/select_type_23.f03: New. + 2011-05-20 Jason Merrill <jason@redhat.com> * g++.dg/cpp0x/defaulted26.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static7.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static7.C new file mode 100644 index 00000000000..e46ddafd702 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static7.C @@ -0,0 +1,10 @@ +// PR c++/48945 +// { dg-options -std=c++0x } + +struct A { + static constexpr bool is(); + static constexpr bool is_not(); +}; + +constexpr bool A::is() { return true; } +constexpr bool A::is_not() const { return true; } // { dg-error "static" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype27.C b/gcc/testsuite/g++.dg/cpp0x/decltype27.C new file mode 100644 index 00000000000..cb962ada525 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype27.C @@ -0,0 +1,9 @@ +// PR c++/48617 +// { dg-options -std=c++0x } + +template<class T, decltype(T())> // # +struct A {}; + +A<int, 0> a; + +int main() {} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted27.C b/gcc/testsuite/g++.dg/cpp0x/defaulted27.C new file mode 100644 index 00000000000..7d9139d2373 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted27.C @@ -0,0 +1,19 @@ +// PR c++/47544 +// { dg-options -std=c++0x } +// { dg-final { scan-assembler "_ZN1sIiEC2Ev" } } +// { dg-final { scan-assembler-not "_ZN1sIiED2Ev" } } + +template <typename T> +struct s { + s(); + ~s() = default; +}; + +extern template struct s<int>; + +template <typename T> +s<T>::s() = default; + +template struct s<int>; + +s<int> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted28.C b/gcc/testsuite/g++.dg/cpp0x/defaulted28.C new file mode 100644 index 00000000000..15caef6cca6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted28.C @@ -0,0 +1,15 @@ +// PR c++/49102 +// { dg-options -std=c++0x } + +struct A { + A() = default; + +private: + A(A const&) = default; // { dg-error "private" } +}; + +void f(...) { } +int main() { + A a; + f(a); // { dg-error "this context" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum12.C b/gcc/testsuite/g++.dg/cpp0x/enum12.C new file mode 100644 index 00000000000..b2ec91990e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum12.C @@ -0,0 +1,18 @@ +// PR c++/48780 +// { dg-options "-std=c++0x -fabi-version=0" } + +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; + +enum struct A : short { X }; + +void foo(int x, ...) { + va_list vl; + __builtin_va_start(vl, x); + enum A t = __builtin_va_arg(vl, enum A); + __builtin_va_end(vl); +} + +int main() { + foo(0, A::X); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum13.C b/gcc/testsuite/g++.dg/cpp0x/enum13.C new file mode 100644 index 00000000000..ec02d3bf607 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum13.C @@ -0,0 +1,20 @@ +// PR c++/48780 +// { dg-options "-std=c++0x -fabi-version=5 -Wabi" } + +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; + +enum struct A : short { X }; + +void foo(int x, ...) { + va_list vl; + __builtin_va_start(vl, x); + enum A t = __builtin_va_arg(vl, enum A); // { dg-warning "promote" } + __builtin_va_end(vl); +} + +int main() { + foo(0, A::X); // { dg-warning "will not promote" } +} + +// { dg-prune-output "note" } diff --git a/gcc/testsuite/g++.dg/cpp0x/enum14.C b/gcc/testsuite/g++.dg/cpp0x/enum14.C new file mode 100644 index 00000000000..709b201d1f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum14.C @@ -0,0 +1,12 @@ +// PR c++/48106 +// { dg-options -std=c++0x } + +enum class E : char +{ + e +}; + +bool operator&(E e, char m) +{ + return static_cast<int>(e) & m; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/error3.C b/gcc/testsuite/g++.dg/cpp0x/error3.C new file mode 100644 index 00000000000..e7da961950e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/error3.C @@ -0,0 +1,24 @@ +// PR c++/47336 +// { dg-options -std=c++0x } + +template <typename T> +void g(T t) +{ + t+1; // { dg-error "no match" } +} + +template <typename S> +class C +{ + struct D {} d; +public: + decltype(g(d)) h() + { + return g(d); + } +}; + +int main() +{ + C<int>().h(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C new file mode 100644 index 00000000000..1490a250837 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C @@ -0,0 +1,16 @@ +// PR c++/47263 +// { dg-options -std=c++0x } +// { dg-do run } + +#include <exception> + +int main( void ) +{ + std::set_unexpected( []{ throw 0; } ); + try + { + []() throw( int ) { throw nullptr; }(); + } + catch( int ) + { } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-cast2.C b/gcc/testsuite/g++.dg/cpp0x/rv-cast2.C new file mode 100644 index 00000000000..94ee4ca849e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-cast2.C @@ -0,0 +1,21 @@ +// Test for const_cast to reference (5.2.11/4). +// { dg-options -std=c++0x } + +template <class T> T&& xval(); +template <class T> T& lval(); +template <class T> T prval(); + +struct A { }; + +int main() +{ + const_cast<int&>(lval<int>()); + const_cast<int&>(xval<int>()); // { dg-error "" } + const_cast<int&>(prval<int>()); // { dg-error "" } + const_cast<int&&>(lval<int>()); + const_cast<int&&>(xval<int>()); + const_cast<int&&>(prval<int>()); // { dg-error "" } + const_cast<A&&>(lval<A>()); + const_cast<A&&>(xval<A>()); + const_cast<A&&>(prval<A>()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae23.C b/gcc/testsuite/g++.dg/cpp0x/sfinae23.C new file mode 100644 index 00000000000..4e2ea88b171 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae23.C @@ -0,0 +1,28 @@ +// PR c++/48647 +// { dg-options -std=c++0x } + +template< class T > +T&& declval(); + +template< class T, class U > +decltype( true ? declval<T>() : declval<U>() ) test( int ); + +template< class T, class U > +void test( ... ); + + +template< class T, class U > +struct is_same { + static const bool value = false; +}; + +template< class T > +struct is_same<T, T> { + static const bool value = true; +}; + +#define SA(X) static_assert ((X),#X) + +typedef decltype( test<int*, double*>(0) ) void_expected; +SA ((is_same<void_expected, void>::value)); +SA ((!is_same<void_expected, void*>::value)); diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae24.C b/gcc/testsuite/g++.dg/cpp0x/sfinae24.C new file mode 100644 index 00000000000..3e1d2e725b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae24.C @@ -0,0 +1,29 @@ +// PR c++/49058 +// This error is not subject to SFINAE because it doesn't happen in the +// deduction context. +// { dg-options -std=c++0x } +// { dg-prune-output "note" } + +template<typename T> T val(); + +struct F1 +{ + void operator()(); +}; + +template<typename F> +struct Bind +{ + template<typename R + = decltype( val<F>()( ) )> + R f(); + + template<typename R + = decltype( val<const F>()( ) )> + R f() const; // { dg-error "no match" } +}; + +int main() +{ + Bind<F1> b; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae25.C b/gcc/testsuite/g++.dg/cpp0x/sfinae25.C new file mode 100644 index 00000000000..7bdc8f88e51 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae25.C @@ -0,0 +1,10 @@ +// PR c++/49105 +// { dg-options -std=c++0x } + +template<class T, class = decltype(T{})> +char f(int); + +template<class T> +auto f(...) -> char(&)[2]; + +static_assert(sizeof(f<const int&&>(0)) == 1, "Error"); // # diff --git a/gcc/testsuite/g++.dg/debug/const5.C b/gcc/testsuite/g++.dg/debug/const5.C new file mode 100644 index 00000000000..e5387ea20ef --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/const5.C @@ -0,0 +1,13 @@ +// PR c++/49092 + +struct A +{ + A(); +}; + +int i; + +A::A() +{ + const int j = i; +} diff --git a/gcc/testsuite/g++.dg/template/sfinae8.C b/gcc/testsuite/g++.dg/template/sfinae8.C index 2ad68dc5dbf..5ac09c6b3b8 100644 --- a/gcc/testsuite/g++.dg/template/sfinae8.C +++ b/gcc/testsuite/g++.dg/template/sfinae8.C @@ -120,7 +120,7 @@ STATIC_ASSERT((!is_equality_comparable<Y, X>::value)); STATIC_ASSERT((!is_equality_comparable<Y>::value)); STATIC_ASSERT((is_equality_comparable<int X::*>::value)); STATIC_ASSERT((!is_equality_comparable<int X::*, int Y::*>::value)); -STATIC_ASSERT((is_equality_comparable<int*, float*>::value)); +STATIC_ASSERT((!is_equality_comparable<int*, float*>::value)); STATIC_ASSERT((is_equality_comparable<X*, Z*>::value)); STATIC_ASSERT((!is_equality_comparable<X*, Y*>::value)); @@ -139,7 +139,7 @@ STATIC_ASSERT((!is_not_equal_comparable<Y, X>::value)); STATIC_ASSERT((!is_not_equal_comparable<Y>::value)); STATIC_ASSERT((is_not_equal_comparable<int X::*>::value)); STATIC_ASSERT((!is_not_equal_comparable<int X::*, int Y::*>::value)); -STATIC_ASSERT((is_not_equal_comparable<int*, float*>::value)); +STATIC_ASSERT((!is_not_equal_comparable<int*, float*>::value)); STATIC_ASSERT((is_not_equal_comparable<X*, Z*>::value)); STATIC_ASSERT((!is_not_equal_comparable<X*, Y*>::value)); diff --git a/gcc/testsuite/g++.dg/torture/pr49115.C b/gcc/testsuite/g++.dg/torture/pr49115.C new file mode 100644 index 00000000000..c4cce21ba5d --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr49115.C @@ -0,0 +1,25 @@ +// { dg-do run } + +extern "C" void abort (void); +struct MyException {}; +struct Data { + int nr; + Data() : nr(66) {} +}; +Data __attribute__((noinline,noclone)) getData(int i) +{ + if (i) throw MyException(); + Data data; + data.nr = i; + return data; +} +int main(int, char **) +{ + Data data; + try { + data = getData(1); + } catch (MyException& e) { + if (data.nr != 66) + abort (); + } +} diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr40874.C b/gcc/testsuite/g++.dg/tree-ssa/pr40874.C new file mode 100644 index 00000000000..d227ff9aaa3 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr40874.C @@ -0,0 +1,25 @@ +// { dg-do compile } +// { dg-options "-O -fdump-tree-optimized" } + +struct pf +{ + inline pf(int(*x)(int)) : x(x) {} + + inline int operator()(int a) const + { + return x(a); + } + + int (*x)(int); +}; + +inline int g(int x) { return x/x - 1; } + +int main(int argc, char* argv[]) +{ + pf f(g); + return f(3); +} + +// { dg-final { scan-tree-dump "return 0" "optimized" } } +// { dg-final { cleanup-tree-dump "optimized" } } diff --git a/gcc/testsuite/g++.dg/warn/pr18016.C b/gcc/testsuite/g++.dg/warn/pr18016.C new file mode 100644 index 00000000000..9cf1ea3b70a --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr18016.C @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -Winit-self" } */ + +class X { + int i; + X() : i(i) { } // { dg-warning "initialized with itself" } + X(int i) : i(i) { } + X(const X& x) : i(x.i) { } +}; + +// { dg-prune-output "In constructor" } diff --git a/gcc/testsuite/gcc.c-torture/compile/pr49029.c b/gcc/testsuite/gcc.c-torture/compile/pr49029.c new file mode 100644 index 00000000000..ebe81b31b28 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr49029.c @@ -0,0 +1,10 @@ +/* PR middle-end/49029 */ +struct S { volatile unsigned f : 11; signed g : 30; } __attribute__((packed)); +struct T { volatile struct S h; } __attribute__((packed)) a; +void foo (int); + +void +bar () +{ + foo (a.h.g); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr48973-1.c b/gcc/testsuite/gcc.c-torture/execute/pr48973-1.c new file mode 100644 index 00000000000..02688a0ea5f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr48973-1.c @@ -0,0 +1,20 @@ +/* PR middle-end/48973 */ + +extern void abort (void); +struct S { int f : 1; } s; +int v = -1; + +void +foo (unsigned int x) +{ + if (x != -1U) + abort (); +} + +int +main () +{ + s.f = (v & 1) > 0; + foo (s.f); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr48973-2.c b/gcc/testsuite/gcc.c-torture/execute/pr48973-2.c new file mode 100644 index 00000000000..a64d4918e4b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr48973-2.c @@ -0,0 +1,14 @@ +/* PR middle-end/48973 */ + +extern void abort (void); +struct S { int f : 1; } s; +int v = -1; + +int +main () +{ + s.f = v < 0; + if ((unsigned int) s.f != -1U) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr49123.c b/gcc/testsuite/gcc.c-torture/execute/pr49123.c new file mode 100644 index 00000000000..2f1f7935d3c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr49123.c @@ -0,0 +1,14 @@ +/* PR lto/49123 */ + +extern void abort (void); +static struct S { int f : 1; } s; +static int v = -1; + +int +main () +{ + s.f = v < 0; + if ((unsigned int) s.f != -1U) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/debug/pr49032.c b/gcc/testsuite/gcc.dg/debug/pr49032.c new file mode 100644 index 00000000000..3985040d712 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/pr49032.c @@ -0,0 +1,11 @@ +/* PR debug/49032 */ +/* { dg-do link } */ + +static int s = 42; + +int +main () +{ + int *l[18] = { &s, &s, &s, &s, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/memcpy-3.c b/gcc/testsuite/gcc.dg/memcpy-3.c new file mode 100644 index 00000000000..ba3db56c99d --- /dev/null +++ b/gcc/testsuite/gcc.dg/memcpy-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +int get_int(const void *p) +{ + int w; + __builtin_memcpy(&w, p, sizeof (int)); + return w; +} + +/* { dg-final { scan-tree-dump-not "memcpy" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "MEM" 1 "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/pr49120.c b/gcc/testsuite/gcc.dg/pr49120.c new file mode 100644 index 00000000000..1a65222cfec --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr49120.c @@ -0,0 +1,11 @@ +/* PR c/49120 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int +main () +{ + int a = 1; + int c = ({ char b[a + 1]; b[0] = 0; b[0]; }); + return c; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-11.c b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-11.c index 73051ae9645..24c9d16d9db 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-11.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-11.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ /* { dg-options "-O -fdump-tree-forwprop1" } */ int f(int *p, int n) @@ -15,5 +16,5 @@ int g(int *p, int n) return q[-1]; } -/* { dg-final { scan-tree-dump-times "= \\\(\\\*a_..\\\)\\\[1\\\];" 2 "forwprop1" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "= MEM\\\[\\\(int \\\*\\\)a_.. \\\+ 4B\\\];" 2 "forwprop1" } } */ /* { dg-final { cleanup-tree-dump "forwprop1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ivopt_infer_2.c b/gcc/testsuite/gcc.dg/tree-ssa/ivopt_infer_2.c index 4b7e197dd04..4c5a54b9af4 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ivopt_infer_2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ivopt_infer_2.c @@ -5,20 +5,20 @@ #define TYPE char* #endif -extern int a[]; +extern char a[]; /* Can not infer loop iteration from array -- exit test can not be replaced. */ -void foo (int i_width, TYPE dst, TYPE src1, TYPE src2) +void foo (unsigned int i_width, TYPE dst) { - TYPE dstn= dst + i_width; - TYPE dst0 = dst; - unsigned long long i = 0; - for( ; dst <= dstn; ) - { - dst0[i] = ( src1[i] + src2[i] + 1 +a[i]) >> 1; - dst++; - i += 16; - } + unsigned long long i = 0; + unsigned long long j = 0; + for ( ; j < i_width; ) + { + *dst = a[i]; + dst++; + i += 2; + j += 1; + } } /* { dg-final { scan-tree-dump-times "Replacing" 0 "ivopts"} } */ diff --git a/gcc/testsuite/gcc.dg/vect/O3-pr49087.c b/gcc/testsuite/gcc.dg/vect/O3-pr49087.c new file mode 100644 index 00000000000..c897fbcd0c4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/O3-pr49087.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ + +static char func2() { } + +struct S0 +{ + int t; +}; + +int g; + +struct S0 s0; + +int +foo (int arg) +{ + int *ptr = &g; + int i, j; + for (i = 0; i < 10; i += 1) + { + for (j = 0; j < 1; j += 1) + { + int k; + if (arg) + { + int l; + for (k = 1; arg < 10; arg = func2 ()) + { + return l; + } + } + *ptr = func2 () ^ s0.t; + } + } +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.target/arm/ivopts-6.c b/gcc/testsuite/gcc.target/arm/ivopts-6.c new file mode 100644 index 00000000000..8a3bafbd884 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/ivopts-6.c @@ -0,0 +1,15 @@ +/* { dg-do assemble } */ +/* { dg-options "-Os -fdump-tree-ivopts -save-temps -marm" } */ + +void +tr5 (short array[], int n) +{ + int x; + if (n > 0) + for (x = 0; x < n; x++) + array[x] = 0; +} + +/* { dg-final { scan-tree-dump-times "PHI <" 1 "ivopts"} } */ +/* { dg-final { object-size text <= 32 } } */ +/* { dg-final { cleanup-tree-dump "ivopts" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr47315.c b/gcc/testsuite/gcc.target/i386/pr47315.c new file mode 100644 index 00000000000..871d3f1bd90 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr47315.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -mvzeroupper" } */ + +__attribute__ ((__target__ ("avx"))) +float bar (float f) {} + +void foo (float f) +{ + bar (f); +} diff --git a/gcc/testsuite/gfortran.dg/function_optimize_8.f90 b/gcc/testsuite/gfortran.dg/function_optimize_8.f90 new file mode 100644 index 00000000000..c197a6d7ff5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/function_optimize_8.f90 @@ -0,0 +1,36 @@ +! { dg-do compile } +! { dg-options "-O -fdump-tree-original" } +module x + implicit none +contains + pure function myfunc(x) result(y) + integer, intent(in) :: x + integer, dimension(:), allocatable :: y + allocate (y(3)) + y(1) = x + y(2) = 2*x + y(3) = 3*x + end function myfunc + + pure function mychar(x) result(r) + integer, intent(in) :: x + character(len=2) :: r + r = achar(x + iachar('0')) // achar(x + iachar('1')) + end function mychar +end module x + +program main + use x + implicit none + integer :: n + character(len=20) :: line + n = 3 + write (unit=line,fmt='(3I2)') myfunc(n) + myfunc(n) + if (line /= ' 61218') call abort + write (unit=line,fmt='(A)') mychar(2) // mychar(2) + if (line /= '2323') call abort +end program main +! { dg-final { scan-tree-dump-times "myfunc" 2 "original" } } +! { dg-final { scan-tree-dump-times "mychar" 2 "original" } } +! { dg-final { cleanup-tree-dump "original" } } +! { dg-final { cleanup-modules "x" } } diff --git a/gcc/testsuite/gfortran.dg/select_type_23.f03 b/gcc/testsuite/gfortran.dg/select_type_23.f03 new file mode 100644 index 00000000000..d7788d2f494 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/select_type_23.f03 @@ -0,0 +1,22 @@ +! { dg-do compile } +! +! PR 48699: [OOP] MOVE_ALLOC inside SELECT TYPE +! +! Contributed by Salvatore Filippone <sfilippone@uniroma2.it> + +program testmv2 + + type bar + integer, allocatable :: ia(:), ja(:) + end type bar + + class(bar), allocatable :: sm,sm2 + + allocate(sm2) + + select type(sm2) + type is (bar) + call move_alloc(sm2,sm) + end select + +end program testmv2 diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 315a252fadc..ba76ae10ab1 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -1633,7 +1633,14 @@ stmt_kills_ref_p_1 (gimple stmt, ao_ref *ref) return false; if (gimple_has_lhs (stmt) - && TREE_CODE (gimple_get_lhs (stmt)) != SSA_NAME) + && TREE_CODE (gimple_get_lhs (stmt)) != SSA_NAME + /* The assignment is not necessarily carried out if it can throw + and we can catch it in the current function where we could inspect + the previous value. + ??? We only need to care about the RHS throwing. For aggregate + assignments or similar calls and non-call exceptions the LHS + might throw as well. */ + && !stmt_can_throw_internal (stmt)) { tree base, lhs = gimple_get_lhs (stmt); HOST_WIDE_INT size, offset, max_size; diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 6dc8a57f5c8..b13ef59af49 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -521,7 +521,14 @@ mark_aliased_reaching_defs_necessary_1 (ao_ref *ref, tree vdef, void *data) /* If the stmt lhs kills ref, then we can stop walking. */ if (gimple_has_lhs (def_stmt) - && TREE_CODE (gimple_get_lhs (def_stmt)) != SSA_NAME) + && TREE_CODE (gimple_get_lhs (def_stmt)) != SSA_NAME + /* The assignment is not necessarily carried out if it can throw + and we can catch it in the current function where we could inspect + the previous value. + ??? We only need to care about the RHS throwing. For aggregate + assignments or similar calls and non-call exceptions the LHS + might throw as well. */ + && !stmt_can_throw_internal (def_stmt)) { tree base, lhs = gimple_get_lhs (def_stmt); HOST_WIDE_INT size, offset, max_size; diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 69df4b62b77..10fd7dc48c7 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -3685,7 +3685,7 @@ force_expr_to_var_cost (tree expr, bool speed) mult = op0; if (mult != NULL_TREE - && TREE_CODE (TREE_OPERAND (mult, 1)) == INTEGER_CST + && cst_and_fits_in_hwi (TREE_OPERAND (mult, 1)) && get_shiftadd_cost (expr, mode, cost0, cost1, mult, speed, &sa_cost)) return sa_cost; diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 2ec2e0ce510..230593ad264 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -2832,6 +2832,54 @@ infer_loop_bounds_from_array (struct loop *loop, gimple stmt, bool reliable) } /* Determine information about number of iterations of a LOOP from the fact + that pointer arithmetics in STMT does not overflow. */ + +static void +infer_loop_bounds_from_pointer_arith (struct loop *loop, gimple stmt) +{ + tree def, base, step, scev, type, low, high; + tree var, ptr; + + if (!is_gimple_assign (stmt) + || gimple_assign_rhs_code (stmt) != POINTER_PLUS_EXPR) + return; + + def = gimple_assign_lhs (stmt); + if (TREE_CODE (def) != SSA_NAME) + return; + + type = TREE_TYPE (def); + if (!nowrap_type_p (type)) + return; + + ptr = gimple_assign_rhs1 (stmt); + if (!expr_invariant_in_loop_p (loop, ptr)) + return; + + var = gimple_assign_rhs2 (stmt); + if (TYPE_PRECISION (type) != TYPE_PRECISION (TREE_TYPE (var))) + return; + + scev = instantiate_parameters (loop, analyze_scalar_evolution (loop, def)); + if (chrec_contains_undetermined (scev)) + return; + + base = initial_condition_in_loop_num (scev, loop->num); + step = evolution_part_in_loop_num (scev, loop->num); + + if (!base || !step + || TREE_CODE (step) != INTEGER_CST + || tree_contains_chrecs (base, NULL) + || chrec_contains_symbols_defined_in_loop (base, loop->num)) + return; + + low = lower_bound_in_type (type, type); + high = upper_bound_in_type (type, type); + + record_nonwrapping_iv (loop, base, step, stmt, low, high, false, true); +} + +/* Determine information about number of iterations of a LOOP from the fact that signed arithmetics in STMT does not overflow. */ static void @@ -2907,7 +2955,10 @@ infer_loop_bounds_from_undefined (struct loop *loop) infer_loop_bounds_from_array (loop, stmt, reliable); if (reliable) - infer_loop_bounds_from_signedness (loop, stmt); + { + infer_loop_bounds_from_signedness (loop, stmt); + infer_loop_bounds_from_pointer_arith (loop, stmt); + } } } diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index 7ddce32a62f..c6da47b6cd9 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -358,6 +358,8 @@ convert_control_dep_chain_into_preds (VEC(edge, heap) **dep_chains, for (i = 0; i < num_chains; i++) { VEC(edge, heap) *one_cd_chain = dep_chains[i]; + + has_valid_pred = false; for (j = 0; j < VEC_length (edge, one_cd_chain); j++) { gimple cond_stmt; diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 9942ebe8151..98bb113629e 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -1704,7 +1704,7 @@ vect_is_slp_reduction (loop_vec_info loop_info, gimple phi, gimple first_stmt) tree lhs; imm_use_iterator imm_iter; use_operand_p use_p; - int nloop_uses, size = 0; + int nloop_uses, size = 0, nuses; bool found = false; if (loop != vect_loop) @@ -1715,9 +1715,11 @@ vect_is_slp_reduction (loop_vec_info loop_info, gimple phi, gimple first_stmt) while (1) { nloop_uses = 0; + nuses = 0; FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs) { use_stmt = USE_STMT (use_p); + nuses++; if (is_gimple_debug (use_stmt)) continue; @@ -1739,6 +1741,10 @@ vect_is_slp_reduction (loop_vec_info loop_info, gimple phi, gimple first_stmt) return false; } + /* We reached a statement with no uses. */ + if (nuses == 0) + return false; + if (found) break; |