Commit Graph

753 Commits

Author SHA1 Message Date
Martin Liska fdd38d7ec3 Backport r254524
2017-11-21  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-11-08  Martin Liska  <mliska@suse.cz>

	* gimplify.c (expand_FALLTHROUGH_r): Simplify usage
	of gimple_call_internal_p.

From-SVN: r255012
2017-11-21 16:02:04 +00:00
Martin Liska 20dda3e716 Backport r254519
2017-11-21  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-11-08  Martin Liska  <mliska@suse.cz>

	PR sanitizer/82792
	* gimplify.c (expand_FALLTHROUGH_r): Skip IFN_ASAN_MARK.
2017-11-21  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-11-08  Martin Liska  <mliska@suse.cz>

	PR sanitizer/82792
	* g++.dg/asan/pr82792.C: New test.

From-SVN: r255011
2017-11-21 16:01:43 +00:00
Jakub Jelinek 4eb003869d backport: re PR c++/82159 (ICE: in assign_temp, at function.c:961)
Backported from mainline
	2017-09-27  Jakub Jelinek  <jakub@redhat.com>

	PR c++/82159
	* gimplify.c (gimplify_modify_expr): Don't optimize away zero sized
	lhs from calls if the lhs has addressable type.

	* g++.dg/opt/pr82159.C: New test.

From-SVN: r253318
2017-09-30 10:25:02 +02:00
Martin Liska ccefbdd7ef Backport r249368
2017-06-22  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-06-19  Martin Liska  <mliska@suse.cz>

	PR sanitizer/80879
	* gimplify.c (gimplify_switch_expr):
	Initialize live_switch_vars for SWITCH_BODY == STATEMENT_LIST.
2017-06-22  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-06-19  Martin Liska  <mliska@suse.cz>

	PR sanitizer/80879
	* gcc.dg/asan/use-after-scope-switch-4.c: New test.

From-SVN: r249551
2017-06-22 11:41:09 +00:00
Jakub Jelinek 8887fa1078 re PR c++/81130 (ICE OpenMP shared clause in gimplify_var_or_parm_decl, at gimplify.c:2584)
PR c++/81130
	* gimplify.c (omp_add_variable): Don't force GOVD_SEEN for types
	with ctors/dtors if GOVD_SHARED is set.

	* testsuite/libgomp.c++/pr81130.C: New test.

From-SVN: r249482
2017-06-22 00:19:38 +02:00
Jakub Jelinek e8f1beb231 backport: re PR middle-end/80809 (Multi-free error for variable size array used within OpenMP task)
Backported from mainline
	2017-05-22  Jakub Jelinek  <jakub@redhat.com>
 
	PR middle-end/80809
	* gimplify.c (omp_add_variable): For GOVD_DEBUG_PRIVATE use
	GOVD_SHARED rather than GOVD_PRIVATE with it.
	(gimplify_adjust_omp_clauses_1, gimplify_adjust_omp_clauses): Expect
	GOVD_SHARED rather than GOVD_PRIVATE with GOVD_DEBUG_PRIVATE.

	* testsuite/libgomp.c/pr80809-1.c: New test.

From-SVN: r248487
2017-05-26 12:13:34 +02:00
Richard Biener cd7fac9613 re PR tree-optimization/80344 (-Wuninitialized triggering on a ctor on ARM)
2017-04-10  Richard Biener  <rguenther@suse.de>

	PR middle-end/80344
	* gimplify.c (is_gimple_mem_rhs_or_call): Allow CLOBBERs.

From-SVN: r246800
2017-04-10 08:58:02 +00:00
Jakub Jelinek 724d25f353 re PR translation/80189 (gimplify.c: check whether parallel/task/teams should be translated)
PR translation/80189
	* gimplify.c (omp_default_clause): Use %qs instead of %s in
	diagnostic messages.
testsuite/
	* g++.dg/gomp/predetermined-1.C: Adjust expected diagnostics.
	* g++.dg/gomp/sharing-1.C: Likewise.
	* gfortran.dg/gomp/pr44536.f90: Likewise.
	* gfortran.dg/gomp/pr44036-1.f90: Likewise.
	* gfortran.dg/gomp/sharing-3.f90: Likewise.
	* gfortran.dg/gomp/crayptr3.f90: Likewise.
	* gfortran.dg/gomp/pr33439.f90: Likewise.
	* gfortran.dg/gomp/appendix-a/a.24.1.f90: Likewise.
	* gfortran.dg/gomp/sharing-1.f90: Likewise.
	* gfortran.dg/gomp/sharing-2.f90: Likewise.
	* gcc.dg/gomp/appendix-a/a.24.1.c: Likewise.
	* gcc.dg/gomp/sharing-1.c: Likewise.

From-SVN: r246599
2017-03-30 22:31:40 +02:00
Richard Biener cda4d053eb re PR tree-optimization/80032 (C++ excessive stack usage (no stack reuse))
2017-03-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/80032
	* gimplify.c (gimple_push_cleanup): Forced unconditional
	cleanups still have to go to the conditional_cleanups
	sequence.

From-SVN: r246414
2017-03-23 08:33:41 +00:00
Jakub Jelinek 68ed2ba0a7 re PR c++/80129 (wrong code with ternary struct assignment to const)
PR c++/80129
	* gimplify.c (gimplify_modify_expr_rhs) <case COND_EXPR>: Clear
	TREE_READONLY on result if writing it more than once.

	* g++.dg/torture/pr80129.C: New test.

From-SVN: r246401
2017-03-22 19:45:48 +01:00
Cesar Philippidis 7ba8651ed2 re PR c++/80029 (valgrind error in new_omp_context(omp_region_type) (gimplify.c:400))
PR c++/80029

	gcc/
	* gimplify.c (is_oacc_declared): New function.
	(oacc_default_clause): Use it to set default flags for acc declared
	variables inside parallel regions.
	(gimplify_scan_omp_clauses): Strip firstprivate pointers for acc
	declared variables.
	(gimplify_oacc_declare): Gimplify the declare clauses.  Add the
	declare attribute to any decl as necessary.

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/declare-vla.c: New test.

From-SVN: r246381
2017-03-22 06:52:10 -07:00
Richard Biener e650ea2a5e re PR tree-optimization/80032 (C++ excessive stack usage (no stack reuse))
2017-03-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/80032
	* gimplify.c (gimple_push_cleanup): Add force_uncond parameter,
	if set force the cleanup to happen unconditionally.
	(gimplify_target_expr): Push inserted clobbers with force_uncond
	to avoid them being removed by control-dependent DCE.

	* g++.dg/opt/pr80032.C: New testcase.

From-SVN: r246314
2017-03-21 11:43:45 +00:00
Jakub Jelinek eebc5e2dde re PR c/79940 (OpenMP pragma - internal compiler error with taskloop)
PR c/79940
	* gimplify.c (gimplify_omp_for): Replace index var in outer
	taskloop statement with an artificial variable and add
	OMP_CLAUSE_PRIVATE clause for it.

	* testsuite/libgomp.c/pr79940.c: New test.

From-SVN: r245980
2017-03-08 18:21:06 +01:00
Marek Polacek 80480ceee9 re PR middle-end/79537 (ICE in gimplify_expr, at gimplify.c:12009)
PR middle-end/79537
	* gimplify.c (gimplify_expr): Handle unused *&&L;.

	* gcc.dg/comp-goto-4.c: New.

From-SVN: r245604
2017-02-20 15:05:53 +00:00
Jakub Jelinek 56f7147848 re PR c/79431 (ICE in get, at cgraph.h:397)
PR c/79431
	* gimplify.c (gimplify_adjust_omp_clauses): Ignore
	"omp declare target link" attribute unless is_global_var.
	* omp-offload.c (find_link_var_op): Likewise.
c/
	* c-parser.c (c_parser_omp_declare_target): Don't invoke
	symtab_node::get on automatic variables.
cp/
	* parser.c (cp_parser_oacc_declare): Formatting fix.
	(cp_parser_omp_declare_target): Don't invoke symtab_node::get on
	automatic variables.
testsuite/
	* c-c++-common/gomp/pr79431.c: New test.

From-SVN: r245302
2017-02-09 15:01:44 +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
David Sherwood ebff5c3f80 re PR middle-end/79212 (internal compiler error: in maybe_lookup_decl_in_outer_ctx, at omp-low.c:4134)
2017-01-26  David Sherwood  <david.sherwood@arm.com>

    gcc/
	PR middle-end/79212
	* gimplify.c (omp_notice_variable): Add GOVD_SEEN flag to variables in
	all contexts.

    gcc/testsuite/
	PR middle-end/79212
	* gfortran.dg/gomp/sharing-4.f90: New test.

From-SVN: r244922
2017-01-26 10:41:35 +00:00
Martin Liska f6b9f2ffc1 use-after-scope: handle writes to a poisoned variable
2017-01-23  Martin Liska  <mliska@suse.cz>

	* gcc.dg/asan/use-after-scope-10.c: New test.
	* gcc.dg/asan/use-after-scope-11.c: New test.
	* g++.dg/asan/use-after-scope-5.C: New test.
2017-01-23  Jakub Jelinek  <jakub@redhat.com>
	    Martin Liska  <mliska@suse.cz>

	* asan.h: Define ASAN_USE_AFTER_SCOPE_ATTRIBUTE.
	* asan.c (asan_expand_poison_ifn): Support stores and use
	appropriate ASAN report function.
	* internal-fn.c (expand_ASAN_POISON_USE): New function.
	* internal-fn.def (ASAN_POISON_USE): Declare.
	* tree-into-ssa.c (maybe_add_asan_poison_write): New function.
	(maybe_register_def): Create ASAN_POISON_USE when sanitizing.
	* tree-ssa-dce.c (eliminate_unnecessary_stmts): Remove
	ASAN_POISON calls w/o LHS.
	* tree-ssa.c (execute_update_addresses_taken): Create clobber
	for ASAN_MARK (UNPOISON, &x, ...) in order to prevent usage of a LHS
	from ASAN_MARK (POISON, &x, ...) coming to a PHI node.
	* gimplify.c (asan_poison_variables): Add attribute
	use_after_scope_memory to variables that really needs to live
	in memory.
	* tree-ssa.c (is_asan_mark_p): Do not rewrite into SSA when
	having the attribute.

From-SVN: r244793
2017-01-23 12:06:13 +00:00
Marek Polacek d2aadab150 re PR c/79152 (-Wimplicit-fallthrough false positive triggered by goto statements)
PR c/79152
	* gimplify.c (should_warn_for_implicit_fallthrough): Handle consecutive
	non-case labels.

	* c-c++-common/Wimplicit-fallthrough-35.c: New test.

From-SVN: r244726
2017-01-20 16:28:16 +00:00
Jakub Jelinek 98e92fb210 re PR middle-end/79089 (error: incorrect sharing of tree nodes)
PR c/79089
	* gimplify.c (gimplify_init_constructor): If want_value and
	object == lhs, unshare lhs to avoid invalid tree sharing.  Formatting
	fix.

	* gcc.c-torture/compile/pr79089.c: New test.

From-SVN: r244507
2017-01-16 22:35:30 +01:00
Martin Liska 6ff9249717 Do not sanitize in an abnormal context (PR sanitizer/78815).
2017-01-05  Martin Liska  <mliska@suse.cz>

	PR sanitizer/78815
	* gimplify.c (gimplify_decl_expr): Compare to
	asan_poisoned_variables instread of checking flags.
	(gimplify_target_expr): Likewise.
	(gimplify_expr): Likewise.
	(gimplify_function_tree): Conditionally initialize
	asan_poisoned_variables.

From-SVN: r244095
2017-01-05 09:16:50 +00:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Martin Jambor 629b3d75c8 Split omp-low into multiple files
2016-12-14  Martin Jambor  <mjambor@suse.cz>

	* omp-general.h: New file.
	* omp-general.c: New file.
	* omp-expand.h: Likewise.
	* omp-expand.c: Likewise.
	* omp-offload.h: Likewise.
	* omp-offload.c: Likewise.
	* omp-grid.c: Likewise.
	* omp-grid.c: Likewise.
	* omp-low.h: Include omp-general.h and omp-grid.h.  Removed includes
	of params.h, symbol-summary.h, lto-section-names.h, cilk.h, tree-eh.h,
	ipa-prop.h, tree-cfgcleanup.h, cfgloop.h, except.h, expr.h, stmt.h,
	varasm.h, calls.h, explow.h, dojump.h, flags.h, tree-into-ssa.h,
	tree-cfg.h, cfganal.h, alias.h, emit-rtl.h, optabs.h, expmed.h,
	alloc-pool.h, cfghooks.h, rtl.h and memmodel.h.
	(omp_find_combined_for): Declare.
	(find_omp_clause): Renamed to omp_find_clause and moved to
	omp-general.h.
	(free_omp_regions): Renamed to omp_free_regions and moved to
	omp-expand.h.
	(replace_oacc_fn_attrib): Renamed to oacc_replace_fn_attrib and moved
	to omp-general.h.
	(set_oacc_fn_attrib): Renamed to oacc_set_fn_attrib and moved to
	omp-general.h.
	(build_oacc_routine_dims): Renamed to oacc_build_routine_dims and
	moved to omp-general.h.
	(get_oacc_fn_attrib): Renamed to oacc_get_fn_attrib and moved to
	omp-general.h.
	(oacc_fn_attrib_kernels_p): Moved to omp-general.h.
	(get_oacc_fn_dim_size): Renamed to oacc_get_fn_dim_size and moved to
	omp-general.c.
	(omp_expand_local): Moved to omp-expand.h.
	(make_gimple_omp_edges): Renamed to omp_make_gimple_edges and moved to
	omp-expand.h.
	(omp_finish_file): Moved to omp-offload.h.
	(default_goacc_validate_dims): Renamed to
	oacc_default_goacc_validate_dims and moved to omp-offload.h.
	(offload_funcs, offload_vars): Moved to omp-offload.h.
	* omp-low.c: Include omp-general.h, omp-offload.h and omp-grid.h.
	(omp_region): Moved to omp-expand.c.
	(omp_for_data_loop): Moved to omp-general.h.
	(omp_for_data): Likewise.
	(oacc_loop): Moved to omp-offload.c.
	(oacc_loop_flags): Moved to omp-general.h.
	(offload_funcs, offload_vars): Moved to omp-offload.c.
	(root_omp_region): Moved to omp-expand.c.
	(omp_any_child_fn_dumped): Likewise.
	(find_omp_clause): Renamed to omp_find_clause and moved to
	omp-general.c.
	(is_combined_parallel): Moved to omp-expand.c.
	(is_reference): Renamed to omp_is_reference and and moved to
	omp-general.c.
	(adjust_for_condition): Renamed to omp_adjust_for_condition and moved
	to omp-general.c.
	(get_omp_for_step_from_incr): Renamed to omp_get_for_step_from_incr
	and moved to omp-general.c.
	(extract_omp_for_data): Renamed to omp_extract_for_data and moved to
	omp-general.c.
	(workshare_safe_to_combine_p): Moved to omp-expand.c.
	(omp_adjust_chunk_size): Likewise.
	(get_ws_args_for): Likewise.
	(get_base_type): Removed.
	(dump_omp_region): Moved to omp-expand.c.
	(debug_omp_region): Likewise.
	(debug_all_omp_regions): Likewise.
	(new_omp_region): Likewise.
	(free_omp_region_1): Likewise.
	(free_omp_regions): Renamed to omp_free_regions and moved to
	omp-expand.c.
	(find_combined_for): Renamed to omp_find_combined_for, made global.
	(build_omp_barrier): Renamed to omp_build_barrier and moved to
	omp-general.c.
	(omp_max_vf): Moved to omp-general.c.
	(omp_max_simt_vf): Likewise.
	(gimple_build_cond_empty): Moved to omp-expand.c.
	(parallel_needs_hsa_kernel_p): Likewise.
	(expand_omp_build_assign): Moved declaration to omp-expand.c.
	(expand_parallel_call): Moved to omp-expand.c.
	(expand_cilk_for_call): Likewise.
	(expand_task_call): Likewise.
	(vec2chain): Likewise.
	(remove_exit_barrier): Likewise.
	(remove_exit_barriers): Likewise.
	(optimize_omp_library_calls): Likewise.
	(expand_omp_regimplify_p): Likewise.
	(expand_omp_build_assign): Likewise.
	(expand_omp_taskreg): Likewise.
	(oacc_collapse): Likewise.
	(expand_oacc_collapse_init): Likewise.
	(expand_oacc_collapse_vars): Likewise.
	(expand_omp_for_init_counts): Likewise.
	(expand_omp_for_init_vars): Likewise.
	(extract_omp_for_update_vars): Likewise.
	(expand_omp_ordered_source): Likewise.
	(expand_omp_ordered_sink): Likewise.
	(expand_omp_ordered_source_sink): Likewise.
	(expand_omp_for_ordered_loops): Likewise.
	(expand_omp_for_generic): Likewise.
	(expand_omp_for_static_nochunk): Likewise.
	(find_phi_with_arg_on_edge): Likewise.
	(expand_omp_for_static_chunk): Likewise.
	(expand_cilk_for): Likewise.
	(expand_omp_simd): Likewise.
	(expand_omp_taskloop_for_outer): Likewise.
	(expand_omp_taskloop_for_inner): Likewise.
	(expand_oacc_for): Likewise.
	(expand_omp_for): Likewise.
	(expand_omp_sections): Likewise.
	(expand_omp_single): Likewise.
	(expand_omp_synch): Likewise.
	(expand_omp_atomic_load): Likewise.
	(expand_omp_atomic_store): Likewise.
	(expand_omp_atomic_fetch_op): Likewise.
	(expand_omp_atomic_pipeline): Likewise.
	(expand_omp_atomic_mutex): Likewise.
	(expand_omp_atomic): Likewise.
	(oacc_launch_pack): and moved to omp-general.c, made public.
	(OACC_FN_ATTRIB): Likewise.
	(replace_oacc_fn_attrib): Renamed to oacc_replace_fn_attrib and moved
	to omp-general.c.
	(set_oacc_fn_attrib): Renamed to oacc_set_fn_attrib and moved to
	omp-general.c.
	(build_oacc_routine_dims): Renamed to oacc_build_routine_dims and
	moved to omp-general.c.
	(get_oacc_fn_attrib): Renamed to oacc_get_fn_attrib and moved to
	omp-general.c.
	(oacc_fn_attrib_kernels_p): Moved to omp-general.c.
	(oacc_fn_attrib_level): Moved to omp-offload.c.
	(get_oacc_fn_dim_size): Renamed to oacc_get_fn_dim_size and moved to
	omp-general.c.
	(get_oacc_ifn_dim_arg): Renamed to oacc_get_ifn_dim_arg and moved to
	omp-general.c.
	(mark_loops_in_oacc_kernels_region): Moved to omp-expand.c.
	(grid_launch_attributes_trees): Likewise.
	(grid_attr_trees): Likewise.
	(grid_create_kernel_launch_attr_types): Likewise.
	(grid_insert_store_range_dim): Likewise.
	(grid_get_kernel_launch_attributes): Likewise.
	(get_target_argument_identifier_1): Likewise.
	(get_target_argument_identifier): Likewise.
	(get_target_argument_value): Likewise.
	(push_target_argument_according_to_value): Likewise.
	(get_target_arguments): Likewise.
	(expand_omp_target): Likewise.
	(grid_expand_omp_for_loop): Moved to omp-grid.c.
	(grid_arg_decl_map): Likewise.
	(grid_remap_kernel_arg_accesses): Likewise.
	(grid_expand_target_grid_body): Likewise.
	(expand_omp): Renamed to omp_expand and moved to omp-expand.c.
	(build_omp_regions_1): Moved to omp-expand.c.
	(build_omp_regions_root): Likewise.
	(omp_expand_local): Likewise.
	(build_omp_regions): Likewise.
	(execute_expand_omp): Likewise.
	(pass_data_expand_omp): Likewise.
	(pass_expand_omp): Likewise.
	(make_pass_expand_omp): Likewise.
	(pass_data_expand_omp_ssa): Likewise.
	(pass_expand_omp_ssa): Likewise.
	(make_pass_expand_omp_ssa): Likewise.
	(grid_lastprivate_predicate): Renamed to
	omp_grid_lastprivate_predicate and moved to omp-grid.c, made public.
	(grid_prop): Moved to omp-grid.c.
	(GRID_MISSED_MSG_PREFIX): Likewise.
	(grid_safe_assignment_p): Likewise.
	(grid_seq_only_contains_local_assignments): Likewise.
	(grid_find_single_omp_among_assignments_1): Likewise.
	(grid_find_single_omp_among_assignments): Likewise.
	(grid_find_ungridifiable_statement): Likewise.
	(grid_parallel_clauses_gridifiable): Likewise.
	(grid_inner_loop_gridifiable_p): Likewise.
	(grid_dist_follows_simple_pattern): Likewise.
	(grid_gfor_follows_tiling_pattern): Likewise.
	(grid_call_permissible_in_distribute_p): Likewise.
	(grid_handle_call_in_distribute): Likewise.
	(grid_dist_follows_tiling_pattern): Likewise.
	(grid_target_follows_gridifiable_pattern): Likewise.
	(grid_remap_prebody_decls): Likewise.
	(grid_var_segment): Likewise.
	(grid_mark_variable_segment): Likewise.
	(grid_copy_leading_local_assignments): Likewise.
	(grid_process_grid_body): Likewise.
	(grid_eliminate_combined_simd_part): Likewise.
	(grid_mark_tiling_loops): Likewise.
	(grid_mark_tiling_parallels_and_loops): Likewise.
	(grid_process_kernel_body_copy): Likewise.
	(grid_attempt_target_gridification): Likewise.
	(grid_gridify_all_targets_stmt): Likewise.
	(grid_gridify_all_targets): Renamed to omp_grid_gridify_all_targets
	and moved to omp-grid.c, made public.
	(make_gimple_omp_edges): Renamed to omp_make_gimple_edges and moved to
	omp-expand.c.
	(add_decls_addresses_to_decl_constructor): Moved to omp-offload.c.
	(omp_finish_file): Likewise.
	(oacc_thread_numbers): Likewise.
	(oacc_xform_loop): Likewise.
	(oacc_default_dims, oacc_min_dims): Likewise.
	(oacc_parse_default_dims): Likewise.
	(oacc_validate_dims): Likewise.
	(new_oacc_loop_raw): Likewise.
	(new_oacc_loop_outer): Likewise.
	(new_oacc_loop): Likewise.
	(new_oacc_loop_routine): Likewise.
	(finish_oacc_loop): Likewise.
	(free_oacc_loop): Likewise.
	(dump_oacc_loop_part): Likewise.
	(dump_oacc_loop): Likewise.
	(debug_oacc_loop): Likewise.
	(oacc_loop_discover_walk): Likewise.
	(oacc_loop_sibling_nreverse): Likewise.
	(oacc_loop_discovery): Likewise.
	(oacc_loop_xform_head_tail): Likewise.
	(oacc_loop_xform_loop): Likewise.
	(oacc_loop_process): Likewise.
	(oacc_loop_fixed_partitions): Likewise.
	(oacc_loop_auto_partitions): Likewise.
	(oacc_loop_partition): Likewise.
	(default_goacc_fork_join): Likewise.
	(default_goacc_reduction): Likewise.
	(execute_oacc_device_lower): Likewise.
	(default_goacc_validate_dims): Likewise.
	(default_goacc_dim_limit): Likewise.
	(pass_data_oacc_device_lower): Likewise.
	(pass_oacc_device_lower): Likewise.
	(make_pass_oacc_device_lower): Likewise.
	(execute_omp_device_lower): Likewise.
	(pass_data_omp_device_lower): Likewise.
	(pass_omp_device_lower): Likewise.
	(make_pass_omp_device_lower): Likewise.
	(pass_data_omp_target_link): Likewise.
	(pass_omp_target_link): Likewise.
	(find_link_var_op): Likewise.
	(pass_omp_target_link::execute): Likewise.
	(make_pass_omp_target_link): Likewise.

	* Makefile.in (OBJS): Added omp-offload.o, omp-expand.o, omp-general.o
	and omp-grid.o.
	(GTFILES): Added omp-offload.h, omp-offload.c and omp-expand.c, removed
	omp-low.h.
	* gimple-fold.c: Include omp-general.h instead of omp-low.h.
	(fold_internal_goacc_dim): Adjusted calls to
	get_oacc_ifn_dim_arg and get_oacc_fn_dim_size to use their new names.
	* gimplify.c: Include omp-low.h.
	(omp_notice_variable): Adjust the call to get_oacc_fn_attrib to use
	its new name.
	(gimplify_omp_task): Adjusted calls to find_omp_clause to use its new
	name.
	(gimplify_omp_for): Likewise.
	* lto-cgraph.c: Include omp-offload.h instead of omp-low.h.
	* toplev.c: Include omp-offload.h instead of omp-low.h.
	* tree-cfg.c: Include omp-general.h instead of omp-low.h.  Also
	include omp-expand.h.
	(make_edges_bb): Adjusted the call to make_gimple_omp_edges to use its
	new name.
	(make_edges): Adjust the call to free_omp_regions to use its new name.
	* tree-parloops.c: Include omp-general.h.
	(create_parallel_loop): Adjusted the call to set_oacc_fn_attrib to use
	its new name.
	(parallelize_loops): Adjusted the call to get_oacc_fn_attrib to use
	its new name.
	* tree-ssa-loop.c: Include omp-general.h instead of omp-low.h.
	(gate_oacc_kernels): Adjusted the call to get_oacc_fn_attrib to use
	its new name.
	* tree-vrp.c: Include omp-general.h instead of omp-low.h.
	(extract_range_basic): Adjusted calls to get_oacc_ifn_dim_arg and
	get_oacc_fn_dim_size to use their new names.
	* varpool.c: Include omp-offload.h instead of omp-low.h.
	* gengtype.c (open_base_files): Replace omp-low.h with omp-offload.h in
	ifiles.
	* config/nvptx/nvptx.c: Include omp-general.c.
	(nvptx_expand_call): Adjusted the call to get_oacc_fn_attrib to use
	its new name.
	(nvptx_reorg): Likewise.
	(nvptx_record_offload_symbol): Likewise.

gcc/c-family:
	* c-omp.c: Include omp-general.h instead of omp-low.h.
	(c_finish_oacc_wait): Adjusted call to find_omp_clause to use its new
	name.

gcc/c/
	* c-parser.c: Include omp-general.h and omp-offload.h instead of
	omp-low.h.
	(c_finish_oacc_routine): Adjusted call to
	get_oacc_fn_attrib, build_oacc_routine_dims and replace_oacc_fn_attrib
	to use their new names.
	(c_parser_oacc_enter_exit_data): Adjusted call to find_omp_clause to
	use its new name.
	(c_parser_oacc_update): Likewise.
	(c_parser_omp_simd): Likewise.
	(c_parser_omp_target_update): Likewise.
	* c-typeck.c: Include omp-general.h instead of omp-low.h.
	(c_finish_omp_cancel): Adjusted call to find_omp_clause to use its new
	name.
	(c_finish_omp_cancellation_point): Likewise.
	* gimple-parser.c: Do not include omp-low.h

gcc/cp/
	* parser.c: Include omp-general.h and omp-offload.h instead of
	omp-low.h.
	(cp_parser_omp_simd): Adjusted calls to find_omp_clause to use its new
	name.
	(cp_parser_omp_target_update): Likewise.
	(cp_parser_oacc_declare): Likewise.
	(cp_parser_oacc_enter_exit_data): Likewise.
	(cp_parser_oacc_update): Likewise.
	(cp_finalize_oacc_routine): Adjusted call to get_oacc_fn_attrib,
	build_oacc_routine_dims and replace_oacc_fn_attrib to use their new
	names.
	* semantics.c: Include omp-general insteda of omp-low.h.
	(finish_omp_for): Adjusted calls to find_omp_clause to use its new
	name.
	(finish_omp_cancel): Likewise.
	(finish_omp_cancellation_point): Likewise.

fortran/
	* trans-openmp.c: Include omp-general.h.

From-SVN: r243673
2016-12-14 23:30:41 +01:00
Martin Liska 56b7aede91 Add pretty printer for ASAN_MARK and add a helper fn
* asan.c (asan_mark_poison_p): Remove.
	(asan_mark_p): New function.
	(transform_statements): Use the function.
	(asan_expand_mark_ifn): Do not use masked enum.
	* asan.h (enum asan_mark_flags): Declare it via a macro.
	* gimple-pretty-print.c (dump_gimple_call_args): Dump first
	argument of ASAN_MARK.
	* gimplify.c (build_asan_poison_call_expr): Use new enum values.
	(asan_poison_variable): Likewise.
	* gcc.dg/asan/use-after-scope-goto-1.c: Update first argument of
	scanned pattern ASAN_MARK.
	* gcc.dg/asan/use-after-scope-goto-2.c: Likewise.
	* gcc.dg/asan/use-after-scope-switch-1.c: Likewise.
	* gcc.dg/asan/use-after-scope-switch-2.c: Likewise.
	* gcc.dg/asan/use-after-scope-switch-3.c: Likewise.

From-SVN: r243597
2016-12-13 09:14:47 +00:00
Marek Polacek 3071bfa9c3 re PR middle-end/78716 (ICE in gimplify_va_arg_expr, at gimplify.c:12650 (i686-linux-gnu))
PR middle-end/78716
	* gimplify.c (gimplify_va_arg_expr): Don't require ADDR_EXPR for
	Case 1; check POINTER_TYPE_P instead.

	* g++.dg/other/vararg-5.C: New.

From-SVN: r243553
2016-12-12 13:57:32 +00:00
Richard Biener d964ba07c7 re PR middle-end/78333 (always-inline gnu-inline functions break -finstrument-functions)
2016-11-16  Richard Biener  <rguenther@suse.de>

	PR middle-end/78333
	* gimplify.c (gimplify_function_tree): Do not instrument
	GNU extern inline functions.

	* gcc.dg/pr78333.c: New testcase.

From-SVN: r242487
2016-11-16 12:55:02 +00:00
Martin Liska 080140bc85 Fix PR sanitizer/78270 (part 2)
PR sanitizer/78270
	* gimplify.c (gimplify_switch_expr): Always save previous
	gimplify_ctxp->live_switch_vars.
	PR sanitizer/78270
	* gcc.dg/asan/pr78270.c: Update comment style.
	* gcc.dg/asan/pr78270-2.c: New test.

From-SVN: r242485
2016-11-16 11:56:58 +00:00
Jakub Jelinek b4c3a85be9 omp-low.c (lower_omp_target): Fix up argument to is_reference.
gcc/
	* omp-low.c (lower_omp_target): Fix up argument to is_reference.
	(expand_omp_ordered_sink): Handle TREE_PURPOSE of deps being
	TRUNC_DIV_EXPR.
	* gimplify.c (gimplify_scan_omp_clauses): Likewise.  Set
	ctx->target_map_scalars_firstprivate on OMP_TARGET even for Fortran.
	Remove omp_no_lastprivate callers.  Propagate lastprivate on combined
	teams distribute parallel for simd even to distribute and teams
	construct.  For OMP_CLAUSE_DEPEND add missing break at the end of
	OMP_CLAUSE_DEPEND_SINK case.
	(omp_notice_variable): Use lang_hooks.decls.omp_scalar_p.
	(omp_no_lastprivate): Removed.
	(gimplify_adjust_omp_clauses): Remove omp_no_lastprivate callers.
	(gimplify_omp_for): Likewise.
	(computable_teams_clause): Fail for automatic vars from current
	function not yet seen in bind expr.
	* langhooks.c (lhd_omp_scalar_p): New function.
	* langhooks.h (struct lang_hooks_for_decls): Add omp_scalar_p.
	* varpool.c (varpool_node::get_create): Set node->offloading
	even for DECL_EXTERNAL decls.
	* langhooks-def.h (lhd_omp_scalar_p): New prototype.
	(LANG_HOOKS_OMP_SCALAR_P): Define.
	(LANG_HOOKS_DECLS): Use it.
gcc/fortran/
	* openmp.c (gfc_free_omp_clauses): Free critical_name, grainsize,
	hint, num_tasks, priority and if_exprs.
	(gfc_match_omp_to_link, gfc_match_omp_depend_sink): New functions.
	(enum omp_mask1, enum omp_mask2): New enums.
	Change all OMP_CLAUSE_* defines into enum values, and change their
	values from ((uint64_t) 1 << bit) to just bit.
	(omp_mask, omp_inv_mask): New classes.  Add ctors and operators.
	(gfc_match_omp_clauses): Change mask argument from uint64_t to
	const omp_mask.  Assert OMP_MASK1_LAST and OMP_MASK2_LAST are
	at most 64.  Move delete clause handling to where it
	alphabetically belongs.  Parse defaultmap, grainsize, hint,
	is_device_ptr, nogroup, nowait, num_tasks, priority, simd, threads
	and use_device_ptr clauses.  Parse if clause modifier.  Parse map
	clause always modifier, and release and delete kinds.  Parse ordered
	clause with argument.  Parse schedule clause modifiers.  Differentiate
	device clause parsing based on openacc flag.  Guard link clause
	parsing with openacc flag.  Add support for parsing
	linear clause modifiers.  Parse depend(source) and depend(sink: ...).
	Use gfc_match_omp_to_link for to and link clauses in declare target
	construct.
	(match_acc): Change mask type from uint64_t to const omp_mask.
	(OMP_SINGLE_CLAUSES, OMP_ORDERED_CLAUSES,
	OMP_DECLARE_TARGET_CLAUSES, OMP_TASKLOOP_CLAUSES,
	OMP_TARGET_ENTER_DATA_CLAUSES, OMP_TARGET_EXIT_DATA_CLAUSES): Define.
	(OACC_PARALLEL_CLAUSES, OACC_KERNELS_CLAUSES, OACC_DATA_CLAUSES,
	OACC_LOOP_CLAUSES, OACC_HOST_DATA_CLAUSES, OACC_DECLARE_CLAUSES,
	OACC_ENTER_DATA_CLAUSES, OACC_EXIT_DATA_CLAUSES, OACC_WAIT_CLAUSES,
	OACC_ROUTINE_CLAUSES, OMP_PARALLEL_CLAUSES, OMP_DECLARE_SIMD_CLAUSES,
	OMP_SECTIONS_CLAUSES, OMP_TEAMS_CLAUSES, OMP_DISTRIBUTE_CLAUSES):
	Replace first or only OMP_CLAUSE_* value in bitset with
	omp_mask (OMP_CLAUSE_*).
	(OMP_DO_CLAUSES): Likewise.  Add OMP_CLAUSE_LINEAR.
	(OMP_SIMD_CLAUSES): Replace first or only OMP_CLAUSE_* value in
	bitset with omp_mask (OMP_CLAUSE_*).  Add OMP_CLAUSE_SIMDLEN.
	(OACC_UPDATE_CLAUSES): Replace first or only OMP_CLAUSE_* value in
	bitset with omp_mask (OMP_CLAUSE_*).  Replace OMP_CLAUSE_OACC_DEVICE
	with OMP_CLAUSE_DEVICE.
	(OMP_TASK_CLAUSES): Replace first or only OMP_CLAUSE_* value in
	bitset with omp_mask (OMP_CLAUSE_*).  Add OMP_CLAUSE_PRIORITY.
	(OMP_TARGET_CLAUSES): Replace first or only OMP_CLAUSE_* value in
	bitset with omp_mask (OMP_CLAUSE_*).  Add OMP_CLAUSE_DEPEND,
	OMP_CLAUSE_NOWAIT, OMP_CLAUSE_PRIVATE, OMP_CLAUSE_FIRSTPRIVATE,
	OMP_CLAUSE_DEFAULTMAP and OMP_CLAUSE_IS_DEVICE_PTR.
	(OMP_TARGET_DATA_CLAUSES): Replace first or only OMP_CLAUSE_* value in
	bitset with omp_mask (OMP_CLAUSE_*).  Add OMP_CLAUSE_USE_DEVICE_PTR.
	(OMP_TARGET_UPDATE_CLAUSES): Replace first or only OMP_CLAUSE_* value
	in bitset with omp_mask (OMP_CLAUSE_*).  Add OMP_CLAUSE_DEPEND and
	OMP_CLAUSE_NOWAIT.
	(match_omp): Change mask argument from unsigned int to
	const omp_mask.
	(gfc_match_omp_critical): Parse optional clauses and use omp_clauses
	union member instead of omp_name.
	(gfc_match_omp_end_critical): New function.
	(gfc_match_omp_distribute_parallel_do): Remove ordered and linear
	clauses from the mask.
	(gfc_match_omp_distribute_parallel_do_simd): Use
	& ~(omp_mask (OMP_CLAUSE_*)) instead of & ~OMP_CLAUSE_*.
	(gfc_match_omp_target_teams_distribute_parallel_do_simd): Likewise.
	(gfc_match_omp_teams_distribute_parallel_do_simd): Likewise.
	(gfc_match_omp_do_simd): Likewise.  Don't remove ordered clause from
	the mask.
	(gfc_match_omp_parallel_do_simd): Likewise.
	(gfc_match_omp_target_teams_distribute_parallel_do): Likewise.
	(gfc_match_omp_teams_distribute_parallel_do): Likewise.
	(gfc_match_omp_declare_simd): If not using the form with
	(proc-name), require space before first clause.  Make (proc-name)
	optional.  If not present, set proc_name to NULL.
	(gfc_match_omp_declare_target): Rewritten for OpenMP 4.5.
	(gfc_match_omp_single): Use OMP_SINGLE_CLAUSES.
	(gfc_match_omp_task, gfc_match_omp_taskwait, gfc_match_omp_taskyield):
	Move around to where they belong alphabetically.
	(gfc_match_omp_target_enter_data, gfc_match_omp_target_exit_data,
	gfc_match_omp_target_parallel, gfc_match_omp_target_parallel_do,
	gfc_match_omp_target_parallel_do_simd, gfc_match_omp_target_simd,
	gfc_match_omp_taskloop, gfc_match_omp_taskloop_simd):
	New functions.
	(gfc_match_omp_ordered): Parse clauses.
	(gfc_match_omp_ordered_depend): New function.
	(gfc_match_omp_cancel, gfc_match_omp_end_single): Use
	omp_mask (OMP_CLAUSE_*) instead of OMP_CLAUSE_*.
	(resolve_oacc_scalar_int_expr): Renamed to ...
	(resolve_scalar_int_expr): ... this.  Fix up formatting.
	(resolve_oacc_positive_int_expr): Renamed to ...
	(resolve_positive_int_expr): ... this.  Fix up formatting.
	(resolve_nonnegative_int_expr): New function.
	(resolve_omp_clauses): Adjust callers, use the above functions
	even for OpenMP clauses, add handling of new OpenMP 4.5 clauses.
	Require orderedc >= collapse if specified. Handle depend(sink:)
	and depend(source) restrictions.  Disallow linear clause when
	orderedc is non-zero.  Diagnose linear clause modifiers when not in
	declare simd.  Only check for integer type if ref modifier
	is not used.  Remove diagnostics for required VALUE attribute.
	Diagnose VALUE attribute with ref or uval modifiers.  Allow
	non-constant linear-step, if it is a dummy argument alone and is
	mentioned in uniform clause.  Diagnose map kinds not allowed
	for various constructs.  Diagnose target {enter ,exit ,}data without
	any map clauses.  Add dummy OMP_LIST_IS_DEVICE_PTR and
	OMP_LIST_USE_DEVICE_PTR cases.
	(gfc_resolve_omp_do_blocks): Set omp_current_do_collapse to orderedc
	if non-zero.
	(gfc_resolve_omp_parallel_blocks): Handle new OpenMP 4.5 constructs,
	replace underscores with spaces in a few construct names.
	(resolve_omp_do): Set collapse to orderedc if non-zero.  Handle new
	OpenMP 4.5 constructs.
	(resolve_oacc_loop_blocks): Call resolve_positive_int_expr instead
	of resolve_oacc_positive_int_expr.
	(gfc_resolve_omp_directive): Handle new OpenMP 4.5 constructs.
	(gfc_resolve_omp_declare_simd): Allow ods->proc_name to be NULL.
	* trans-openmp.c (gfc_omp_scalar_p): New function.
	(doacross_steps): New variable.
	(gfc_trans_omp_clauses): Handle new OpenMP 4.5 clauses and new clause
	modifiers.
	(gfc_trans_omp_critical): Adjust EXEC_OMP_CRITICAL handling.
	(gfc_trans_omp_do): Handle doacross loops.  Clear sched_simd flag.
	Handle EXEC_OMP_TASKLOOP.
	(gfc_trans_omp_ordered): Translate omp clauses, allow NULL
	code->block.
	(GFC_OMP_SPLIT_TASKLOOP, GFC_OMP_MASK_TASKLOOP): New enum constants.
	(gfc_split_omp_clauses): Copy orderedc together with ordered.  Change
	firstprivate and lastprivate handling for OpenMP 4.5.
	Handle EXEC_OMP_TARGET_SIMD, EXEC_OMP_TARGET_PARALLEL{,_DO,_DO_SIMD}
	and EXEC_OMP_TASKLOOP{,_SIMD}.  Add handling for new OpenMP 4.5
	clauses and clause modifiers and handle if clause without/with
	modifiers.
	(gfc_trans_omp_teams): Add omp_clauses argument, add it to other
	teams clauses.  Don't wrap into OMP_TEAMS if -fopenmp-simd.
	(gfc_trans_omp_target): For -fopenmp, translate num_teams and
	thread_limit clauses on combined target teams early and pass to
	gfc_trans_omp_teams.  Set OMP_TARGET_COMBINED if needed.
	Handle EXEC_OMP_TARGET_PARALLEL{,_DO,_DO_SIMD} and
	EXEC_OMP_TARGET_SIMD.
	(gfc_trans_omp_taskloop, gfc_trans_omp_target_enter_data,
	gfc_trans_omp_target_exit_data): New functions.
	(gfc_trans_omp_directive): Handle EXEC_OMP_TARGET_{ENTER,EXIT}_DATA
	EXEC_OMP_TASKLOOP{,_SIMD}, EXEC_OMP_TARGET_PARALLEL{,_DO,_DO_SIMD}
	and EXEC_OMP_TARGET_SIMD.  Adjust gfc_trans_omp_teams caller.
	* symbol.c (check_conflict): Handle omp_declare_target_link.
	(gfc_add_omp_declare_target_link): New function.
	(gfc_copy_attr): Copy omp_declare_target_link.
	* dump-parse-tree.c (show_omp_namelist): Handle OMP_DEPEND_SINK_FIRST
	depend_op.  Print linear clause modifiers.
	(show_omp_clauses): Adjust for OpenMP 4.5 clause changes.
	(show_omp_node): Print clauses for EXEC_OMP_ORDERED.  Allow NULL
	c->block for EXEC_OMP_ORDERED.  Formatting fixes.  Adjust handling of
	EXEC_OMP_CRITICAL, handle new OpenMP 4.5 constructs and some
	forgotten OpenMP 4.0 constructs.
	(show_code_node): Handle new OpenMP 4.5 constructs and some forgotten
	OpenMP 4.0 constructs.
	* gfortran.h (symbol_attribute): Add omp_declare_target_link bitfield.
	(struct gfc_omp_namelist): Add u.common and u.linear_op fields.
	(struct gfc_common_head): Change omp_declare_target into bitfield.
	Add omp_declare_target_link bitfield.
	(gfc_add_omp_declare_target_link): New prototype.
	(enum gfc_statement): Add ST_OMP_TARGET_PARALLEL,
	ST_OMP_END_TARGET_PARALLEL, ST_OMP_TARGET_PARALLEL_DO,
	ST_OMP_END_TARGET_PARALLEL_DO, ST_OMP_TARGET_PARALLEL_DO_SIMD,
	ST_OMP_END_TARGET_PARALLEL_DO_SIMD, ST_OMP_TARGET_ENTER_DATA,
	ST_OMP_TARGET_EXIT_DATA, ST_OMP_TARGET_SIMD, ST_OMP_END_TARGET_SIMD,
	ST_OMP_TASKLOOP, ST_OMP_END_TASKLOOP, ST_OMP_TASKLOOP_SIMD,
	ST_OMP_END_TASKLOOP_SIMD and ST_OMP_ORDERED_DEPEND.
	(enum gfc_omp_depend_op): Add OMP_DEPEND_SINK_FIRST and
	OMP_DEPEND_SINK.
	(enum gfc_omp_linear_op): New.
	(struct gfc_omp_clauses): Add critical_name, depend_source,
	orderedc, defaultmap, nogroup, sched_simd, sched_monotonic,
	sched_nonmonotonic, simd, threads, grainsize, hint, num_tasks,
	priority and if_exprs fields.
	(enum gfc_exec_op): Add EXEC_OMP_END_CRITICAL,
	EXEC_OMP_TARGET_ENTER_DATA, EXEC_OMP_TARGET_EXIT_DATA,
	EXEC_OMP_TARGET_PARALLEL, EXEC_OMP_TARGET_PARALLEL_DO,
	EXEC_OMP_TARGET_PARALLEL_DO_SIMD, EXEC_OMP_TARGET_SIMD,
	EXEC_OMP_TASKLOOP, EXEC_OMP_TASKLOOP_SIMD.
	(enum gfc_omp_map_op): Add OMP_MAP_RELEASE,
	OMP_MAP_ALWAYS_TO, OMP_MAP_ALWAYS_FROM and OMP_MAP_ALWAYS_TOFROM.
	(OMP_LIST_IS_DEVICE_PTR, OMP_LIST_USE_DEVICE_PTR): New.
	(enum gfc_omp_if_kind): New.
	* module.c (enum ab_attribute): Add AB_OMP_DECLARE_TARGET_LINK.
	(attr_bits): Add AB_OMP_DECLARE_TARGET_LINK entry.
	(mio_symbol_attribute): Save and restore omp_declare_target_link bit.
	* trans.h (gfc_omp_scalar_p): New prototype.
	* frontend-passes.c (gfc_code_walker): Handle new OpenMP 4.5
	expressions.
	* trans.c (trans_code): Handle new OpenMP 4.5 constructs.
	* resolve.c (gfc_resolve_blocks): Likewise.
	(gfc_resolve_code): Likewise.
	* f95-lang.c (LANG_HOOKS_OMP_SCALAR_P): Redefine to gfc_omp_scalar_p.
	(gfc_attribute_table): Add "omp declare target link".
	* st.c (gfc_free_statement): Handle EXEC_OMP_END_CRITICAL like
	EXEC_OMP_CRITICAL before, free clauses for EXEC_OMP_CRITICAL
	and new OpenMP 4.5 constructs.  Free omp clauses even for
	EXEC_OMP_ORDERED.
	* match.c (match_exit_cycle): Rename collapse variable to count,
	set it to orderedc if non-zero, instead of collapse.
	* trans-decl.c (add_attributes_to_decl): Add "omp declare target link"
	instead of "omp declare target" for omp_declare_target_link.
	* trans-common.c (build_common_decl): Likewise.
	* match.h (gfc_match_omp_target_enter_data,
	gfc_match_omp_target_exit_data, gfc_match_omp_target_parallel,
	gfc_match_omp_target_parallel_do,
	gfc_match_omp_target_parallel_do_simd, gfc_match_omp_target_simd,
	gfc_match_omp_taskloop, gfc_match_omp_taskloop_simd,
	gfc_match_omp_end_critical, gfc_match_omp_ordered_depend): New
	prototypes.
	* parse.c (decode_omp_directive): Use gfc_match_omp_end_critical
	instead of gfc_match_omp_critical for !$omp end critical.
	Handle new OpenMP 4.5 constructs.  If ordered directive has
	depend clause as the first of the clauses, use
	gfc_match_omp_ordered_depend and ST_OMP_ORDERED_DEPEND instead of
	gfc_match_omp_ordered and ST_OMP_ORDERED.
	(case_executable): Add ST_OMP_TARGET_ENTER_DATA,
	ST_OMP_TARGET_EXIT_DATA and ST_OMP_ORDERED_DEPEND cases.
	(case_exec_markers): Add ST_OMP_TARGET_PARALLEL,
	ST_OMP_TARGET_PARALLEL_DO, ST_OMP_TARGET_PARALLEL_DO_SIMD,
	ST_OMP_TARGET_SIMD, ST_OMP_TASKLOOP and ST_OMP_TASKLOOP_SIMD cases.
	(gfc_ascii_statement): Handle new OpenMP 4.5 constructs.
	(parse_omp_do): Handle ST_OMP_TARGET_PARALLEL_DO,
	ST_OMP_TARGET_PARALLEL_DO_SIMD, ST_OMP_TASKLOOP and
	ST_OMP_TASKLOOP_SIMD.
	(parse_omp_structured_block): Handle EXEC_OMP_END_CRITICAL instead
	of EXEC_OMP_CRITICAL, adjust for EXEC_OMP_CRITICAL having omp clauses
	now.
	(parse_executable): Handle ST_OMP_TARGET_PARALLEL,
	ST_OMP_TARGET_PARALLEL_DO, ST_OMP_TARGET_PARALLEL_DO_SIMD,
	ST_OMP_TASKLOOP and ST_OMP_TASKLOOP_SIMD.
gcc/testsuite/
	* gfortran.dg/gomp/pr77516.f90: Add dg-warning.
	* gfortran.dg/gomp/target1.f90: Remove ordered clause where it is
	no longer allowed and corresponding ordered construct.
	* gfortran.dg/gomp/linear-1.f90: New test.
	* gfortran.dg/gomp/declare-simd-2.f90: New test.
	* gfortran.dg/gomp/declare-target-1.f90: New test.
	* gfortran.dg/gomp/declare-target-2.f90: New test.
libgomp/
	* testsuite/libgomp.fortran/examples-4/declare_target-1.f90
	(fib_wrapper): Add map(from: x) clause.
	* testsuite/libgomp.fortran/examples-4/declare_target-2.f90
	(e_53_2): Likewise.
	* testsuite/libgomp.fortran/examples-4/declare_target-4.f90
	(accum): Add map(tmp) clause.
	* testsuite/libgomp.fortran/examples-4/declare_target-5.f90
	(accum): Add map(tofrom: tmp) clause.
	* testsuite/libgomp.fortran/examples-4/target_data-3.f90
	(gramSchmidt): Likewise.
	* testsuite/libgomp.fortran/examples-4/teams-2.f90 (dotprod): Add
	map(tofrom: sum) clause.
	* testsuite/libgomp.fortran/nestedfn5.f90 (foo): Add twice
	map (alloc: a, l) clause.  Add defaultmap(tofrom: scalar) clause.
	* testsuite/libgomp.fortran/pr66199-2.f90: Adjust for linear clause
	only allowed on the loop iterator.
	* testsuite/libgomp.fortran/target4.f90 (foo): Add map(t) clause.
	* testsuite/libgomp.fortran/taskloop2.f90: New test.
	* testsuite/libgomp.fortran/taskloop4.f90: New test.
	* testsuite/libgomp.fortran/doacross1.f90: New test.
	* testsuite/libgomp.fortran/doacross3.f90: New test.
	* testsuite/libgomp.fortran/taskloop1.f90: New test.
	* testsuite/libgomp.fortran/taskloop3.f90: New test.
	* testsuite/libgomp.fortran/doacross2.f90: New test.
	* testsuite/libgomp.c/doacross-1.c (main): Add missing
	#pragma omp atomic read.
	* testsuite/libgomp.c/doacross-2.c (main): Likewise.
	* testsuite/libgomp.c/doacross-3.c (main): Likewise.

From-SVN: r242037
2016-11-10 12:38:05 +01:00
Martin Liska 86bc850653 Create live_switch_vars conditionally (PR sanitizer/78270)
PR sanitizer/78270
	* gcc.dg/asan/pr78270.c: New test.
	PR sanitizer/78270
	* gimplify.c (gimplify_switch_expr): Create live_switch_vars
	only when SWITCH_BODY is a BIND_EXPR.

From-SVN: r242036
2016-11-10 11:21:03 +00:00
Martin Liska fcd1b8dffc use-after-scope fallout
PR testsuite/78242
	* g++.dg/asan/use-after-scope-4.C: New test.
	* g++.dg/asan/use-after-scope-types-4.C: Update scanned pattern.
	* gcc.dg/asan/use-after-scope-8.c: Remove.
	PR testsuite/78242
	* dbgcnt.def: Add new debug counter asan_use_after_scope.
	* gimplify.c (gimplify_decl_expr): Do not sanitize vars
	with a value expr.  Do not add artificial variables to
	live_switch_vars.  Use the debug counter.
	(gimplify_target_expr): Use the debug counter.
	* internal-fn.def: Remove ECF_TM_PURE from ASAN_MARK builtin.
	* sanitizer.def: Set ATTR_NOTHROW_LEAF_LIST to
	BUILT_IN_ASAN_CLOBBER_N and BUILT_IN_ASAN_UNCLOBBER_N.

From-SVN: r241961
2016-11-08 12:28:33 +00:00
Martin Liska 6dc4a60450 Introduce -fsanitize-address-use-after-scope
* c-warn.c (warn_for_unused_label): Save all labels used
	in goto or in &label.
	* asan.c (enum asan_check_flags): Move the enum to header file.
	(asan_init_shadow_ptr_types): Make type creation more generic.
	(shadow_mem_size): New function.
	(asan_emit_stack_protection): Use newly added ASAN_SHADOW_GRANULARITY.
	Rewritten stack unpoisoning code.
	(build_shadow_mem_access): Add new argument return_address.
	(instrument_derefs): Instrument local variables if use after scope
	sanitization is enabled.
	(asan_store_shadow_bytes): New function.
	(asan_expand_mark_ifn): Likewise.
	(asan_sanitize_stack_p): Moved from asan_sanitize_stack_p.
	* asan.h (enum asan_mark_flags): Moved here from asan.c
	(asan_protect_stack_decl): Protect all declaration that need
	to live in memory.
	(asan_sanitize_use_after_scope): New function.
	(asan_no_sanitize_address_p): Likewise.
	* cfgexpand.c (partition_stack_vars): Consider
	asan_sanitize_use_after_scope in condition.
	(expand_stack_vars): Likewise.
	* common.opt (-fsanitize-address-use-after-scope): New option.
	* doc/invoke.texi (use-after-scope-direct-emission-threshold):
	Explain the parameter.
	* flag-types.h (enum sanitize_code): Define SANITIZE_USE_AFTER_SCOPE.
	* gimplify.c (build_asan_poison_call_expr): New function.
	(asan_poison_variable): Likewise.
	(gimplify_bind_expr): Generate poisoning/unpoisoning for local
	variables that have address taken.
	(gimplify_decl_expr): Likewise.
	(gimplify_target_expr): Likewise for C++ temporaries.
	(sort_by_decl_uid): New function.
	(gimplify_expr): Unpoison all variables for a label we can jump
	from outside of a scope.
	(gimplify_switch_expr): Unpoison variables defined in the switch
	context.
	(gimplify_function_tree): Clear asan_poisoned_variables.
	(asan_poison_variables): New function.
	(warn_switch_unreachable_r): Handle IFN_ASAN_MARK.
	* internal-fn.c (expand_ASAN_MARK): New function.
	* internal-fn.def (ASAN_MARK): Declare.
	* opts.c (finish_options): Handle -fstack-reuse if
	-fsanitize-address-use-after-scope is enabled.
	(common_handle_option): Enable address sanitization if
	-fsanitize-address-use-after-scope is enabled.
	* params.def (PARAM_USE_AFTER_SCOPE_DIRECT_EMISSION_THRESHOLD):
	New parameter.
	* params.h: Likewise.
	* sancov.c (pass_sanopt::execute): Handle IFN_ASAN_MARK.
	* sanitizer.def: Define __asan_poison_stack_memory and
	__asan_unpoison_stack_memory functions.
	* asan.c (asan_mark_poison_p): New function.
	(transform_statements): Handle asan_mark_poison_p calls.
	* gimple.c (nonfreeing_call_p): Handle IFN_ASAN_MARK.

From-SVN: r241896
2016-11-07 10:23:38 +00:00
Will Schmidt 0faf9ab4d6 re PR middle-end/72747 (powerpc: wrong code generated for vec_splats in cascading assignment)
gcc:
2016-10-26  Will Schmidt <will_schmidt@vnet.ibm.com>

        PR middle-end/72747
        * gimplify.c (gimplify_init_constructor): Move emit of constructor
        assignment to earlier in the if/else logic.

testsuite:
2016-10-26  Will Schmidt <will_schmidt@vnet.ibm.com>

        PR middle-end/72747
        * c-c++-common/pr72747-1.c: New test.
        * c-c++-common/pr72747-2.c: Likewise.

From-SVN: r241647
2016-10-28 13:28:46 +00:00
Jakub Jelinek 3693a620f0 re PR fortran/77973 (ICE in scan_omp_1_op, at omp-low.c:3841)
PR fortran/77973
	* gimplify.c (gimplify_adjust_omp_clauses_1): For all added map
	clauses with OMP_CLAUSE_SIZE being a decl, call omp_notice_variable
	on outer context if any.

	* gfortran.dg/gomp/pr77973.f90: New test.

Co-Authored-By: Martin Liska <mliska@suse.cz>

From-SVN: r241581
2016-10-26 18:21:56 +02:00
Jakub Jelinek f9faea3725 gimplify.c (gimplify_bind_expr): Handle oacc_declare_returns even for -fstack-reuse=none, or for volatile vars etc.
* gimplify.c (gimplify_bind_expr): Handle oacc_declare_returns
	even for -fstack-reuse=none, or for volatile vars etc.

From-SVN: r241407
2016-10-21 17:09:49 +02:00
Richard Biener d6b1fea25c gimplify.c (gimplify_function_tree): Do not move the outer binds block.
2016-10-17  Richard Biener  <rguenther@suse.de>

	* gimplify.c (gimplify_function_tree): Do not move the outer
	binds block.

From-SVN: r241228
2016-10-17 07:28:57 +00:00
Jakub Jelinek 70f6d5e19b gcc/
* common.opt (Wimplicit-fallthrough) Turn into alias to
	-Wimplicit-fallthrough=3.  Remove EnabledBy.
	(Wimplicit-fallthrough=): New option.
	* gimplify.c (warn_implicit_fallthrough_r): Use
	OPT_Wimplicit_fallthrough_ instead of OPT_Wimplicit_fallthrough.
	* doc/invoke.texi (-Wimplicit-fallthrough): Document as alias
	to -Wimplicit-fallthrough=3.
	(-Wimplicit-fallthrough=): Document.
gcc/c-family/
	* c.opt (Wextra): Add as C/C++/ObjC/ObjC++ option.
	(Wimplicit-fallthrough=): Enable for these languages by -Wextra.
	* c-opts.c (sanitize_cpp_opts): Initialize
	cpp_opts->cpp_warn_implicit_fallthrough.
gcc/testsuite/
	* c-c++-common/Wimplicit-fallthrough-25.c: New test.
	* c-c++-common/Wimplicit-fallthrough-26.c: New test.
	* c-c++-common/Wimplicit-fallthrough-27.c: New test.
	* c-c++-common/Wimplicit-fallthrough-28.c: New test.
	* c-c++-common/Wimplicit-fallthrough-29.c: New test.
	* c-c++-common/Wimplicit-fallthrough-30.c: New test.
	* c-c++-common/Wimplicit-fallthrough-31.c: New test.
	* c-c++-common/Wimplicit-fallthrough-32.c: New test.
	* c-c++-common/Wimplicit-fallthrough-33.c: New test.
libcpp/
	* include/cpplib.h (struct cpp_options): Add
	cpp_warn_implicit_fallthrough.
	* init.c (cpp_create_reader): Initialize it to 0.
	* lex.c (fallthrough_comment_p): Handle different
	cpp_warn_implicit_fallthrough levels.  Whitespace fixes.

From-SVN: r241013
2016-10-12 01:19:06 +02: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
Marek Polacek a9172bf307 gimplify.c (should_warn_for_implicit_fallthrough): Check for FALLTHROUGH_LABEL_P here...
* gimplify.c (should_warn_for_implicit_fallthrough): Check for
	FALLTHROUGH_LABEL_P here...
	(warn_implicit_fallthrough_r): ...not here.

	* c-c++-common/Wimplicit-fallthrough-22.c: New test.

From-SVN: r240864
2016-10-07 12:44:54 +00:00
Marek Polacek d4bd46463c re PR c++/77803 (Bogus implicit-fallthrough warning)
PR c++/77803
	* gimplify.c (last_stmt_in_scope): Add check for FALLTHROUGH ().

	* g++.dg/warn/Wimplicit-fallthrough-1.C: New test.

From-SVN: r240861
2016-10-07 11:45:50 +00:00
Marek Polacek 81fea426da Implement -Wimplicit-fallthrough.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r240485
2016-09-26 09:42:50 +00:00
Tom de Vries 5b28efbbf4 Make canonical_va_list_type more strict
2016-09-10  Tom de Vries  <tom@codesourcery.com>

	PR C/71602
	* builtins.c (std_canonical_va_list_type): Strictly return non-null for
	va_list type only.
	* config/i386/i386.c (ix86_canonical_va_list_type): Same.
	* gimplify.c (gimplify_va_arg_expr): Handle &va_list.

	* c-common.c (build_va_arg): Handle more strict
	targetm.canonical_va_list_type.  Replace first argument type error with
	assert.

	* c-c++-common/va-arg-va-list-type.c: New test.

From-SVN: r240072
2016-09-10 14:38:56 +00:00
Jakub Jelinek 9dc5773f4b re PR c/65467 ([libgomp] sorry, unimplemented: '_Atomic' with OpenMP)
PR c/65467
	* gimplify.c (gimplify_adjust_omp_clauses_1): Diagnose implicit
	map and firstprivate clauses on target construct for _Atomic
	qualified decls.
	(gimplify_adjust_omp_clauses): Diagnose explicit firstprivate clauses
	on target construct for _Atomic qualified decls.
	* omp-low.c (use_pointer_for_field): Return true for _Atomic qualified
	decls.
	* omp-simd-clone.c (simd_clone_clauses_extract): Warn and give up for
	_Atomic qualified arguments not mentioned in uniform clause.
c/
	* c-parser.c (c_parser_declspecs): Don't sorry about _Atomic if
	flag_openmp.
	(c_parser_omp_variable_list): Use convert_lvalue_to_rvalue
	instead of mark_exp_read on low_bound/length expression.
	(c_parser_omp_clause_num_gangs, c_parser_omp_clause_num_threads,
	c_parser_omp_clause_num_tasks, c_parser_omp_clause_grainsize,
	c_parser_omp_clause_priority, c_parser_omp_clause_hint,
	c_parser_omp_clause_num_workers, c_parser_oacc_shape_clause,
	c_parser_oacc_clause_tile, c_parser_omp_clause_schedule,
	c_parser_omp_clause_vector_length, c_parser_omp_clause_num_teams,
	c_parser_omp_clause_thread_limit, c_parser_omp_clause_aligned,
	c_parser_omp_clause_linear, c_parser_omp_clause_safelen,
	c_parser_omp_clause_simdlen, c_parser_omp_clause_device,
	c_parser_omp_clause_dist_schedule): Use convert_lvalue_to_rvalue
	instead of mark_expr_read.
	(c_parser_omp_declare_reduction): Reject _Atomic qualified types.
	* c-objc-common.h (LANG_HOOKS_OMP_CLAUSE_COPY_CTOR,
	LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP): Redefine.
	* c-tree.h (c_omp_clause_copy_ctor): New prototype.
	* c-typeck.c (handle_omp_array_sections_1): Diagnose _Atomic qualified
	array section bases outside of depend clause, for depend clause
	use convert_lvalue_to_rvalue on the base.
	(c_finish_omp_clauses): Reject _Atomic qualified vars in reduction,
	linear, aligned, map, to and from clauses.
	(c_omp_clause_copy_ctor): New function.
c-family/
	* c-omp.c (c_finish_omp_atomic): Reject _Atomic qualified expressions.
	(c_finish_omp_for): Reject _Atomic qualified iterators.
testsuite/
	* gcc.dg/gomp/_Atomic-1.c: New test.
	* gcc.dg/gomp/_Atomic-2.c: New test.
	* gcc.dg/gomp/_Atomic-3.c: New test.
	* gcc.dg/gomp/_Atomic-4.c: New test.
	* gcc.dg/gomp/_Atomic-5.c: New test.

From-SVN: r239964
2016-09-02 20:38:07 +02:00
Martin Sebor 3d7b83b671 c-ada-spec.c (dump_ada_function_declaration): Increase buffer size to guarantee it fits the output of the formatted function...
gcc/c-family/ChangeLog:

	* c-ada-spec.c (dump_ada_function_declaration): Increase buffer
	size to guarantee it fits the output of the formatted function
	regardless of its arguments.

gcc/cp/ChangeLog:

	* mangle.c: Increase buffer size to guarantee it fits the output
	of the formatted function regardless of its arguments.

gcc/go/ChangeLog:

	* gofrontend/expressions.cc: Increase buffer size to guarantee
	it fits the output of the formatted function regardless of its
	arguments.

gcc/java/ChangeLog:

	* decl.c (give_name_to_locals): Increase buffer size to guarantee
	it fits the output of the formatted function regardless of its
	arguments.
	* mangle_name.c (append_unicode_mangled_name): Same.

gcc/ChangeLog:

	* genmatch.c (parser::parse_expr): Increase buffer size to guarantee
	it fits the output of the formatted function regardless of its
	arguments.
	* gcc/genmodes.c (parser::parse_expr): Same.
	* gimplify.c (gimplify_asm_expr): Same.
	* passes.c (pass_manager::register_one_dump_file): Same.
	* print-tree.c (print_node): Same.

From-SVN: r239949
2016-09-01 16:47:49 -06:00
Tom de Vries ba9bbd6f58 Handle errors in both args of va_arg
2016-08-29  Tom de Vries  <tom@codesourcery.com>

	PR c/77398
	* c-common.c (build_va_arg): Add first argument error.  Build va_arg
	with error_mark_node as va_list instead of with illegal va_list.

	* gimplify.c (gimplify_va_arg_expr): Replace first argument type error
	with assert.

	* g++.dg/ext/va-arg1.C: Add error check for illegal first argument.

From-SVN: r239827
2016-08-29 16:41:33 +00:00
Chung-Lin Tang 2c71d454eb re PR middle-end/70895 (OpenACC: loop reduction does not work. Output is zero.)
2016-08-18  Chung-Lin Tang  <cltang@codesourcery.com>

	PR middle-end/70895
	gcc/
	* gimplify.c (omp_add_variable): Adjust/add variable mapping on
	enclosing parallel construct for reduction variables on OpenACC loop
	directives.

	gcc/testsuite/
	* gfortran.dg/goacc/loop-tree-1.f90: Add gimple scan-tree-dump test.
	* c-c++-common/goacc/reduction-1.c: Likewise.
	* c-c++-common/goacc/reduction-2.c: Likewise.
	* c-c++-common/goacc/reduction-3.c: Likewise.
	* c-c++-common/goacc/reduction-4.c: Likewise.

	libgomp/
	* testsuite/libgomp.oacc-fortran/reduction-7.f90: Add explicit
	firstprivate clauses.
	* testsuite/libgomp.oacc-fortran/reduction-6.f90: Remove explicit
	copy clauses.
	* testsuite/libgomp.oacc-c-c++-common/reduction-7.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/reduction-cplx-flt.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/reduction-flt.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/collapse-2.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/loop-red-wv-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/collapse-4.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/reduction-cplx-dbl.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/reduction-dbl.c: Likewise.

From-SVN: r239576
2016-08-18 14:46:19 +00: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
Richard Biener 7f15b177ba re PR tree-optimization/71104 (ICE: verify_ssa failed (with vfork / error: definition in block 3 does not dominate use in block 7 ))
2016-07-13  Richard Biener  <rguenther@suse.de>

	PR middle-end/71104
	* gimplify.c (gimplify_modify_expr): Gimplify the RHS before
	gimplifying the LHS.  Make sure to gimplify a returning twice
	call LHS without using SSA names.

	* gcc.dg/pr71104-1.c: New testcase.
	* gcc.dg/pr71104-2.c: Likewise.

From-SVN: r238287
2016-07-13 08:03:04 +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
Jason Merrill 8a1b7b7fd7 P0145: Refining Expression Order for C++ (assignment)
* gimplify.c (initial_rhs_predicate_for): New.
	(gimplfy_modify_expr): Gimplify RHS before LHS.

Co-Authored-By: Richard Biener <rguenther@suse.de>

From-SVN: r238175
2016-07-08 16:23:40 -04:00
Jakub Jelinek 283635f9bd gimplify.c (gimplify_scan_omp_clauses): Handle COMPONENT_REFs with base of reference to struct.
* gimplify.c (gimplify_scan_omp_clauses): Handle COMPONENT_REFs
	with base of reference to struct.

	* parser.c (cp_parser_omp_var_list_no_open): Call
	convert_from_reference before cp_parser_postfix_dot_deref_expression.
	* semantics.c (finish_omp_clauses): Don't ICE when
	processing_template_decl when checking for bitfields and unions.
	Look through REFERENCE_REF_P as base of COMPONENT_REF.

	* testsuite/libgomp.c++/target-20.C: New test.

From-SVN: r237538
2016-06-16 21:03:05 +02:00