Commit Graph

1475 Commits

Author SHA1 Message Date
Martin Jambor daccaeb998 Be conservative with arithmetic jmp-function types
2017-11-29  Martin Jambor  <mjambor@suse.cz>

	PR ipa/82808
	* tree.c (expr_type_first_operand_type_p): New function.
	* tree.h (expr_type_first_operand_type_p): Declare it.
	* ipa-cp.c (ipa_get_jf_pass_through_result): Use it.

testsuite/
	* gcc.dg/ipa/pr82808.c: New test.

From-SVN: r255256
2017-11-29 23:13:34 +01:00
Jason Merrill 3eb1e9c89d PR c++/82406 - C++17 error with noexcept function type
PR c++/70029 - ICE with ref-qualifier and -flto
gcc/
	* langhooks.h (struct lang_hooks_for_types): Add
	copy_lang_qualifiers.
	* langhooks-def.h (LANG_HOOKS_COPY_LANG_QUALIFIERS): Default to
	NULL.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Use it.
	* tree.c (verify_type): Re-enable TYPE_CANONICAL main variant check.
	(build_type_attribute_qual_variant): Use copy_lang_qualifiers.
gcc/cp/
	* tree.c (cxx_copy_lang_qualifiers): New.
	* cp-tree.h: Declare it.
	* cp-objcp-common.h: Define LANG_HOOKS_COPY_LANG_QUALIFIERS.

From-SVN: r253424
2017-10-04 13:47:08 -04:00
Richard Biener 9563a3d30a backport: [multiple changes]
2017-08-28  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2017-08-21  Richard Biener  <rguenther@suse.de>

	PR middle-end/81884
	* tree-ssa-alias.c (stmt_kills_ref_p): Handle array accesses
	at struct end conservatively when comparing common bases.

	* g++.dg/torture/pr81884.C: New testcase.

	2017-05-04  Richard Biener  <rguenther@suse.de>
 
	* tree.c (array_at_struct_end_p): Handle arrays at struct
	end with flexarrays more conservatively.  Refactor and treat
	arrays of arrays or aggregates more strict.  Fix
	VIEW_CONVERT_EXPR handling.  Remove allow_compref argument.
	* tree.h (array_at_struct_end_p): Adjust prototype.
	* gimple-fold.c (get_range_strlen): Likewise.
	* tree-chkp.c (chkp_may_narrow_to_field): Likewise.

From-SVN: r251379
2017-08-28 12:16:06 +00:00
Jakub Jelinek a240da2d3a re PR c++/80534 (7.1 RC - internal compiler error: in finish_member_declaration, at cp/semantics.c:2963)
PR c++/80534
	* tree.c (type_cache_hasher::equal): Only compare
	TYPE_TYPELESS_STORAGE flag on non-aggregate element types.
	(build_array_type_1): Only hash TYPE_TYPELESS_STORAGE flag on
	non-aggregate element types.
	* tree.h (TYPE_TYPELESS_STORAGE): Fix comment typo, add more details
	about the flag on ARRAY_TYPEs in the comment, formatting fix.
c-family/
	* c-common.c (complete_array_type): Only hash TYPE_TYPELESS_STORAGE
	flag on non-aggregate element types.
testsuite/
	* g++.dg/other/pr80534-1.C: New test.
	* g++.dg/other/pr80534-2.C: New test.

From-SVN: r247337
2017-04-27 15:47:54 +02:00
Jakub Jelinek 8a59d4660c re PR middle-end/80423 (GC related -fcompare-debug failure)
PR middle-end/80423
	* tree.h (build_array_type): Add typeless_storage default argument.
	* tree.c (type_cache_hasher::equal): Also compare
	TYPE_TYPELESS_STORAGE flag for ARRAY_TYPEs.
	(build_array_type): Add typeless_storage argument, set
	TYPE_TYPELESS_STORAGE to it, if shared also hash it, and pass to
	recursive call.
	(build_nonshared_array_type): Adjust build_array_type_1 caller.
	(build_array_type): Likewise.  Add typeless_storage argument.
c-family/
	* c-common.c (complete_array_type): Preserve TYPE_TYPELESS_STORAGE.
cp/
	* tree.c (build_cplus_array_type): Call build_array_type
	with the intended TYPE_TYPELESS_STORAGE flag value, instead
	of calling build_array_type and modifying later TYPE_TYPELESS_STORAGE
	on the shared type.
testsuite/
	* g++.dg/other/pr80423.C: New test.

From-SVN: r247014
2017-04-20 11:18:02 +02:00
Richard Biener 2d143ba8cf re PR middle-end/80341 (gcc miscompiles division of signed char)
2017-04-07  Richard Biener  <rguenther@suse.de>

	PR middle-end/80341
	* tree.c (get_unwidened): Also handle ! for_type case for
	INTEGER_CSTs.
	* convert.c (do_narrow): Split out from ...
	(convert_to_integer_1): ... here.  Do not pass final truncation
	type to get_unwidened for TRUNC_DIV_EXPR.

	* gcc.dg/torture/pr80341.c: New testcase.

From-SVN: r246756
2017-04-07 08:20:24 +00:00
Markus Trippelsdorf a292245ee8 Avoid name lookup warning
/home/markus/gcc/gcc/tree.c: In function ‘void inchash::add_expr(const_tree, inchash::hash&, unsigned int)’:
/home/markus/gcc/gcc/tree.c:8013:11: warning: name lookup of ‘i’ changed
      for (i = TREE_OPERAND_LENGTH (t) - 1; i >= 0; --i)
           ^
/home/markus/gcc/gcc/tree.c:7773:7: warning:   matches this ‘i’ under ISO standard rules
   int i;
       ^
/home/markus/gcc/gcc/tree.c:7869:16: warning:   matches this ‘i’ under old rules
       for (int i = 0; i < TREE_VEC_LENGTH (t); ++i)
                ^

From-SVN: r246519
2017-03-28 05:47:13 +00:00
Marek Polacek 410a590c2a re PR c++/79672 (ICE with -Wduplicated-branches -fopenmp)
PR c++/79672
	* tree.c (inchash::add_expr): Handle TREE_VEC.

	* g++.dg/warn/Wduplicated-branches2.C: Fix PR.
	* g++.dg/warn/Wduplicated-branches3.C: New test.

From-SVN: r245996
2017-03-09 09:53:03 +00:00
Jakub Jelinek b607e75e25 re PR middle-end/79665 (gcc's signed (x*x)/200 is slower than clang's)
PR middle-end/79665
	* internal-fn.c (get_range_pos_neg): Moved to ...
	* tree.c (get_range_pos_neg): ... here.  No longer static.
	* tree.h (get_range_pos_neg): New prototype.
	* expr.c (expand_expr_real_2) <case TRUNC_DIV_EXPR>: If both arguments
	are known to be in between 0 and signed maximum inclusive, try to
	expand both unsigned and signed divmod and use the cheaper one from
	those.

From-SVN: r245676
2017-02-23 08:49:06 +01:00
Chung-Lin Tang 02889d23ee gimplify.c (gimplify_scan_omp_clauses): No special handling for OMP_CLAUSE_TILE.
2017-02-09  Nathan Sidwell  <nathan@codesourcery.com>
	    Cesar Philippidis  <cesar@codesourcery.com>
	    Joseph Myers  <joseph@codesourcery.com>
	    Chung-Lin Tang  <cltang@codesourcery.com>

	gcc/
	* gimplify.c (gimplify_scan_omp_clauses): No special handling for
	OMP_CLAUSE_TILE.
	(gimplify_adjust_omp_clauses): Don't delete TILE.
	(gimplify_omp_for): Deal with TILE.
	* internal-fn.c (expand_GOACC_TILE): New function.
	* internal-fn.def (GOACC_DIM_POS): Comment may be overly conservative.
	(GOACC_TILE): New.
	* omp-expand.c (struct oacc_collapse): Add tile and outer fields.
	(expand_oacc_collapse_init): Add LOC paramter.  Initialize tile
	element fields.
	(expand_oacc_collapse_vars): Add INNER parm, adjust for tiling,
	avoid DIV for outermost collapse var.
	(expand_oacc_for): Insert tile element loop as needed.  Adjust.
	Remove out of date comments, fix whitespace.
	* omp-general.c (omp_extract_for_data): Deal with tiling.
	* omp-general.h (enum oacc_loop_flags): Add OLF_TILE flag,
	adjust OLF_DIM_BASE value.
	(struct omp_for_data): Add tiling field.
	* omp-low.c (scan_sharing_clauses): Allow OMP_CLAUSE_TILE.
	(lower_oacc_head_mark): Add OLF_TILE as appropriate.  Ensure 2 levels
	for auto loops.  Remove default auto determining, moved to
	oacc_loop_fixed_partitions.
	* omp-offload.c (struct oacc_loop): Change 'ifns' to vector of call
	stmts, add e_mask field.
	(oacc_dim_call): New function, abstracted out from oacc_thread_numbers.
	(oacc_thread_numbers): Use oacc_dim_call.
	(oacc_xform_tile): New.
	(new_oacc_loop_raw): Initialize e_mask, adjust for ifns vector.
	(finish_oacc_loop): Adjust for ifns vector.
	(oacc_loop_discover_walk): Append loop abstraction sites to list,
	add case for GOACC_TILE fns.
	(oacc_loop_xform_loop): Delete.
	(oacc_loop_process): Iterate over call list directly, and add
	handling for GOACC_TILE fns.
	(oacc_loop_fixed_partitions): Determine default auto, deal with TILE,
	dump partitioning.
	(oacc_loop_auto_partitions): Add outer_assign parm. Assign all but
	vector partitioning to outer loops.  Assign 2 partitions to loops
	when available. Add TILE handling.
	(oacc_loop_partition): Adjust oacc_loop_auto_partitions call.
	(execite_oacc_device_lower): Process GOACC_TILE fns, ignore unknown specs.
	* tree-nested.c (convert_nonlocal_omp_clauses): Allow OMP_CLAUSE_TILE.
	* tree.c (omp_clause_num_ops): Adjust TILE ops.
	* tree.h (OMP_CLAUSE_TILE_ITERVAR, OMP_CLAUSE_TILE_COUNT): New.

	gcc/c/
	* c-parser.c (c_parser_omp_clause_collapse): Disallow tile.
	(c_parser_oacc_clause_tile): Disallow collapse. Fix parsing and
	semantic checking.
	* c-parser.c (c_parser_omp_for_loop): Accept tiling constructs.

	gcc/cp/
	* parser.c (cp_parser_oacc_clause_tile): Disallow collapse.  Fix
	parsing.  Parse constant expression. Remove semantic checking.
	(cp_parser_omp_clause_collapse): Disallow tile.
	(cp_parser_omp_for_loop): Deal with tile clause.  Don't emit a parse
	error about missing for after already emitting one.  Use more
	conventional for idiom for unbounded loop.
	* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_TILE.
	* semantics.c (finish_omp_clauses): Correct TILE semantic check.
	(finish_omp_for): Deal with tile clause.

	gcc/fortran/
	* openmp.c (resolve_omp_clauses): Error on directives
	containing both tile and collapse clauses.
	(resolve_oacc_loop_blocks): Represent '*' tile arguments as zero.
	* trans-openmp.c (gfc_trans_omp_do): Lower tiled loops like
	collapsed loops.

	gcc/testsuite/
	* c-c++-common/goacc/combined-directives.c: Remove xfail.
	* c-c++-common/goacc/loop-auto-1.c: Adjust and add additional case.
	* c-c++-common/goacc/loop-auto-2.c: New.
	* c-c++-common/goacc/tile.c: Include stdbool, fix expected errors.
	* c-c++-common/goacc/tile-2.c: New.
	* g++.dg/goacc/template.C: Test tile subst.  Adjust erroneous uses.
	* g++.dg/goacc/tile-1.C: New, check tile subst.
	* gcc.dg/goacc/loop-processing-1.c: Adjust dg-final pattern.
	* gfortran.dg/goacc/combined-directives.f90: Remove xfail.
	* gfortran.dg/goacc/tile-1.f90: New test.
	* gfortran.dg/goacc/tile-2.f90: New test.
	* gfortran.dg/goacc/tile-lowering.f95: New test.

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/tile-1.c: New.
	* testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c: Adjust and
	add additional case.
	* testsuite/libgomp.oacc-c-c++-common/vprop.c: XFAIL under
	"openacc_nvidia_accel_selected".
	* libgomp.oacc-fortran/nested-function-1.f90 (test2):
	Add num_workers(8) clause.

From-SVN: r245300
2017-02-09 13:46:20 +00:00
Martin Sebor 3f3430400b PR tree-optimization/79352 - -fprintf-return-value doesn't handle flexible-like array members properly
gcc/ChangeLog:

	PR tree-optimization/79352
	* gimple-fold.c (get_range_strlen): Add argument.
	(get_range_strlen): Change return type to bool.
	(get_maxval_strlen): Pass in a dummy argument.
	* gimple-fold.h (get_range_strlen): Change return type to bool.
	* gimple-ssa-sprintf.c (get_string_length): Set unlikely counter.
	* tree.h (array_at_struct_end_p): Add argument.
	* tree.c (array_at_struct_end_p): Handle it.

gcc/testsuite/ChangeLog:

	PR tree-optimization/79352
	* gcc.dg/tree-ssa/pr79352.c: New test.

From-SVN: r245156
2017-02-03 09:38:15 -07:00
Richard Biener fcc216ec44 re PR tree-optimization/79256 (FAIL: gcc.dg/vect/pr25413a.c execution test)
2017-01-30  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/79256
	* targhooks.c (default_builtin_vector_alignment_reachable): Honor
	BIGGEST_FIELD_ALIGNMENT and ADJUST_FIELD_ALIGN to fix up bogus
	alignment on TYPE.
	* tree.c (build_aligned_type): Set TYPE_USER_ALIGN.

From-SVN: r245025
2017-01-30 13:52:44 +00:00
Jakub Jelinek 9579db3583 tree.h (assign_assembler_name_if_neeeded): Rename to ...
* tree.h (assign_assembler_name_if_neeeded): Rename to ...
	(assign_assembler_name_if_needed): ... this.
	* tree.c (assign_assembler_name_if_neeeded): Rename to ...
	(assign_assembler_name_if_needed): ... this.
	(free_lang_data_in_cgraph): Adjust callers.
	* cgraphunit.c (cgraph_node::analyze): Likewise.
	* omp-expand.c (expand_omp_taskreg, expand_omp_target):
	Likewise.

From-SVN: r244839
2017-01-23 23:58:12 +01:00
Maxim Ostapenko e3d53f96ed re PR lto/79061 ([LTO][ASAN] LTO plus ASAN fails with "AddressSanitizer: initialization-order-fiasco")
Revert fix for PR lto/79061 due to this regresses compile-time by 100%
on some fortran cases.

From-SVN: r244773
2017-01-23 11:12:29 +02:00
Marek Polacek 2ebd93e1d7 re PR c/64279 (Warning missing for "(cond) ? A : A" / if(cond) expr1; else expr1; // same expression in if and else branch)
PR c/64279
	* c-common.h (do_warn_duplicated_branches_r): Declare.
	* c-gimplify.c (c_genericize): Walk the function tree calling
	do_warn_duplicated_branches_r.
	* c-warn.c (expr_from_macro_expansion_r): New.
	(do_warn_duplicated_branches): New.
	(do_warn_duplicated_branches_r): New.
	* c.opt (Wduplicated-branches): New option.

	* c-typeck.c (build_conditional_expr): Warn about duplicated branches.

	* call.c (build_conditional_expr_1): Warn about duplicated branches.
	* semantics.c (finish_expr_stmt): Build statement using the proper
	location.

	* doc/invoke.texi: Document -Wduplicated-branches.
	* fold-const.c (operand_equal_p): Handle MODIFY_EXPR, INIT_EXPR,
	COMPOUND_EXPR, PREDECREMENT_EXPR, PREINCREMENT_EXPR,
	POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, CLEANUP_POINT_EXPR, EXPR_STMT,
	STATEMENT_LIST, and RETURN_EXPR.  For non-pure non-const functions
	return 0 only when not OEP_LEXICOGRAPHIC.
	(fold_build_cleanup_point_expr): Use the expression
	location when building CLEANUP_POINT_EXPR.
	* tree-core.h (enum operand_equal_flag): Add OEP_LEXICOGRAPHIC.
	* tree.c (add_expr): Handle error_mark_node.

	* c-c++-common/Wduplicated-branches-1.c: New test.
	* c-c++-common/Wduplicated-branches-10.c: New test.
	* c-c++-common/Wduplicated-branches-11.c: New test.
	* c-c++-common/Wduplicated-branches-12.c: New test.
	* c-c++-common/Wduplicated-branches-2.c: New test.
	* c-c++-common/Wduplicated-branches-3.c: New test.
	* c-c++-common/Wduplicated-branches-4.c: New test.
	* c-c++-common/Wduplicated-branches-5.c: New test.
	* c-c++-common/Wduplicated-branches-6.c: New test.
	* c-c++-common/Wduplicated-branches-7.c: New test.
	* c-c++-common/Wduplicated-branches-8.c: New test.
	* c-c++-common/Wduplicated-branches-9.c: New test.
	* c-c++-common/Wimplicit-fallthrough-7.c: Coalesce dg-warning.
	* g++.dg/cpp0x/lambda/lambda-switch.C: Move dg-warning.
	* g++.dg/ext/builtin-object-size3.C: Likewise.
	* g++.dg/gomp/loop-1.C: Likewise.
	* g++.dg/warn/Wduplicated-branches1.C: New test.
	* g++.dg/warn/Wduplicated-branches2.C: New test.

From-SVN: r244705
2017-01-20 12:02:50 +00:00
Maxim Ostapenko 5807fb918d re PR lto/79061 ([LTO][ASAN] LTO plus ASAN fails with "AddressSanitizer: initialization-order-fiasco")
PR lto/79061
gcc/

	* asan.c (get_translation_unit_decl): New function.
	(asan_add_global): Extract modules file name from globals
	TRANSLATION_UNIT_DECL in lto mode.
	* tree.c (build_translation_unit_decl): Add source location for newly
	built TRANSLATION_UNIT_DECL.

gcc/lto/

	* lto.c (lto_read_decls): accept location cache for
	TRANSLATION_UNIT_DECL.
	
gcc/testsuite/

	* gcc.dg/cpp/mi1.c: Adjust testcase.
	* gcc.dg/pch/cpp-3.c: Likewise.

From-SVN: r244581
2017-01-18 18:06:31 +02:00
Richard Biener ef9d56f8ac tree.c (initialize_tree_contains_struct): Make TS_OPTIMIZATION and TS_TARGET_OPTION directly derive from TS_BASE.
2017-01-12  Richard Biener  <rguenther@suse.de>

	* tree.c (initialize_tree_contains_struct): Make TS_OPTIMIZATION
	and TS_TARGET_OPTION directly derive from TS_BASE.
	* tree-core.h (tree_optimization_option): Derive from tree_base.
	(tree_target_option): Likewise.

From-SVN: r244349
2017-01-12 08:13:43 +00:00
Jakub Jelinek bd2c62704b re PR translation/79019 (translatable string typo in cif-code.def:141)
PR translation/79019
	PR translation/79020
	* params.def (PARAM_INLINE_MIN_SPEEDUP,
	PARAM_IPA_CP_SINGLE_CALL_PENALTY,
	PARAM_USE_AFTER_SCOPE_DIRECT_EMISSION_THRESHOLD): Fix typos
	in descriptions.
	* config/avr/avr.opt (maccumulate-args): Likewise.
	* config/msp430/msp430.opt (mwarn-mcu): Likewise.
	* common.opt (freport-bug): Likewise.
	* cif-code.def (CIF_FINAL_ERROR): Likewise.
	* doc/invoke.texi (ipa-cp-single-call-penalty): Likewise.
	* config/s390/s390.c (s390_invalid_binary_op): Fix spelling in
	translatable string.
	* config/i386/i386.c (function_value_32): Likewise.
	* config/nios2/nios2.c (nios2_valid_target_attribute_rec): Likewise.
	* config/msp430/msp430.c (msp430_option_override, msp430_attr):
	Likewise.
	* config/msp430/driver-msp430.c (msp430_select_hwmult_lib): Likewise.
	* common/config/msp430/msp430-common.c (msp430_handle_option):
	Likewise.
	* symtab.c (symtab_node::verify_base): Likewise.
	* opts.c (set_debug_level): Likewise.
	* tree.c (verify_type_variant): Likewise.  Fix typo in comment.
	* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Add
	missing whitespace to translatable strings.
	* config/avr/avr.md (bswapsi2): Fix typo in comment.
	* config/sh/superh.h: Likewise.
	* config/i386/xopintrin.h: Likewise.
	* config/i386/znver1.md: Likewise.
	* config/rs6000/rs6000.c (struct rs6000_opt_mask): Likewise.
	* ipa-inline-analysis.c (compute_inline_parameters): Likewise.
	* double-int.h (struct double_int): Likewise.
	* double-int.c (div_and_round_double): Likewise.
	* wide-int.cc: Likewise.
	* tree-ssa.c (non_rewritable_mem_ref_base): Likewise.
	* tree-ssa-sccvn.c (vn_reference_lookup_3): Likewise.
	* cfgcleanup.c (crossjumps_occured): Renamed to ...
	(crossjumps_occurred): ... this.
	(try_crossjump_bb, try_head_merge_bb, try_optimize_cfg, cleanup_cfg):
	Adjust all uses.
cp/
	* semantics.c (finish_omp_clauses): Add missing whitespace to
	translatable strings.
	* cp-cilkplus.c (cpp_validate_cilk_plus_loop_aux): Fix comment typo.
lto/
	* lto-symtab.c (lto_symtab_merge_symbols): Fix comment typo.
fortran/
	* decl.c (attr_decl1): Fix spelling in translatable string.
	* intrinsic.texi: Fix spelling - invokation -> invocation.
	* lang.opt (faggressive-function-elimination, gfc_convert): Fix
	typos in descriptions.
	* openmp.c (resolve_omp_clauses): Add missing whitespace to
	translatable strings.
c-family/
	* c.opt (Wnormalized=): Fix typo in description.
testsuite/
	* c-c++-common/goacc/host_data-2.c (f): Adjust expected spelling of
	diagnostics.
	* gfortran.dg/initialization_17.f90: Likewise.

From-SVN: r244245
2017-01-09 22:48:33 +01:00
Martin Sebor efcc8d387f PR tree-optimization/78913 - Probably misleading error reported by -Wformat-length
PR tree-optimization/78913 - Probably misleading error reported by -Wformat-length
PR middle-end/77708 - -Wformat-length %s warns for snprintf

gcc/ChangeLog:

	PR middle-end/77708
	* doc/invoke.texi (Warning Options): Document -Wformat-truncation.
	* gimple-ssa-sprintf.c (call_info::reval_used, call_info::warnopt):
	New member functions.
	(format_directive): Used them.
	(add_bytes): Same.
	(pass_sprintf_length::handle_gimple_call): Same.
	* graphite-sese-to-poly.c (tree_int_to_gmp): Increase buffer size
	to avoid truncation for any argument.
	(extract_affine_mul): Same.
	* tree.c (get_file_function_name): Same.

gcc/c-family/ChangeLog:

	PR middle-end/77708
	* c.opt (-Wformat-truncation): New option.

gcc/fortran/ChangeLog:

	PR tree-optimization/78913
	PR middle-end/77708
	* trans-common.c (build_equiv_decl): Increase buffer size to avoid
	truncation for any argument.
	* trans-types.c (gfc_build_logical_type): Same.

gcc/testsuite/ChangeLog:

	PR middle-end/77708
	* gcc.dg/tree-ssa/builtin-snprintf-warn-1.c: New test.
	* gcc.dg/tree-ssa/builtin-snprintf-warn-2.c: New test.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-6.c: XFAIL test cases failing
	due to bug 78969.
	* gcc.dg/format/pr78569.c: Adjust.

From-SVN: r244210
2017-01-08 16:42:09 -07:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Jakub Jelinek 0dba79602a re PR bootstrap/78817 (stage2 bootstrap failure in vec.h:1613:5: error: argument 1 null where non-null expected after r243661)
PR bootstrap/78817
	* tree-pass.h (make_pass_post_ipa_warn): Declare.
	* builtins.c (validate_arglist): Adjust get_nonnull_args call.
	Check for NULL pointer argument to nonnull arg here.
	(validate_arg): Revert 2016-12-14 changes.
	* calls.h (get_nonnull_args): Remove declaration.
	* tree-ssa-ccp.c: Include diagnostic-core.h.
	(pass_data_post_ipa_warn): New variable.
	(pass_post_ipa_warn): New class.
	(pass_post_ipa_warn::execute): New method.
	(make_pass_post_ipa_warn): New function.
	* tree.h (get_nonnull_args): Declare.
	* tree.c (get_nonnull_args): New function.
	* calls.c (maybe_warn_null_arg): Removed.
	(maybe_warn_null_arg): Removed.
	(initialize_argument_information): Revert 2016-12-14 changes.
	* passes.def: Add pass_post_ipa_warn after first ccp after IPA.
c-family/
	* c-common.c (struct nonnull_arg_ctx): New type.
	(check_function_nonnull): Return bool instead of void.  Use
	nonnull_arg_ctx as context rather than just location_t.
	(check_nonnull_arg): Adjust for the new context type, set
	warned_p to true if a warning has been diagnosed.
	(check_function_arguments): Return bool instead of void.
	* c-common.h (check_function_arguments): Adjust prototype.
c/
	* c-typeck.c (build_function_call_vec): If check_function_arguments
	returns true, set TREE_NO_WARNING on CALL_EXPR.
cp/
	* typeck.c (cp_build_function_call_vec): If check_function_arguments
	returns true, set TREE_NO_WARNING on CALL_EXPR.
	* call.c (build_over_call): Likewise.

From-SVN: r243874
2016-12-21 23:15:59 +01:00
Richard Biener 6182121c12 re PR tree-optimization/78742 (internal compiler error: in int_cst_value, at tree.c:10782)
2016-12-13  Richard Biener  <rguenther@suse.de>

	PR middle-end/78742
	* tree.c (cst_and_fits_in_hwi): Look if the actual value fits.
	* tree-object-size.c (compute_builtin_object_size): Use
	tree_fits_shwi_p.
	* tree-data-ref.c (initialize_matrix_A): Remove excess assert.

	* gcc.dg/torture/pr78742.c: New testcase.

From-SVN: r243598
2016-12-13 09:17:42 +00:00
Prathamesh Kulkarni 7fa6a96535 tree.c (build_common_tree_nodes): Initialize ptrdiff_type_node.
2016-11-26  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	* tree.c (build_common_tree_nodes): Initialize ptrdiff_type_node.
	(free_lang_data): Remove assignment to ptrdiff_type_node.
c-family/
	* c-common.c (c_common_nodes_and_builtins): Remove initialization of
	ptrdiff_type_node.
lto/
	* lto-lang.c (lto_init): Remove initialization of ptrdiff_type_node.

From-SVN: r242888
2016-11-26 10:41:55 +00:00
Richard Sandiford 664e69688d Set mode of decimal floats before calling layout_type
Previously decimal floating-point types were created and laid
out as binary floating-point types, then the caller changed
the mode to a decimal mode later.  The problem with that
approach is that not all targets support an equivalent binary
floating-point mode.  When they didn't, we would give the
type BLKmode and lay it out as a zero-sized type.

This probably had no effect in practice.  If a target doesn't
support a binary mode then it's unlikely to support the decimal
equivalent either.  However, with the stricter mode checking
added by later patches, we would assert if a scalar floating-
point type didn't have a scalar floating-point mode.

gcc/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

	* stor-layout.c (layout_type): Allow the caller to set the mode of
	a float type.  Only choose one here if the mode is still VOIDmode.
	* tree.c (build_common_tree_nodes): Set the type mode of decimal
	floats before calling layout_type.
	* config/rs6000/rs6000.c (rs6000_init_builtins): Likewise.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r242862
2016-11-25 08:20:40 +00:00
Eric Botcazou 3b08cde8dd re PR middle-end/78429 (ICE in set_value_range, at tree-vrp.c on non-standard boolean)
PR middle-end/78429
	* tree.h (wi::fits_to_boolean_p): New predicate.
	(wi::fits_to_tree_p): Use it for boolean types.
	* tree.c (int_fits_type_p): Likewise.

From-SVN: r242829
2016-11-24 12:02:53 +00:00
James Greenhalgh 56d8ffc170 [Patch 6/17] Migrate excess precision logic to use TARGET_EXCESS_PRECISION
gcc/

	* toplev.c (init_excess_precision): Delete most logic.
	* tree.c (excess_precision_type): Rewrite to use
	TARGET_EXCESS_PRECISION.
	* doc/invoke.texi (-fexcess-precision): Document behaviour in a
	more generic fashion.
	* ginclude/float.h: Wrap definition of FLT_EVAL_METHOD in
	__STDC_WANT_IEC_60559_TYPES_EXT__.

gcc/c-family/

	* c-common.c (excess_precision_mode_join): New.
	(c_ts18661_flt_eval_method): New.
	(c_c11_flt_eval_method): Likewise.
	(c_flt_eval_method): Likewise.
	* c-common.h (excess_precision_mode_join): New.
	(c_flt_eval_method): Likewise.
	* c-cppbuiltin.c (c_cpp_flt_eval_method_iec_559): New.
	(cpp_iec_559_value): Call it.
	(c_cpp_builtins): Modify logic for __LIBGCC_*_EXCESS_PRECISION__,
	call c_flt_eval_method to set __FLT_EVAL_METHOD__ and
	__FLT_EVAL_METHOD_TS_18661_3__.

gcc/testsuite/

	* gcc.dg/fpermitted-flt-eval-methods_3.c: New.
	* gcc.dg/fpermitted-flt-eval-methods_4.c: Likewise.

From-SVN: r242776
2016-11-23 17:23:12 +00:00
Richard Biener efb7123241 re PR lto/78472 (warning: type of 's' does not match original declaration from zero length bitfield in C vs C++)
2016-11-23  Richard Biener  <rguenther@suse.de>

	PR lto/78472
	* tree.c (gimple_canonical_types_compatible_p): Ignore zero-sized
	fields.

	lto/
	* lto.c (hash_canonical_type): Ignore zero-sized fields.

	* g++.dg/lto/pr78472_0.c: New testcase.
	* g++.dg/lto/pr78472_1.C: Likewise.

From-SVN: r242746
2016-11-23 11:24:55 +00:00
Jakub Jelinek 6c7509bc07 OpenMP loop cloning for SIMT execution
2016-11-22  Jakub Jelinek  <jakub@redhat.com>
            Alexander Monakov  <amonakov@ispras.ru>

	* internal-fn.c (expand_GOMP_USE_SIMT): New function.
	* tree.c (omp_clause_num_ops): OMP_CLAUSE__SIMT_ has 0 operands.
	(omp_clause_code_name): Add _simt_ name.
	(walk_tree_1): Handle OMP_CLAUSE__SIMT_.
	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE__SIMT_.
	* omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE__SIMT_.
	(scan_omp_simd): New function.
	(scan_omp_1_stmt): Use it in target regions if needed.
	(omp_max_vf): Don't max with omp_max_simt_vf.
	(lower_rec_simd_input_clauses): Use omp_max_simt_vf if
	OMP_CLAUSE__SIMT_ is present.
	(lower_rec_input_clauses): Compute maybe_simt from presence of
	OMP_CLAUSE__SIMT_.
	(lower_lastprivate_clauses): Likewise.
	(expand_omp_simd): Likewise.
	(execute_omp_device_lower): Lower IFN_GOMP_USE_SIMT.
	* internal-fn.def (GOMP_USE_SIMT): New internal function.
	* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE__SIMT_.

Co-Authored-By: Alexander Monakov <amonakov@ispras.ru>

From-SVN: r242714
2016-11-22 20:56:43 +03:00
Bernd Edlinger 48330c9355 re PR c++/71973 (c++ handles built-in functions inconsistently)
gcc:
2016-11-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR c++/71973
	* doc/invoke.texi (-Wno-builtin-declaration-mismatch): Document the
	new default-enabled warning..
	* builtin-types.def (BT_CONST_TM_PTR): New primitive type.
	(BT_PTR_CONST_STRING): Updated.
	(BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_PTR): Removed.
	(BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_TM_PTR): New function type.
	* builtins.def (DEF_TM_BUILTIN): Disable BOTH_P for TM builtins.
	(strftime): Update builtin function.
	* tree-core.h (TI_CONST_TM_PTR_TYPE): New enum value.
	* tree.h (const_tm_ptr_type_node): New type node.
	* tree.c (free_lang_data, build_common_tree_nodes): Initialize
	const_tm_ptr_type_node.

c-family:
2016-11-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR c++/71973
	* c.opt (-Wbuiltin-declaration-mismatch): New warning.
	* c-common.c (c_common_nodes_and_builtins): Initialize
	const_tm_ptr_type_node.

c:
2016-11-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR c++/71973
	* c-decl.c (diagnose_mismatched_decls): Use
	OPT_Wbuiltin_declaration_mismatch here too.

cp:
2016-11-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR c++/71973
	* decl.c (duplicate_decls): Warn when a built-in function is redefined.
	Don't overload builtin functions with C++ functions.
	Handle const_tm_ptr_type_node like file_ptr_node.
	Copy the TREE_NOTHROW flag unmodified to the old decl.

lto:
2016-11-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR c++/71973
	* lto-lang.c (lto_init): Assert const_tm_ptr_type_node is sane.

testsuite:
2016-11-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR c++/71973
	* g++.dg/pr71973-1.C: New test.
	* g++.dg/pr71973-2.C: New test.
	* g++.dg/pr71973-3.C: New test.
	* g++.dg/lto/pr68811_0.C: Add -w to first lto-options.
	* g++.dg/lookup/extern-c-redecl4.C: Adjust test expectations.
	* g++.old-deja/g++.mike/p700.C: Add -Wno-builtin-declaration-mismatch
	to dg-options.
	* g++.old-deja/g++.other/realloc.C: Likewise.
	* g++.old-deja/g++.other/builtins10.C: Adjust test expectations.

From-SVN: r242662
2016-11-21 14:17:05 +00:00
Richard Sandiford 899ca90e6d Add SET_DECL_MODE
This may no longer be necessary with the current version
of the SVE patches, but it does at least make things consistent
with the TYPE_MODE/SET_TYPE_MODE split.

gcc/ada/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
 	    Alan Hayward  <alan.hayward@arm.com>
 	    David Sherwood  <david.sherwood@arm.com>

	* gcc-interface/utils.c (create_label_decl): Use SET_DECL_MODE.

gcc/c/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
 	    Alan Hayward  <alan.hayward@arm.com>
 	    David Sherwood  <david.sherwood@arm.com>

	* c-decl.c (merge_decls): Use SET_DECL_MODE.
	(make_label, finish_struct): Likewise.

gcc/cp/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
 	    Alan Hayward  <alan.hayward@arm.com>
 	    David Sherwood  <david.sherwood@arm.com>

	* class.c (finish_struct_bits): Use SET_DECL_MODE.
	(build_base_field_1, layout_class_type, finish_struct_1): Likewise.
	* decl.c (make_label_decl): Likewise.
	* pt.c (tsubst_decl): Likewise.

gcc/fortran/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
 	    Alan Hayward  <alan.hayward@arm.com>
 	    David Sherwood  <david.sherwood@arm.com>

	* trans-common.c (build_common_decl): Use SET_DECL_MODE.
	* trans-decl.c (gfc_build_label_decl): Likewise.
	* trans-types.c (gfc_get_array_descr_info): Likewise.

gcc/lto/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
 	    Alan Hayward  <alan.hayward@arm.com>
 	    David Sherwood  <david.sherwood@arm.com>

	* lto.c (offload_handle_link_vars): Use SET_DECL_MODE.

gcc/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
 	    Alan Hayward  <alan.hayward@arm.com>
 	    David Sherwood  <david.sherwood@arm.com>

	* tree.h (SET_DECL_MODE): New macro.
	* cfgexpand.c (avoid_deep_ter_for_debug): Use SET_DECL_MODE.
	(expand_gimple_basic_block): Likewise.
	* function.c (split_complex_args): Likeise.
	* ipa-prop.c (ipa_modify_call_arguments): Likewise.
	* omp-simd-clone.c (ipa_simd_modify_stmt_ops): Likewise.
	* stor-layout.c (layout_decl, relayout_decl): Likewise.
	(finish_bitfield_representative): Likewise.
	* tree.c (make_node_stat): Likewise.
	* tree-inline.c (remap_ssa_name): Likewise.
	(tree_function_versioning): Likewise.
	* tree-into-ssa.c (rewrite_debug_stmt_uses): Likewise.
	* tree-sra.c (sra_ipa_reset_debug_stmts): Likewise.
	* tree-ssa-ccp.c (optimize_atomic_bit_test_and): Likewise.
	* tree-ssa-loop-ivopts.c (remove_unused_ivs): Likewise.
	* tree-ssa.c (insert_debug_temp_for_var_def): Likewise.
	* tree-streamer-in.c (unpack_ts_decl_common_value_fields): Likewise.
	* varasm.c (make_debug_expr_from_rtl): Likewise.

libcc1/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
 	    Alan Hayward  <alan.hayward@arm.com>
 	    David Sherwood  <david.sherwood@arm.com>

	* plugin.cc (plugin_build_add_field): Use SET_DECL_MODE.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r242585
2016-11-18 10:03:12 +00:00
Martin Jambor f73fbf900d Remove a TODO from verify_type_variant
2016-11-07  Martin Jambor  <mjambor@suse.cz>

	* tree.c (verify_type_variant): Use pointer comparison to check that
	TYPE_SIZE_UNIT match.

From-SVN: r241918
2016-11-07 19:30:26 +01:00
Jason Merrill 1906d6b4dc Use type_hash_eq langhook in check_qualified_type.
gcc/
	* tree.c (check_lang_type): New.
	(check_qualified_type): Use it.
	(check_aligned_type): Use it.
	* tree.h: Declare it.
gcc/cp/
	* tree.c (cp_check_qualified_type): Call check_base_type instead
	of check_qualified_type.
	(cxx_type_hash_eq): Check ref-qualifiers.
	* typeck.c (apply_memfn_quals): No need to mess with TYPE_CANONICAL.

From-SVN: r241831
2016-11-03 15:52:58 -04:00
Eric Botcazou 90e261e494 tree.h (wi::fits_to_tree_p): Accept only 0 and 1 for boolean types.
* tree.h (wi::fits_to_tree_p): Accept only 0 and 1 for boolean types.
	* tree.c (int_fits_type_p): Likewise.  Adjust head comment.

From-SVN: r241529
2016-10-25 17:11:49 +00:00
Eric Botcazou 4c640e2606 re PR ada/37139 (DEP prevents using Ada tasking)
PR ada/37139
	PR ada/67205
	* common.opt (-ftrampolines): New option.
	* doc/invoke.texi (Code Gen Options): Document it.
	* doc/tm.texi.in (Trampolines): Add TARGET_CUSTOM_FUNCTION_DESCRIPTORS.
	* doc/tm.texi: Regenerate.
	* builtins.def: Add init_descriptor and adjust_descriptor.
	* builtins.c (expand_builtin_init_trampoline): Do not issue a warning
	on platforms with descriptors.
	(expand_builtin_init_descriptor): New function.
	(expand_builtin_adjust_descriptor): Likewise.
	(expand_builtin) <BUILT_IN_INIT_DESCRIPTOR>: New case.
	<BUILT_IN_ADJUST_DESCRIPTOR>: Likewise.
	* calls.c (prepare_call_address): Remove SIBCALLP parameter and add
	FLAGS parameter.  Deal with indirect calls by descriptor and adjust.
	Set STATIC_CHAIN_REG_P on the static chain register, if any.
	(call_expr_flags): Set ECF_BY_DESCRIPTOR for calls by descriptor.
	(expand_call): Likewise.  Move around call to prepare_call_address
	and pass all flags to it.
	* cfgexpand.c (expand_call_stmt): Reinstate CALL_EXPR_BY_DESCRIPTOR.
	* gimple.h (enum gf_mask): New GF_CALL_BY_DESCRIPTOR value.
	(gimple_call_set_by_descriptor): New setter.
	(gimple_call_by_descriptor_p): New getter.
	* gimple.c (gimple_build_call_from_tree): SetCALL_EXPR_BY_DESCRIPTOR.
	(gimple_call_flags): Deal with GF_CALL_BY_DESCRIPTOR.
	* langhooks.h (struct lang_hooks): Add custom_function_descriptors.
	* langhooks-def.h (LANG_HOOKS_CUSTOM_FUNCTION_DESCRIPTORS): Define.
	(LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_CUSTOM_FUNCTION_DESCRIPTORS.
	* rtl.h (STATIC_CHAIN_REG_P): New macro.
	* rtlanal.c (find_first_parameter_load): Skip static chain registers.
	* target.def (custom_function_descriptors): New POD hook.
	* tree.h (FUNC_ADDR_BY_DESCRIPTOR): New flag on ADDR_EXPR.
	(CALL_EXPR_BY_DESCRIPTOR): New flag on CALL_EXPR.
	* tree-core.h (ECF_BY_DESCRIPTOR): New mask.
	Document FUNC_ADDR_BY_DESCRIPTOR and CALL_EXPR_BY_DESCRIPTOR.
	* tree.c (make_node_stat) <tcc_declaration>: Use FUNCTION_ALIGNMENT.
	(build_common_builtin_nodes): Initialize init_descriptor and
	adjust_descriptor.
	* tree-nested.c: Include target.h.
	(struct nesting_info): Add 'any_descr_created' field.
	(get_descriptor_type): New function.
	(lookup_element_for_decl): New function extracted from...
	(create_field_for_decl): Likewise.
	(lookup_tramp_for_decl): ...here.  Adjust.
	(lookup_descr_for_decl): New function.
	(convert_tramp_reference_op): Deal with descriptors.
	(build_init_call_stmt): New function extracted from...
	(finalize_nesting_tree_1): ...here.  Adjust and deal withdescriptors.
	* defaults.h (FUNCTION_ALIGNMENT): Define.
	(TRAMPOLINE_ALIGNMENT): Set to above instead of FUNCTION_BOUNDARY.
	* config/i386/i386.h (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): Define.
	* config/ia64/ia64.h (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): Likewise.
	* config/rs6000/rs6000.h (TARGET_CUSTOM_FUNCTION_DESCRIPTORS):Likewise.
	* config/sparc/sparc.h (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): Likewise.
ada/
	* gcc-interface/misc.c (LANG_HOOKS_CUSTOM_FUNCTION_DESCRIPTORS):Define.
	* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Access>: Deal with
	a zero TARGET_CUSTOM_FUNCTION_DESCRIPTORS specially for Code_Address.
	Otherwise, if TARGET_CUSTOM_FUNCTION_DESCRIPTORS is positive, set
	FUNC_ADDR_BY_DESCRIPTOR for 'Access/'Unrestricted_Access of nested
	subprograms if the type can use an internal representation.
	(call_to_gnu): Likewise, but set CALL_EXPR_BY_DESCRIPTOR on indirect
	calls if the type can use an internal representation.

From-SVN: r241222
2016-10-16 20:13:32 +00:00
Eric Botcazou 2e33e1c46f tree.h (build_complex_type): Add second parameter with default.
* tree.h (build_complex_type): Add second parameter with default.
	* tree.c (build_complex_type): Add NAMED second parameter and adjust
	recursive call.  Create a TYPE_DECL only if NAMED is true.
	(build_common_tree_nodes): Pass true in calls to build_complex_type.

From-SVN: r240967
2016-10-11 08:05:31 +00:00
Jakub Jelinek 8813a647b5 tree-ssa.c (target_for_debug_bind, [...]): Use VAR_P and/or VAR_OR_FUNCTION_DECL_P macros.
* tree-ssa.c (target_for_debug_bind, verify_phi_args,
	ssa_undefined_value_p, maybe_optimize_var): Use VAR_P and/or
	VAR_OR_FUNCTION_DECL_P macros.
	* tree-chkp.c (chkp_register_var_initializer, chkp_make_static_bounds,
	chkp_get_bounds_for_decl_addr, chkp_parse_array_and_component_ref,
	chkp_find_bounds_1): Likewise.
	* ipa-polymorphic-call.c (decl_maybe_in_construction_p): Likewise.
	* hsa-gen.c (get_symbol_for_decl): Likewise.
	* cgraphunit.c (check_global_declaration, analyze_functions,
	handle_alias_pairs, thunk_adjust, cgraph_node::expand_thunk):
	Likewise.
	* gimple-fold.c (can_refer_decl_in_current_unit_p,
	canonicalize_constructor_val, gimple_get_virt_method_for_vtable):
	Likewise.
	* tree.c (set_decl_section_name, copy_node_stat,
	need_assembler_name_p, free_lang_data_in_decl, find_decls_types_r,
	merge_dllimport_decl_attributes, handle_dll_attribute,
	decl_init_priority_insert, auto_var_in_fn_p, array_at_struct_end_p,
	verify_type): Likewise.
	* gimple-ssa-isolate-paths.c (find_implicit_erroneous_behavior,
	find_explicit_erroneous_behavior): Likewise.
	* sdbout.c (sdbout_toplevel_data, sdbout_late_global_decl): Likewise.
	* ipa.c (process_references): Likewise.
	* tree-chkp-opt.c (chkp_get_check_result): Likewise.
	* varasm.c (get_block_for_decl, use_blocks_for_decl_p, make_decl_rtl,
	notice_global_symbol, assemble_variable, mark_decl_referenced,
	build_constant_desc, output_constant_def_contents, do_assemble_alias,
	make_decl_one_only, default_section_type_flags,
	categorize_decl_for_section, default_encode_section_info): Likewise.
	* trans-mem.c (requires_barrier): Likewise.
	* gimple-expr.c (mark_addressable): Likewise.
	* cfgexpand.c (add_scope_conflicts_1, expand_one_var,
	expand_used_vars_for_block, clear_tree_used, stack_protect_decl_p,
	expand_debug_expr): Likewise.
	* tree-dump.c (dequeue_and_dump): Likewise.
	* ubsan.c (instrument_bool_enum_load): Likewise.
	* tree-pretty-print.c (print_declaration): Likewise.
	* simplify-rtx.c (delegitimize_mem_from_attrs): Likewise.
	* tree-ssa-uninit.c (warn_uninitialized_vars): Likewise.
	* asan.c (asan_protect_global, instrument_derefs): Likewise.
	* tree-into-ssa.c (rewrite_stmt, maybe_register_def,
	pass_build_ssa::execute): Likewise.
	* var-tracking.c (var_debug_decl, track_expr_p): Likewise.
	* tree-ssa-loop-ivopts.c (force_expr_to_var_cost, split_address_cost):
	Likewise.
	* ipa-split.c (test_nonssa_use, consider_split, mark_nonssa_use):
	Likewise.
	* tree-inline.c (insert_debug_decl_map, remap_ssa_name,
	can_be_nonlocal, remap_decls, copy_debug_stmt,
	initialize_inlined_parameters, add_local_variables,
	reset_debug_binding, replace_locals_op): Likewise.
	* dse.c (can_escape): Likewise.
	* ipa-devirt.c (compare_virtual_tables, referenced_from_vtable_p):
	Likewise.
	* tree-diagnostic.c (default_tree_printer): Likewise.
	* tree-streamer-in.c (unpack_ts_decl_common_value_fields,
	unpack_ts_decl_with_vis_value_fields,
	lto_input_ts_decl_common_tree_pointers): Likewise.
	* builtins.c (builtin_save_expr, fold_builtin_expect,
	readonly_data_expr): Likewise.
	* tree-ssa-structalias.c (new_var_info, get_constraint_for_ssa_var,
	create_variable_info_for, set_uids_in_ptset, visit_loadstore):
	Likewise.
	* gimple-streamer-out.c (output_gimple_stmt): Likewise.
	* gimplify.c (force_constant_size, gimplify_bind_expr,
	gimplify_decl_expr, gimplify_var_or_parm_decl,
	gimplify_compound_lval, gimplify_init_constructor,
	gimplify_modify_expr, gimplify_asm_expr, gimplify_oacc_declare,
	gimplify_type_sizes): Likewise.
	* cgraphbuild.c (record_reference, record_type_list, mark_address,
	mark_load, mark_store, pass_build_cgraph_edges::execute): Likewise.
	* tree-ssa-live.c (mark_all_vars_used_1, remove_unused_scope_block_p,
	remove_unused_locals): Likewise.
	* tree-ssa-alias.c (ptr_deref_may_alias_decl_p, ptrs_compare_unequal,
	ref_maybe_used_by_call_p_1, call_may_clobber_ref_p_1): Likewise.
	* function.c (instantiate_expr, instantiate_decls_1,
	setjmp_vars_warning, add_local_decl): Likewise.
	* alias.c (ao_ref_from_mem, get_alias_set, compare_base_symbol_refs):
	Likewise.
	* tree-stdarg.c (find_va_list_reference, va_list_counter_struct_op,
	va_list_ptr_read, va_list_ptr_write, check_all_va_list_escapes,
	optimize_va_list_gpr_fpr_size): Likewise.
	* tree-nrv.c (pass_nrv::execute): Likewise.
	* tsan.c (instrument_expr): Likewise.
	* tree-ssa-dce.c (remove_dead_stmt): Likewise.
	* vtable-verify.c (verify_bb_vtables): Likewise.
	* tree-dfa.c (ssa_default_def, set_ssa_default_def,
	get_ref_base_and_extent): Likewise.
	* toplev.c (wrapup_global_declaration_1, wrapup_global_declaration_2):
	Likewise.
	* tree-sra.c (static bool constant_decl_p, find_var_candidates,
	analyze_all_variable_accesses): Likewise.
	* tree-nested.c (get_nonlocal_debug_decl,
	convert_nonlocal_omp_clauses, note_nonlocal_vla_type,
	note_nonlocal_block_vlas, convert_nonlocal_reference_stmt,
	get_local_debug_decl, convert_local_omp_clauses,
	convert_local_reference_stmt, nesting_copy_decl, remap_vla_decls):
	Likewise.
	* tree-vect-data-refs.c (vect_can_force_dr_alignment_p): Likewise.
	* stmt.c (decl_overlaps_hard_reg_set_p): Likewise.
	* dbxout.c (dbxout_late_global_decl, dbxout_type_fields,
	dbxout_symbol, dbxout_common_check): Likewise.
	* expr.c (expand_assignment, expand_expr_real_2, expand_expr_real_1,
	string_constant): Likewise.
	* hsa.c (hsa_get_declaration_name): Likewise.
	* passes.c (rest_of_decl_compilation): Likewise.
	* tree-ssanames.c (make_ssa_name_fn): Likewise.
	* tree-streamer-out.c (pack_ts_decl_common_value_fields,
	pack_ts_decl_with_vis_value_fields,
	write_ts_decl_common_tree_pointers): Likewise.
	* stor-layout.c (place_field): Likewise.
	* symtab.c (symtab_node::maybe_create_reference,
	symtab_node::verify_base, symtab_node::make_decl_local,
	symtab_node::copy_visibility_from,
	symtab_node::can_increase_alignment_p): Likewise.
	* dwarf2out.c (add_var_loc_to_decl, tls_mem_loc_descriptor,
	decl_by_reference_p, reference_to_unused, rtl_for_decl_location,
	fortran_common, add_location_or_const_value_attribute,
	add_scalar_info, add_linkage_name, set_block_abstract_flags,
	local_function_static, gen_variable_die, dwarf2out_late_global_decl,
	optimize_one_addr_into_implicit_ptr,
	optimize_location_into_implicit_ptr): Likewise.
	* gimple-low.c (record_vars_into): Likewise.
	* ipa-visibility.c (update_vtable_references): Likewise.
	* tree-ssa-address.c (fixed_address_object_p, copy_ref_info):
	Likewise.
	* lto-streamer-out.c (tree_is_indexable, get_symbol_initial_value,
	DFS::DFS_write_tree_body, write_symbol): Likewise.
	* langhooks.c (lhd_warn_unused_global_decl,
	lhd_set_decl_assembler_name): Likewise.
	* attribs.c (decl_attributes): Likewise.
	* except.c (output_ttype): Likewise.
	* varpool.c (varpool_node::get_create, ctor_for_folding,
	varpool_node::assemble_decl, varpool_node::create_alias): Likewise.
	* fold-const.c (fold_unary_loc): Likewise.
	* ipa-prop.c (ipa_compute_jump_functions_for_edge,
	ipa_find_agg_cst_from_init): Likewise.
	* omp-low.c (expand_omp_regimplify_p, expand_omp_taskreg,
	expand_omp_target, lower_omp_regimplify_p,
	grid_reg_assignment_to_local_var_p, grid_remap_prebody_decls,
	find_link_var_op): Likewise.
	* tree-chrec.c (chrec_contains_symbols): Likewise.
	* tree-cfg.c (verify_address, verify_expr, verify_expr_location_1,
	gimple_duplicate_bb, move_stmt_op, replace_block_vars_by_duplicates,
	execute_fixup_cfg): Likewise.

From-SVN: r240900
2016-10-09 13:19:48 +02:00
Joseph Myers c65699efcc Implement C _FloatN, _FloatNx types.
ISO/IEC TS 18661-3:2015 defines C bindings to IEEE interchange and
extended types, in the form of _FloatN and _FloatNx type names with
corresponding fN/FN and fNx/FNx constant suffixes and FLTN_* / FLTNX_*
<float.h> macros.  This patch implements support for this feature in
GCC.

The _FloatN types, for N = 16, 32, 64 or >= 128 and a multiple of 32,
are types encoded according to the corresponding IEEE interchange
format (endianness unspecified; may use either the NaN conventions
recommended in IEEE 754-2008, or the MIPS NaN conventions, since the
choice of convention is only an IEEE recommendation, not a
requirement).  The _FloatNx types, for N = 32, 64 and 128, are IEEE
"extended" types: types extending a narrower format with range and
precision at least as big as those specified in IEEE 754 for each
extended type (and with unspecified representation, but still
following IEEE semantics for their values and operations - and with
the set of values being determined by the precision and the maximum
exponent, which means that while Intel "extended" is suitable for
_Float64x, m68k "extended" is not).  These types are always distinct
from and not compatible with each other and the standard floating
types float, double, long double; thus, double, _Float64 and _Float32x
may all have the same ABI, but they are three still distinct types.
The type names may be used with _Complex to construct corresponding
complex types (unlike __float128, which acts more like a typedef name
than a keyword - thus, this patch may be considered to fix PR
c/32187).  The new suffixes can be combined with GNU "i" and "j"
suffixes for constants of complex types (e.g. 1.0if128, 2.0f64i).

The set of types supported is implementation-defined.  In this GCC
patch, _Float32 is SFmode if that is suitable; _Float32x and _Float64
are DFmode if that is suitable; _Float128 is TFmode if that is
suitable; _Float64x is XFmode if that is suitable, and otherwise
TFmode if that is suitable.  There is a target hook to override the
choices if necessary.  "Suitable" means both conforming to the
requirements of that type, and supported as a scalar type including in
libgcc.  The ABI is whatever the back end does for scalars of that
mode (but note that _Float32 is passed without promotion in variable
arguments, unlike float).  All the existing issues with exceptions and
rounding modes for existing types apply equally to the new type names.

No GCC port supports a floating-point format suitable for _Float128x.
Although there is HFmode support for ARM and AArch64, use of that for
_Float16 is not enabled.  Supporting _Float16 would require additional
work on the excess precision aspects of TS 18661-3: there are new
values of FLT_EVAL_METHOD, which are not currently supported in GCC,
and FLT_EVAL_METHOD == 0 now means that operations and constants on
types narrower than float are evaluated to the range and precision of
float.  Implementing that, so that _Float16 gets evaluated with excess
range and precision, would involve changes to the excess precision
infrastructure so that the _Float16 case is enabled by default, unlike
the x87 case which is only enabled for -fexcess-precision=standard.
Other differences between _Float16 and __fp16 would also need to be
disentangled.

GCC has some prior support for nonstandard floating-point types in the
form of __float80 and __float128.  Where these were previously types
distinct from long double, they are made by this patch into aliases
for _Float64x / _Float128 if those types have the required properties.

In principle the set of possible _FloatN types is infinite.  This
patch hardcodes the four such types for N <= 128, but with as much
code as possible using loops over types to minimize the number of
places with such hardcoding.  I don't think it's likely any further
such types will be of use in future (or indeed that formats suitable
for _Float128x will actually be implemented).  There is a corner case
that all _FloatN, for N >= 128 and a multiple of 32, should be treated
as keywords even when the corresponding type is not supported; I
intend to deal with that in a followup patch.

Tests are added for various functionality of the new types, mostly
using type-generic headers.  The tests use dg-add-options to pass any
extra options needed to enable the types; this is wired up to use the
same options as for __float128 on powerpc to enable _Float128 and
_Float64x, and effective-target keywords for runtime support do the
same hardware test as for __float128 to make sure the VSX instructions
generated by those options are supported.  (Corresponding additions
would be needed for _Float16 on ARM as well if that were enabled with
-mfp16-format=ieee required to use it rather than unconditionally
available.  Of course, -mfp16-format=alternative enables use of a
format which is not compatible with the requirements of the _Float16
type.)

C++ note: no support for the new types or constant suffixes is added
for C++.  C++ decimal floating-point support was very different from
the C support, using class types, and the same may well apply to any
future C++ bindings for IEEE interchange and extended types.  There is
a case, however, for supporting at least *f128 constants in C++, so
that code using __float128 can use the newer style for constants
throughout rather than needing to use the older *q constants in C++.
Also, if built-in functions are added that may provide a way in which
the types could leak into C++ code.

Fortran note: the float128_type_node used in the Fortran front end is
renamed to gfc_float128_type_node, since the semantics are different:
in particular, if long double has binary128 format, then the new
language-independent float128_type_node is a distinct type that also
has binary128 format, but the Fortran node is expected to be NULL in
that case.  Likewise, Fortran's complex_float128_type_node is renamed
to gfc_complex_float128_type_node.

PowerPC note: the back end had an inconsistency that if TFmode was
binary128, *q constants were TFmode instead of KFmode but __float128
was KFmode.  This patch follows the same logic as for *q constants, so
that _Float128 prefers TFmode (and __float128 becomes an alias for
_Float128).

ARM note: __fp16 is promoted to double (by convert_arguments) when
passed without a prototype / in variable arguments.  But this is only
about the argument promotion; it is not handled as promoting in
c-common.c:self_promoting_args_p / c-typeck.c:c_type_promotes_to,
meaning that a K&R function definition for an argument of type __fp16
corresponds to a prototype with an argument of that type, not to one
with an argument of type double, whereas a float argument in a K&R
function definition corresponds to a double prototype argument - and
the same functions are also what's involved in making va_arg give a
warning and generate a call to abort when called with type float.
This is preserved by this patch, while arranging for _Float16 not to
be promoted when passed without a prototype / in variable arguments
(the promotion of float being considered a legacy feature, not applied
to any new types in C99 or later).

TS 18661-3 extends the set of decimal floating-point types similarly,
and adds new constant suffixes for the existing types, but this patch
does not do anything regarding that extension.

This patch does nothing regarding built-in functions, although
type-generic functions such as __builtin_isinf work for the new types
and associated tests are included.  There are at least two levels of
built-in function support possible for these types.  The minimal
level, implemented in
<https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01702.html> (which
needs updating to use dg-add-options), adds built-in functions similar
to those x86 has for __float128: __builtin_inf* __builtin_huge_val*,
__builtin_nan*, __builtin_nans*, __builtin_fabs*, __builtin_copysign*.
That would be sufficient for glibc to use the *f128 names for built-in
functions by default with *q used only for backwards compatibility
when using older GCC versions.  That would also allow c_cpp_builtins's
flag_building_libgcc code, defining __LIBGCC_%s_FUNC_EXT__, to use
such suffixes rather than the present code hardcoding logic about
target-specific constant suffixes and how those relate to function
suffixes.

Full built-in function support would cover the full range of built-in
functions for existing floating-point types, adding variants for all
the new types, except for a few obsolescent functions and
non-type-generic variants of type-generic functions.  Some but not all
references to such functions in GCC use macros such as CASE_FLT_FN to
be type-generic; a fair amount of work would be needed to identify all
places to update.  Adding all those functions would enable
optimizations (for constant arguments and otherwise) for TS 18661-3
functions, but it would also substantially expand the enum listing
built-in functions (and we've had problems with the size of that enum
in the past), and increase the amount of built-in function
initialization to do - I don't know what the startup cost involved in
built-in function initialization is, but it would be something to
consider when adding such a large set of functions.

There are also a range of optimizations, in match.pd and elsewhere,
that only operate on the three standard floating-point types.  Ideally
those would be made generic to all floating-point types, but this
patch does nothing in that regard.  Special care would be needed
regarding making sure library functions to which calls are generated
actually exist.  For example, if sqrt is called on an argument of type
_Float32, and the result converted to _Float32, this is equivalent to
doing a square root operation directly on _Float32.  But if the user's
libm does not have the sqrtf32 function, or the name is not reserved
because __STDC_WANT_IEC_60559_TYPES_EXT__ was not defined before
including <math.h>, you can only do that optimization if you convert
to a call to sqrtf instead.

DECIMAL_DIG now relates to all supported floating-point formats, not
just float, double and long double; I've raised the question with WG14
of how this relates to the formula for DECIMAL_DIG in C11 not
considering this.  TS 18661-3 says it also covers non-arithmetic
formats only supported by library conversion functions; this patch
does not add any target hooks to allow for the case where there are
such formats wider than any supported for arithmetic types (where
e.g. libc supports conversions involving the binary128 representation,
but the _Float128 type is not supported).

GCC provides its own <tgmath.h> for some targets.  No attempt is made
to adapt this to handle the new types.

Nothing is done regarding debug info for the new types (see the
"Debugger support for __float128 type?" thread on gcc@, Sep/Oct 2015).

No __SIZEOF_*__ macros are added for the new types.

Nothing is done with do_warn_double_promotion.

Nothing is done to include the new types in those determining
max_align_t, although properly it should be sufficiently aligned for
any of those types.

The logic for usual arithmetic conversions in c_common_type relies on
TYPE_PRECISION for floating-point types, which is less than ideal
(doesn't necessarily correspond to whether one type's values are
subset of another); looking in more detail at the formats might be
better.  But since I included code in build_common_tree_nodes to work
around rs6000 KFmode having precision 113 not 128, I think it should
work.  Ideally one might have errors in generic code for the case
where the two types do not have one type's values a subset of the
other (which is undefined behavior).  But the only case where this can
actually occur is mixing IBM long double with binary128 on powerpc,
and rs6000_invalid_binary_op deals with that at present.  TS 18661-3
does not fully specify the type resulting from the usual arithmetic
conversions in the case where two _FloatNx types have the same set of
values; I arranged the code to prefer the greater value of N in that
case.

The __FP_FAST_FMA* macros are not extended to cover the new types,
since there are no corresponding built-in functions (if built-in
fmafN, fmafNx are added, the macros should be extended, and the new
macros documented).  Also, only a limited set of modes is handled in
mode_has_fma.

Diagnostics relating to the use of the new types with -pedantic do not
try to distinguish them from purely nonstandard types such as __int128
and constant suffixes such as *q.

If you use an unsupported _FloatN / _FloatNx type you get a warning
about the type defaulting to int after the warning about the type not
being supported.  That's less than ideal, but it's also a pre-existing
condition if you use __int128 on a 32-bit system where it's
unsupported.

Bootstrapped with no regressions on x86_64-pc-linux-gnu.  Other
back-end changes minimally tested by building cc1 for ia64-linux-gnu,
powerpc64le-linux-gnu, pdp11-none (the last failed for unrelated
reasons).

	PR c/32187
gcc:
	* tree-core.h (TI_COMPLEX_FLOAT16_TYPE)
	(TI_COMPLEX_FLOATN_NX_TYPE_FIRST, TI_COMPLEX_FLOAT32_TYPE)
	(TI_COMPLEX_FLOAT64_TYPE, TI_COMPLEX_FLOAT128_TYPE)
	(TI_COMPLEX_FLOAT32X_TYPE, TI_COMPLEX_FLOAT64X_TYPE)
	(TI_COMPLEX_FLOAT128X_TYPE, TI_FLOAT16_TYPE, TI_FLOATN_TYPE_FIRST)
	(TI_FLOATN_NX_TYPE_FIRST, TI_FLOAT32_TYPE, TI_FLOAT64_TYPE)
	(TI_FLOAT128_TYPE, TI_FLOATN_TYPE_LAST, TI_FLOAT32X_TYPE)
	(TI_FLOATNX_TYPE_FIRST, TI_FLOAT64X_TYPE, TI_FLOAT128X_TYPE)
	(TI_FLOATNX_TYPE_LAST, TI_FLOATN_NX_TYPE_LAST): New enum
	tree_index values.
	(NUM_FLOATN_TYPES, NUM_FLOATNX_TYPES, NUM_FLOATN_NX_TYPES): New
	macros.
	(struct floatn_type_info): New structure type.
	(floatn_nx_types): New variable declaration.
	* tree.h (FLOATN_TYPE_NODE, FLOATN_NX_TYPE_NODE)
	(FLOATNX_TYPE_NODE, float128_type_node, float64x_type_node)
	(COMPLEX_FLOATN_NX_TYPE_NODE): New macros.
	* tree.c (floatn_nx_types): New variable.
	(build_common_tree_nodes): Initialize _FloatN, _FloatNx and
	corresponding complex types.
	* target.def (floatn_mode): New hook.
	* targhooks.c: Include "real.h".
	(default_floatn_mode): New function.
	* targhooks.h (default_floatn_mode): New prototype.
	* doc/extend.texi (Floating Types): Document _FloatN and _FloatNx
	types.
	* doc/sourcebuild.texi (float@var{n}, float@var{n}x): Document new
	effective-target and dg-add-options keywords.
	(float@var{n}_runtime, float@var{n}x_runtime, floatn_nx_runtime):
	Document new effective-target keywords.
	* doc/tm.texi.in (TARGET_FLOATN_MODE): New @hook.
	* doc/tm.texi: Regenerate.
	* ginclude/float.h (LDBL_DECIMAL_DIG): Define to
	__LDBL_DECIMAL_DIG__, not __DECIMAL_DIG__.
	[__STDC_WANT_IEC_60559_TYPES_EXT__]: Define macros from TS
	18661-3.
	* real.h (struct real_format): Add field ieee_bits.
	* real.c (ieee_single_format, mips_single_format)
	(motorola_single_format, spu_single_format, ieee_double_format)
	(mips_double_format, motorola_double_format)
	(ieee_extended_motorola_format, ieee_extended_intel_96_format)
	(ieee_extended_intel_128_format)
	(ieee_extended_intel_96_round_53_format, ibm_extended_format)
	(mips_extended_format, ieee_quad_format, mips_quad_format)
	(vax_f_format, vax_d_format, vax_g_format, decimal_single_format)
	(decimal_double_format, decimal_quad_format, ieee_half_format)
	(arm_half_format, real_internal_format: Initialize ieee_bits
	field.
	* config/i386/i386.c (ix86_init_builtin_types): Do not initialize
	float128_type_node.  Set float80_type_node to float64x_type_node
	if appropriate and long_double_type_node not appropriate.
	* config/ia64/ia64.c (ia64_init_builtins): Likewise.
	* config/pdp11/pdp11.c (pdp11_f_format, pdp11_d_format):
	Initialize ieee_bits field.
	* config/rs6000/rs6000.c (TARGET_FLOATN_MODE): New macro.
	(rs6000_init_builtins): Set ieee128_float_type_node to
	float128_type_node.
	(rs6000_floatn_mode): New function.

gcc/c:
	* c-tree.h (cts_floatn_nx): New enum c_typespec_keyword value.
	(struct c_declspecs): Add field floatn_nx_idx.
	* c-decl.c (declspecs_add_type, finish_declspecs): Handle _FloatN
	and _FloatNx type specifiers.
	* c-parser.c (c_keyword_starts_typename, c_token_starts_declspecs)
	(c_parser_declspecs, c_parser_attribute_any_word)
	(c_parser_objc_selector): Use CASE_RID_FLOATN_NX.
	* c-typeck.c (c_common_type): Handle _FloatN and _FloatNx types.
	(convert_arguments): Avoid promoting _FloatN and _FloatNx types
	narrower than double.

gcc/c-family:
	* c-common.h (RID_FLOAT16, RID_FLOATN_NX_FIRST, RID_FLOAT32)
	(RID_FLOAT64, RID_FLOAT128, RID_FLOAT32X, RID_FLOAT64X)
	(RID_FLOAT128X): New enum rid values.
	(CASE_RID_FLOATN_NX): New macro.
	* c-common.c (c_common_reswords): Add _FloatN and _FloatNx
	keywords.
	(c_common_type_for_mode): Check for _FloatN and _FloatNx and
	corresponding complex types.
	(c_common_nodes_and_builtins): For non-C++, register _FloatN and
	_FloatNx and corresponding complex types.
	(keyword_begins_type_specifier): Use CASE_RID_FLOATN_NX.
	* c-cppbuiltin.c (builtin_define_float_constants): Check _FloatN
	and _FloatNx types for the widest type for determining
	DECIMAL_DIG.  Define __LDBL_DECIMAL_DIG__ as well as
	__DECIMAL_DIG__ for long double.  Handle FMA_SUFFIX being NULL.
	(c_cpp_builtins): Call builtin_define_float_constants for _FloatN
	and _FloatNx types.
	* c-lex.c (interpret_float): Handle _FloatN and _FloatNx
	constants.
	* c-pretty-print.c (pp_c_floating_constant): Handle _FloatN and
	_FloatNx types.

gcc/fortran:
	* trans-types.h (float128_type_node): Rename to
	gfc_float128_type_node.
	(complex_float128_type_node): Rename to
	gfc_complex_float128_type_node.
	* iso-c-binding.def, trans-intrinsic.c, trans-types.c: All users
	changed.

gcc/testsuite:
	* lib/target-supports.exp (check_effective_target_float16)
	(check_effective_target_float32, check_effective_target_float64)
	(check_effective_target_float128, check_effective_target_float32x)
	(check_effective_target_float64x)
	(check_effective_target_float128x)
	(check_effective_target_float16_runtime)
	(check_effective_target_float32_runtime)
	(check_effective_target_float64_runtime)
	(check_effective_target_float128_runtime)
	(check_effective_target_float32x_runtime)
	(check_effective_target_float64x_runtime)
	(check_effective_target_float128x_runtime)
	(check_effective_target_floatn_nx_runtime)
	(add_options_for_float16, add_options_for_float32)
	(add_options_for_float64, add_options_for_float128)
	(add_options_for_float32x, add_options_for_float64x)
	(add_options_for_float128x): New procedures.
	* gcc.dg/dfp/floatn.c, gcc.dg/float128-typeof.c,
	gcc.dg/float128x-typeof.c, gcc.dg/float16-typeof.c,
	gcc.dg/float32-typeof.c, gcc.dg/float32x-typeof.c,
	gcc.dg/float64-typeof.c, gcc.dg/float64x-typeof.c,
	gcc.dg/floatn-arithconv.c, gcc.dg/floatn-errs.c,
	gcc.dg/floatn-typeof.h, gcc.dg/torture/float128-basic.c,
	gcc.dg/torture/float128-complex.c,
	gcc.dg/torture/float128-floath.c, gcc.dg/torture/float128-tg.c,
	gcc.dg/torture/float128x-basic.c,
	gcc.dg/torture/float128x-complex.c,
	gcc.dg/torture/float128x-floath.c, gcc.dg/torture/float128x-tg.c,
	gcc.dg/torture/float16-basic.c, gcc.dg/torture/float16-complex.c,
	gcc.dg/torture/float16-floath.c, gcc.dg/torture/float16-tg.c,
	gcc.dg/torture/float32-basic.c, gcc.dg/torture/float32-complex.c,
	gcc.dg/torture/float32-floath.c, gcc.dg/torture/float32-tg.c,
	gcc.dg/torture/float32x-basic.c,
	gcc.dg/torture/float32x-complex.c,
	gcc.dg/torture/float32x-floath.c, gcc.dg/torture/float32x-tg.c,
	gcc.dg/torture/float64-basic.c, gcc.dg/torture/float64-complex.c,
	gcc.dg/torture/float64-floath.c, gcc.dg/torture/float64-tg.c,
	gcc.dg/torture/float64x-basic.c,
	gcc.dg/torture/float64x-complex.c,
	gcc.dg/torture/float64x-floath.c, gcc.dg/torture/float64x-tg.c,
	gcc.dg/torture/floatn-basic.h, gcc.dg/torture/floatn-complex.h,
	gcc.dg/torture/floatn-convert.c, gcc.dg/torture/floatn-floath.h,
	gcc.dg/torture/floatn-tg.h,
	gcc.dg/torture/fp-int-convert-float128-ieee-timode.c,
	gcc.dg/torture/fp-int-convert-float128-ieee.c,
	gcc.dg/torture/fp-int-convert-float128x-timode.c,
	gcc.dg/torture/fp-int-convert-float128x.c,
	gcc.dg/torture/fp-int-convert-float16-timode.c,
	gcc.dg/torture/fp-int-convert-float16.c,
	gcc.dg/torture/fp-int-convert-float32-timode.c,
	gcc.dg/torture/fp-int-convert-float32.c,
	gcc.dg/torture/fp-int-convert-float32x-timode.c,
	gcc.dg/torture/fp-int-convert-float32x.c,
	gcc.dg/torture/fp-int-convert-float64-timode.c,
	gcc.dg/torture/fp-int-convert-float64.c,
	gcc.dg/torture/fp-int-convert-float64x-timode.c,
	gcc.dg/torture/fp-int-convert-float64x.c: New tests.
	* gcc.dg/torture/fp-int-convert.h (TEST_I_F): Add argument for
	maximum exponent of floating-point type.  Use it in testing
	whether 0x8...0 fits in the floating-point type.  Always treat -1
	(signed 0xf...f) as fitting in the floating-point type.
	(M_OK1): New macro.
	* gcc.dg/torture/fp-int-convert-double.c,
	gcc.dg/torture/fp-int-convert-float.c,
	gcc.dg/torture/fp-int-convert-float128-timode.c,
	gcc.dg/torture/fp-int-convert-float128.c,
	gcc.dg/torture/fp-int-convert-float80-timode.c,
	gcc.dg/torture/fp-int-convert-float80.c,
	gcc.dg/torture/fp-int-convert-long-double.c,
	gcc.dg/torture/fp-int-convert-timode.c: Update calls to TEST_I_F.

libcpp:
	* include/cpplib.h (CPP_N_FLOATN, CPP_N_FLOATNX)
	(CPP_N_WIDTH_FLOATN_NX, CPP_FLOATN_SHIFT, CPP_FLOATN_MAX): New
	macros.
	* expr.c (interpret_float_suffix): Handle fN, fNx, FN and FNx
	suffixes.

From-SVN: r239625
2016-08-19 18:43:26 +01:00
Marek Polacek 191816a36b re PR c/7652 (-Wswitch-break : Warn if a switch case falls through)
PR c/7652
gcc/
	* alias.c (find_base_value): Adjust fall through comment.
	* cfgexpand.c (expand_debug_expr): Likewise.
	* combine.c (find_split_point): Likewise.
	(expand_compound_operation): Likewise.  Add FALLTHRU.
	(make_compound_operation): Adjust fall through comment.
	(canon_reg_for_combine): Add FALLTHRU.
	(force_to_mode): Adjust fall through comment.
	(simplify_shift_const_1): Likewise.
	(simplify_comparison): Likewise.
	* config/aarch64/aarch64-builtins.c (aarch64_simd_expand_args): Add
	FALLTHRU.
	* config/aarch64/predicates.md: Likewise.
	* config/i386/i386.c (function_arg_advance_32): Likewise.
	(ix86_gimplify_va_arg): Likewise.
	(print_reg): Likewise.
	(ix86_print_operand): Likewise.
	(ix86_build_const_vector): Likewise.
	(ix86_expand_branch): Likewise.
	(ix86_sched_init_global): Adjust fall through comment.
	(ix86_expand_args_builtin): Add FALLTHRU.
	(ix86_expand_builtin): Likewise.
	(ix86_expand_vector_init_one_var): Likewise.
	* config/rs6000/rs6000.c (rs6000_emit_vector_compare_inner): Likewise.
	(rs6000_adjust_cost): Likewise.
	(insn_must_be_first_in_group): Likewise.
	* config/rs6000/rs6000.md: Likewise.  Adjust fall through comment.
	* dbxout.c (dbxout_symbol): Adjust fall through comment.
	* df-scan.c (df_uses_record): Likewise.
	* dojump.c (do_jump): Add FALLTHRU.
	* dwarf2out.c (mem_loc_descriptor): Likewise.  Adjust fall through
	comment.
	(resolve_args_picking_1): Adjust fall through comment.
	(loc_list_from_tree_1): Likewise.
	* expmed.c (make_tree): Likewise.
	* expr.c (expand_expr_real_2): Add FALLTHRU.
	(expand_expr_real_1): Likewise.  Adjust fall through comment.
	* fold-const.c (const_binop): Adjust fall through comment.
	(fold_truth_not_expr): Likewise.
	(fold_cond_expr_with_comparison): Add FALLTHRU.
	(fold_binary_loc): Likewise.
	(contains_label_1): Adjust fall through comment.
	(multiple_of_p): Likewise.
	* gcov-tool.c (process_args): Add FALLTHRU.
	* genattrtab.c (check_attr_test): Likewise.
	(write_test_expr): Likewise.
	* genconfig.c (walk_insn_part): Likewise.
	* genpreds.c (validate_exp): Adjust fall through comment.
	(needs_variable): Likewise.
	* gensupport.c (get_alternatives_number): Add FALLTHRU.
	(subst_dup): Likewise.
	* gimple-pretty-print.c (dump_gimple_assign): Likewise.
	* gimplify.c (gimplify_addr_expr): Adjust fall through comment.
	(gimplify_scan_omp_clauses): Add FALLTHRU.
	(goa_stabilize_expr): Likewise.
	* graphite-isl-ast-to-gimple.c (substitute_ssa_name): Adjust fall
	through comment.
	* hsa-gen.c (get_address_from_value): Likewise.
	* ipa-icf.c (sem_function::hash_stmt): Likewise.
	* ira.c (ira_setup_alts): Add FALLTHRU.
	* lra-eliminations.c (lra_eliminate_regs_1): Adjust fall through
	comment.
	* lto-streamer-out.c (lto_output_tree_ref): Add FALLTHRU.
	* opts.c (common_handle_option): Likewise.
	* read-rtl.c (read_rtx_code): Likewise.
	* real.c (round_for_format): Likewise.
	* recog.c (asm_operand_ok): Likewise.
	* reginfo.c (reg_scan_mark_refs): Adjust fall through comment.
	* reload1.c (set_label_offsets): Likewise.
	(eliminate_regs_1): Likewise.
	(reload_reg_reaches_end_p): Likewise.
	* rtlanal.c (commutative_operand_precedence): Add FALLTHRU.
	(rtx_cost): Likewise.
	* sched-rgn.c (is_exception_free): Likewise.
	* simplify-rtx.c (simplify_rtx): Adjust fall through comment.
	* stor-layout.c (int_mode_for_mode): Likewise.
	* toplev.c (print_to_asm_out_file): Likewise.
	(print_to_stderr): Likewise.
	* tree-cfg.c (gimple_verify_flow_info): Likewise.
	* tree-chrec.c (chrec_fold_plus_1): Add FALLTHRU.
	(chrec_fold_multiply): Likewise.
	(evolution_function_is_invariant_rec_p): Likewise.
	(for_each_scev_op): Likewise.
	* tree-data-ref.c (siv_subscript_p): Likewise.
	(get_references_in_stmt): Likewise.
	* tree.c (find_placeholder_in_expr): Adjust fall through comment.
	(substitute_in_expr): Likewise.
	(type_cache_hasher::equal): Likewise.
	(walk_type_fields): Likewise.
	* var-tracking.c (adjust_mems): Add FALLTHRU.
	(set_dv_changed): Adjust fall through comment.
	* varasm.c (default_function_section): Add FALLTHRU.
gcc/c-family/
	* c-common.c (scalar_to_vector): Adjust fall through comment.
	* c-opts.c (c_common_handle_option): Likewise.
	* c-pragma.c (handle_pragma_pack): Add FALLTHRU.
	* c-pretty-print.c (c_pretty_printer::postfix_expression): Adjust
	fall through comment.
	* cilk.c (extract_free_variables): Add FALLTHRU.
gcc/c/
	* c-parser.c (c_parser_external_declaration): Add FALLTHRU.
	(c_parser_postfix_expression): Likewise.
	* c-typeck.c (build_unary_op): Adjust fall through comment.
	(c_mark_addressable): Likewise.
gcc/cp/
	* call.c (add_builtin_candidate): Add FALLTHRU.
	(build_integral_nontype_arg_conv): Adjust fall through comment.
	(build_new_op_1): Add FALLTHRU.
	(convert_like_real): Adjust fall through comment.
	* class.c (fixed_type_or_null): Likewise.
	* constexpr.c (cxx_eval_constant_expression): Likewise.
	(potential_constant_expression_1): Likewise.  Add FALLTHRU.
	* cp-gimplify.c (cp_gimplify_expr): Adjust fall through comment.
	(cp_fold): Add FALLTHRU.
	* cvt.c (build_expr_type_conversion): Adjust fall through comment.
	* cxx-pretty-print.c (pp_cxx_unqualified_id): Add FALLTHRU.
	(pp_cxx_qualified_id): Likewise.
	(cxx_pretty_printer::constant): Adjust fall through comment.
	(cxx_pretty_printer::primary_expression): Add FALLTHRU.
	(pp_cxx_pm_expression): Adjust fall through comment.
	(cxx_pretty_printer::expression): Add FALLTHRU.
	(cxx_pretty_printer::declaration_specifiers): Reformat code.
	(pp_cxx_type_specifier_seq): Adjust fall through comment.
	(pp_cxx_ptr_operator): Likewise.  Add FALLTHRU.
	* error.c (dump_type): Adjust fall through comment.
	(dump_decl): Likewise.
	* mangle.c (write_type): Likewise.
	* method.c (synthesized_method_walk): Add FALLTHRU.
	* name-lookup.c (arg_assoc_type): Likewise.
	* parser.c (cp_lexer_print_token): Adjust fall through comment.
	(cp_parser_primary_expression): Add FALLTHRU.
	(cp_parser_operator): Likewise.
	* pt.c (find_parameter_packs_r): Likewise.
	(tsubst_aggr_type): Adjust fall through comment.
	* semantics.c (finish_omp_clauses): Add FALLTHRU.
	* tree.c (lvalue_kind): Likewise.
gcc/fortran/
	* decl.c (match_attr_spec): Add FALLTHRU.
	* primary.c (match_arg_list_function): Likewise.
	* resolve.c (resolve_operator): Adjust fall through comment.
	(fixup_charlen): Add FALLTHRU.
	(resolve_allocate_expr): Adjust fall through comment.
	* trans-array.c (gfc_conv_ss_startstride): Add FALLTHRU.
	* trans-intrinsic.c (gfc_conv_intrinsic_len): Adjust fall through
	comment.
gcc/java/
	* expr.c (java_truthvalue_conversion): Adjust fall through comment.
	* jcf-io.c (verify_constant_pool): Likewise.
	* typeck.c (promote_type): Likewise.
gcc/objc/
	* objc-encoding.c (encode_type): Add FALLTHRU.
libcpp/
	* lex.c (search_line_fast): Add FALLTHRU.
	(_cpp_lex_direct): Likewise.
	(cpp_token_val_index): Adjust fall through comment.
	* macro.c (parse_params): Add FALLTHRU.
	* pch.c (count_defs): Adjust fall through comment.
	(write_defs): Likewise.
libiberty/
	* cp-demangle.c (d_print_mod): Add FALLTHRU.

From-SVN: r239410
2016-08-12 10:30:47 +00:00
David Malcolm a01fc54920 Move make_location from tree.h/c to input.h/c
For some reason I added make_location and some related functions to
tree.h/c, rather than to input.h/c.  Move them there, so we can use them
without requiring tree, and add some selftest coverage.

gcc/ChangeLog:
	* input.c (get_pure_location): Move here from tree.c.
	(make_location): Likewise.  Add header comment.
	(selftest::test_accessing_ordinary_linemaps): Verify
	pure_location_p, make_location, get_location_from_adhoc_loc and
	get_range_from_loc.
	* input.h (get_pure_location): Move declaration here from tree.h.
	(get_finish): Likewise for inline function.
	(make_location): Likewise for declaration.
	* tree.c (get_pure_location): Move to input.c.
	(make_location): Likewise.
	* tree.h (get_pure_location): Move declaration to tree.h.
	(get_finish): Likewise for inline function.
	(make_location): Likewise for declaration.

libcpp/ChangeLog:
	* include/line-map.h (source_location): Fix line numbers in
	comment.

From-SVN: r238792
2016-07-27 17:21:20 +00:00
Uros Bizjak dd4786fe81 cse.c: Use HOST_WIDE_INT_M1 instead of ~(HOST_WIDE_INT) 0.
* cse.c: Use HOST_WIDE_INT_M1 instead of ~(HOST_WIDE_INT) 0.
	* combine.c: Use HOST_WIDE_INT_M1U instead of
	~(unsigned HOST_WIDE_INT) 0.
	* double-int.h: Ditto.
	* dse.c: Ditto.
	* dwarf2asm.c:Ditto.
	* expmed.c: Ditto.
	* genmodes.c: Ditto.
	* match.pd: Ditto.
	* read-rtl.c: Ditto.
	* tree-ssa-loop-ivopts.c: Ditto.
	* tree-ssa-loop-prefetch.c: Ditto.
	* tree-vect-generic.c: Ditto.
	* tree-vect-patterns.c: Ditto.
	* tree.c: Ditto.

From-SVN: r238529
2016-07-20 17:47:33 +02:00
Uros Bizjak fecfbfa4a2 builtins.c: Use HOST_WIDE_INT_1 instead of (HOST_WIDE_INT) 1...
* builtins.c: Use HOST_WIDE_INT_1 instead of (HOST_WIDE_INT) 1,
	HOST_WIDE_INT_1U instead of (unsigned HOST_WIDE_INT) 1,
	HOST_WIDE_INT_M1 instead of (HOST_WIDE_INT) -1 and
	HOST_WIDE_INT_M1U instead of (unsigned HOST_WIDE_INT) -1.
	* combine.c: Ditto.
	* cse.c: Ditto.
	* dojump.c: Ditto.
	* double-int.c: Ditto.
	* dse.c: Ditto.
	* dwarf2out.c: Ditto.
	* expmed.c: Ditto.
	* expr.c: Ditto.
	* fold-const.c: Ditto.
	* function.c: Ditto.
	* fwprop.c: Ditto.
	* genmodes.c: Ditto.
	* hwint.c: Ditto.
	* hwint.h: Ditto.
	* ifcvt.c: Ditto.
	* loop-doloop.c: Ditto.
	* loop-invariant.c: Ditto.
	* loop-iv.c: Ditto.
	* match.pd: Ditto.
	* optabs.c: Ditto.
	* real.c: Ditto.
	* reload.c: Ditto.
	* rtlanal.c: Ditto.
	* simplify-rtx.c: Ditto.
	* stor-layout.c: Ditto.
	* toplev.c: Ditto.
	* tree-ssa-loop-ivopts.c: Ditto.
	* tree-vect-generic.c: Ditto.
	* tree-vect-patterns.c: Ditto.
	* tree.c: Ditto.
	* tree.h: Ditto.
	* ubsan.c: Ditto.
	* varasm.c: Ditto.
	* wide-int-print.cc: Ditto.
	* wide-int.cc: Ditto.
	* wide-int.h: Ditto.

From-SVN: r238481
2016-07-19 18:40:55 +02:00
Trevor Saunders 74ea4cd5e3 tree.c: add [cd]tors to free_lang_data_d
gcc/ChangeLog:

2016-07-12  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* tree.c (struct free_lang_data_d): Add constructor and change
	types of members to ones that automatically manage resources.
	(fld_worklist_push): Adjust.
	(find_decls_types): Likewise.
	(find_decls_types_in_eh_region): Likewise.
	(free_lang_data_in_cgraph): Stop manually creating and
	destroying members of free_lang_data_d.

From-SVN: r238278
2016-07-13 02:43:10 +00:00
Bernd Edlinger 25b75a48d2 Convert TYPE_ALIGN_OK to a TYPE_LANG_FLAG.
2016-07-11  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        Convert TYPE_ALIGN_OK to a TYPE_LANG_FLAG.
        * tree-core.h (tree_base::nothrow_flag): Adjust comment.
        (tree_type_common::lang_flag_7): New.
        (tree_type_common::spare): Reduce size.
        * tree.h (TYPE_ALIGN_OK): Remove.
        (TYPE_LANG_FLAG_7): New.
        (get_inner_reference): Adjust header.
        * print-tree.c (print_node): Adjust.
        * expr.c (get_inner_reference): Remove parameter keep_aligning.
        (get_bit_range, expand_assignment, expand_expr_addr_expr_1): Adjust
        calls to get_inner_reference.
        (expand_expr_real_1): Adjust call to get_inner_reference.  Remove
        handling of TYPE_ALIGN_OK.
        * builtins.c (get_object_alignment_2): Adjust call to
        get_inner_reference.  Remove handling of VIEW_CONVERT_EXPR.
        * emit-rtl.c (set_mem_attributes_minus_bitpos): Remove handling of
        TYPE_ALIGN_OK.
        * asan.c (instrument_derefs): Adjust calls to get_inner_reference.
        * cfgexpand.c (expand_debug_expr): Likewise.
        * dbxout.c (dbxout_expand_expr): Likewise.
        * dwarf2out.c (loc_list_for_address_of_addr_expr_of_indirect_ref,
        loc_list_from_tree, fortran_common): Likewise.
        * fold-const.c (optimize_bit_field_compare,
        decode_field_reference, fold_unary_loc, fold_comparison,
        split_address_to_core_and_offset): Likewise.
        * gimple-laddress.c (execute): Likewise.
        * gimple-ssa-strength-reduction.c (slsr_process_ref): Likewise.
        * gimplify.c (gimplify_scan_omp_clauses): Likewise.
        * hsa-gen.c (gen_hsa_addr): Likewise.
        * simplifx-rtx.c (delegitimize_mem_from_attrs): Likewise.
        * tsan.c (instrument_expr): Likewise.
        * ubsan.c (instrument_bool_enum_load, instrument_object_size): Likewise.
        * tree.c (verify_type_variant): Remove handling of TYPE_ALIGN_OK.
        * tree-affine.c (tree_to_aff_combination,
        get_inner_reference_aff): Adjust calls to get_inner_reference.
        * tree-data-ref.c (split_constant_offset_1,
        dr_analyze_innermost): Likewise.
        * tree-scalar-evolution.c (interpret_rhs_expr): Likewise.
        * tree-sra.c (ipa_sra_check_caller): Likewise.
        * tree-ssa-loop-ivopts.c (split_address_cost): Likewise.
        * tree-ssa-math-opts.c (find_bswap_or_nop_load,
        bswap_replace): Likewise.
        * tree-vect-data-refs.c (vect_check_gather,
        vect_analyze_data_refs): Likewise.
        * config/mips/mips.c (r10k_safe_mem_expr_p): Likewise.
        * config/pa/pa.c (pa_emit_move_sequence): Remove handling of
        TYPE_ALIGN_OK.

ada:
2016-07-11  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        Convert TYPE_ALIGN_OK to a TYPE_LANG_FLAG.
        * gcc-interface/ada-tree.h (TYPE_ALIGN_OK): Define.
        * gcc-interface/trans.c (Attribute_to_gnu): Adjust call to
        get_inner_reference.
        * gcc-interface/utils2.c (build_unary_op): Likewise.

From-SVN: r238210
2016-07-11 15:02:12 +00:00
Jakub Jelinek 2a5537c3e2 re PR c++/71739 (ICE on valid C++11 code: tree check: expected identifier_node, have tree_list in private_is_attribute_p, at tree.c:6080)
PR c++/71739
	* tree.c (attribute_value_equal): Use get_attribute_name instead of
	directly using TREE_PURPOSE.

	* g++.dg/cpp0x/pr71739.C: New test.

From-SVN: r237991
2016-07-04 19:31:38 +02:00
Eric Botcazou d42b755992 tree.c (verify_type_variant): Skip TYPE_SIZE and TYPE_SIZE_UNIT if they are both PLACEHOLDER_EXPRs.
* tree.c (verify_type_variant): Skip TYPE_SIZE and TYPE_SIZE_UNIT if
	they are both PLACEHOLDER_EXPRs.
ada/
	* gcc-interface/decl.c (set_nonaliased_component_on_array_type): New
	function.
	(set_reverse_storage_order_on_array_type): Likewise.
	(gnat_to_gnu_entity) <E_Array_Type>: Call them to set the flags.
	<E_Array_Subtype>: Likewise.
	<E_String_Literal_Subtype>: Likewise.
	(substitute_in_type) <ARRAY_TYPE>: Likewise.
	* gcc-interface/utils.c (gnat_pushdecl): Always create a variant for
	the DECL_ORIGINAL_TYPE of a type.

From-SVN: r237658
2016-06-21 21:34:12 +00:00
Michael Meissner 5cd0a74a91 stor-layout.c (layout_type): Move setting complex MODE to layout_type...
[gcc]
2016-06-21  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* stor-layout.c (layout_type): Move setting complex MODE to
	layout_type, instead of setting it ahead of time by the caller.
	* tree.c (build_complex_type): Likewise.

[gcc/fortran]
2016-06-21  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* trans-types.c (gfc_build_complex_type): Move setting complex
	MODE to layout_type, instead of setting it ahead of time by the
	caller.

From-SVN: r237657
2016-06-21 20:57:20 +00:00
David Malcolm d9b950dd44 Selftest framework
gcc/ChangeLog:
	* Makefile.in (OBJS): Add function-tests.o,
	hash-map-tests.o, hash-set-tests.o, rtl-tests.o,
	selftest-run-tests.o.
	(OBJS-libcommon): Add selftest.o.
	(OBJS-libcommon-target): Add selftest.o.
	(all.internal): Add "selftest".
	(all.cross): Likewise.
	(selftest): New phony target.
	(s-selftest): New target.
	(selftest-gdb): New phony target.
	(COLLECT2_OBJS): Add selftest.o.
	* bitmap.c: Include "selftest.h".
	(selftest::test_gc_alloc): New function.
	(selftest::test_set_range): New function.
	(selftest::test_clear_bit_in_middle): New function.
	(selftest::test_copying): New function.
	(selftest::test_bitmap_single_bit_set_p): New function.
	(selftest::bitmap_c_tests): New function.
	* common.opt (fself-test): New.
	* diagnostic-show-locus.c: Include "selftest.h".
	(make_range): New function.
	(test_range_contains_point_for_single_point): New function.
	(test_range_contains_point_for_single_line): New function.
	(test_range_contains_point_for_multiple_lines): New function.
	(assert_eq): New function.
	(test_get_line_width_without_trailing_whitespace): New function.
	(selftest::diagnostic_show_locus_c_tests): New function.
	* et-forest.c: Include "selftest.h".
	(selftest::test_single_node): New function.
	(selftest::test_simple_tree): New function.
	(selftest::test_disconnected_nodes): New function.
	(selftest::et_forest_c_tests): New function.
	* fold-const.c: Include "selftest.h".
	(selftest::assert_binop_folds_to_const): New function.
	(selftest::assert_binop_folds_to_nonlvalue): New function.
	(selftest::test_arithmetic_folding): New function.
	(selftest::fold_const_c_tests): New function.
	* function-tests.c: New file.
	* gimple.c: Include "selftest.h".
	Include "gimple-pretty-print.h".
	(selftest::verify_gimple_pp): New function.
	(selftest::test_assign_single): New function.
	(selftest::test_assign_binop): New function.
	(selftest::test_nop_stmt): New function.
	(selftest::test_return_stmt): New function.
	(selftest::test_return_without_value): New function.
	(selftest::gimple_c_tests): New function.
	* hash-map-tests.c: New file.
	* hash-set-tests.c: New file.
	* input.c: Include "selftest.h".
	(selftest::assert_loceq): New function.
	(selftest::test_accessing_ordinary_linemaps): New function.
	(selftest::test_unknown_location): New function.
	(selftest::test_builtins): New function.
	(selftest::test_reading_source_line): New function.
	(selftest::input_c_tests): New function.
	* rtl-tests.c: New file.
	* selftest-run-tests.c: New file.
	* selftest.c: New file.
	* selftest.h: New file.
	* spellcheck.c: Include "selftest.h".
	(selftest::levenshtein_distance_unit_test_oneway): New function,
	adapted from testsuite/gcc.dg/plugin/levenshtein_plugin.c.
	(selftest::levenshtein_distance_unit_test): Likewise.
	(selftest::spellcheck_c_tests): Likewise.
	* toplev.c: Include selftest.h.
	(toplev::run_self_tests): New.
	(toplev::main): Handle -fself-test.
	* toplev.h (toplev::run_self_tests): New.
	* tree.c: Include "selftest.h".
	(selftest::test_integer_constants): New function.
	(selftest::test_identifiers): New function.
	(selftest::test_labels): New function.
	(selftest::tree_c_tests): New function.
	* tree-cfg.c: Include "selftest.h".
	(selftest::push_fndecl): New function.
	(selftest::test_linear_chain): New function.
	(selftest::test_diamond): New function.
	(selftest::test_fully_connected): New function.
	(selftest::tree_cfg_c_tests): New function.
	* vec.c: Include "selftest.h".
	(selftest::safe_push_range): New function.
	(selftest::test_quick_push): New function.
	(selftest::test_safe_push): New function.
	(selftest::test_truncate): New function.
	(selftest::test_safe_grow_cleared): New function.
	(selftest::test_pop): New function.
	(selftest::test_safe_insert): New function.
	(selftest::test_ordered_remove): New function.
	(selftest::test_unordered_remove): New function.
	(selftest::test_block_remove): New function.
	(selftest::reverse_cmp): New function.
	(selftest::test_qsort): New function.
	(selftest::vec_c_tests): New function.c.
	* wide-int.cc: Include selftest.h and wide-int-print.h.
	(selftest::from_int <wide_int>): New function.
	(selftest::from_int <offset_int>): New function.
	(selftest::from_int <widest_int>): New function.
	(selftest::assert_deceq): New function.
	(selftest::assert_hexeq): New function.
	(selftest::test_printing <VALUE_TYPE>): New function template.
	(selftest::test_ops <VALUE_TYPE>): New function template.
	(selftest::test_comparisons <VALUE_TYPE>): New function template.
	(selftest::run_all_wide_int_tests <VALUE_TYPE>): New function
	template.
	(selftest::wide_int_cc_tests): New function.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/levenshtein-test-1.c: Delete.
	* gcc.dg/plugin/levenshtein_plugin.c: Delete.
	* gcc.dg/plugin/plugin.exp (plugin_test_list): Remove the
	above.

From-SVN: r237144
2016-06-06 17:11:30 +00:00
Bernd Schmidt 36b85e4328 re PR tree-optimization/52171 (memcmp/strcmp/strncmp can be optimized when the result is tested for [in]equality with 0)
PR tree-optimization/52171
        * builtins.c (expand_cmpstrn_or_cmpmem): Delete, moved elsewhere.
        (expand_builtin_memcmp): New arg RESULT_EQ.  All callers changed.
        Look for constant strings.  Move some code to emit_block_cmp_hints
        and use it.
        * builtins.def (BUILT_IN_MEMCMP_EQ): New.
        * defaults.h (COMPARE_MAX_PIECES): New macro.
        * expr.c (move_by_pieces_d, store_by_pieces_d): Remove old structs.
        (move_by_pieces_1, store_by_pieces_1, store_by_pieces_2): Remvoe.
        (clear_by_pieces_1): Don't declare.  Move definition before use.
        (can_do_by_pieces): New static function.
        (can_move_by_pieces): Use it.  Return bool.
        (by_pieces_ninsns): Renamed from move_by_pieces_ninsns.  New arg
        OP.  All callers changed.  Handle COMPARE_BY_PIECES.
        (class pieces_addr); New.
        (pieces_addr::pieces_addr, pieces_addr::decide_autoinc,
        pieces_addr::adjust, pieces_addr::increment_address,
        pieces_addr::maybe_predec, pieces_addr::maybe_postinc): New member
        functions for it.
        (class op_by_pieces_d): New.
        (op_by_pieces_d::op_by_pieces_d, op_by_pieces_d::run): New member
        functions for it.
        (class move_by_pieces_d, class compare_by_pieces_d,
        class store_by_pieces_d): New subclasses of op_by_pieces_d.
        (move_by_pieces_d::prepare_mode, move_by_pieces_d::generate,
        move_by_pieces_d::finish_endp, store_by_pieces_d::prepare_mode,
        store_by_pieces_d::generate, store_by_pieces_d::finish_endp,
        compare_by_pieces_d::generate, compare_by_pieces_d::prepare_mode,
        compare_by_pieces_d::finish_mode): New member functions.
        (compare_by_pieces, emit_block_cmp_via_cmpmem): New static
        functions.
        (expand_cmpstrn_or_cmpmem): Moved here from builtins.c.
        (emit_block_cmp_hints): New function.
        (move_by_pieces, store_by_pieces, clear_by_pieces): Rewrite to just
        use the newly defined classes.
        * expr.h (by_pieces_constfn): New typedef.
        (can_store_by_pieces, store_by_pieces): Use it in arg declarations.
        (emit_block_cmp_hints, expand_cmpstrn_or_cmpmem): Declare.
        (move_by_pieces_ninsns): Don't declare.
        (can_move_by_pieces): Change return value to bool.
        * target.def (TARGET_USE_BY_PIECES_INFRASTRUCTURE_P): Update docs.
        (compare_by_pieces_branch_ratio): New hook.
        * target.h (enum by_pieces_operation): Add COMPARE_BY_PIECES.
        (by_pieces_ninsns): Declare.
        * targethooks.c (default_use_by_pieces_infrastructure_p): Handle
        COMPARE_BY_PIECES.
        (default_compare_by_pieces_branch_ratio): New function.
        * targhooks.h (default_compare_by_pieces_branch_ratio): Declare.
        * doc/tm.texi.in (STORE_MAX_PIECES, COMPARE_MAX_PIECES): Document.
        * doc/tm.texi: Regenerate.
        * tree-ssa-strlen.c: Include "builtins.h".
        (handle_builtin_memcmp): New static function.
        (strlen_optimize_stmt): Call it for BUILT_IN_MEMCMP.
        * tree.c (build_common_builtin_nodes): Create __builtin_memcmp_eq.

testsuite/
        PR tree-optimization/52171
        * gcc.dg/pr52171.c: New test.
        * gcc.target/i386/pr52171.c: New test.

From-SVN: r237069
2016-06-03 14:20:53 +00:00
Thomas Schwinge 268143a480 Remove the unused OMP_CLAUSE_DEVICE_RESIDENT
gcc/
	* tree-core.h (enum omp_clause_code): Remove
	OMP_CLAUSE_DEVICE_RESIDENT.  Adjust all users.

From-SVN: r236985
2016-06-01 13:55:35 +02:00
Martin Liska 6aa1abe5f2 re PR tree-optimization/71239 (ICE in operand_equal_p (fold-const.c:2769))
Fix PR tree-optimization/71239.

	* g++.dg/pr71239.C: New test.
	PR tree-optimization/71239
	* tree.c (array_at_struct_end_p): Do not call operand_equal_p
	if DECL_SIZE is NULL.

From-SVN: r236696
2016-05-25 09:10:16 +00:00