Commit Graph

11020 Commits

Author SHA1 Message Date
Jason Merrill b10c7cd74a PR c++/79556 - C++17 ICE with non-type auto
* pt.c (do_auto_deduction): Don't try to deduce from null type.

From-SVN: r245543
2017-02-17 13:42:37 -05:00
Jason Merrill 1ee2604721 PR c++/79533 - C++17 ICE with temporary cast to reference
* call.c (build_over_call): Conversion to a reference prevents copy
	elision.

From-SVN: r245538
2017-02-17 11:50:16 -05:00
Jakub Jelinek 790ecf8532 PR c++/79502 - lost nodiscard attribute
* pt.c (apply_late_template_attributes): Do apply non-dependent
	attributes to types.

Co-Authored-By: Jason Merrill <jason@redhat.com>

From-SVN: r245516
2017-02-16 14:49:19 -05:00
Jason Merrill 1e163090d5 PR c++/78572 - ICE with self-modifying array initializer
* constexpr.c (cxx_eval_store_expression): The object we're
	initializing is outside the constant-expression.

From-SVN: r245511
2017-02-16 11:42:06 -05:00
Jason Merrill 61cee26030 PR c++/79050 - ICE with undeduced auto and LTO
* decl.c (poplevel): Remove undeduced auto decls.

From-SVN: r245510
2017-02-16 11:42:00 -05:00
Jakub Jelinek bcac0b4dac re PR c++/79512 (ICE: Segfault in gimple_build_call_1, at gimple.c:218)
PR c++/79512
c/
	* c-parser.c (c_parser_omp_target): For -fopenmp-simd
	ignore #pragma omp target even when not followed by identifier.
cp/
	* parser.c (cp_parser_omp_target): For -fopenmp-simd
	ignore #pragma omp target even when not followed by identifier.
testsuite/
	* c-c++-common/gomp/pr79512.c: New test.

From-SVN: r245504
2017-02-16 13:02:24 +01:00
Jason Merrill 19e8a45feb PR c++/79464 - ICE in IPA with omitted constructor parms
* class.c (build_clone): Also omit parms from TYPE_ARG_TYPES.
	(adjust_clone_args): Adjust.
	(add_method): Remember omitted parms.
	* call.c (add_function_candidate): Likewise.
	* mangle.c (write_method_parms): Likewise.
	* method.c (ctor_omit_inherited_parms): Return false if there are no
	parms to omit.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r245495
2017-02-15 15:29:08 -05:00
Martin Sebor 945c17d8c1 PR c++/79363 - ICE with NSDMI and array
gcc/cp/ChangeLog:

	PR c++/79363
	* init.c (maybe_reject_flexarray_init): New function.
	(perform_member_init): Call it.

gcc/testsuite/ChangeLog:

	PR c++/79363
	* g++.dg/ext/flexary12.C: Adjust.
	* g++.dg/ext/flexary20.C: Same.
	* g++.dg/ext/flexary21.C: Same.
	* g++.dg/ext/flexary22.C: New test.

From-SVN: r245494
2017-02-15 13:28:32 -07:00
Jakub Jelinek e72028574f re PR c++/79301 (With -Werror=pedantic outside C++17 mode, __has_cpp_attribute(fallthrough) is nonzero but [[fallthrough]] fails)
PR c++/79301
	* parser.c (cp_parser_std_attribute): Don't pedwarn about
	[[deprecated]] with -std=c++11 and [[fallthrough]] with
	-std=c++11 and -std=c++14.

	* g++.dg/cpp1y/feat-cxx11-neg.C: Remove (with pedwarn) from
	[[deprecated]] comment.
	* g++.dg/cpp1y/feat-cxx98-neg.C: Likewise.
	* g++.dg/cpp1y/feat-cxx11.C: Likewise.
	* g++.dg/cpp1y/attr-deprecated-neg.C: Don't expect warnings for
	[[deprecated]] in -std=c++11.
	* g++.dg/cpp0x/fallthrough2.C: Don't expect warnings for
	[[fallthrough]] in -std=c++11 and -std=c++14.

From-SVN: r245489
2017-02-15 18:10:40 +01:00
Jakub Jelinek 4f5e5fcba8 re PR c++/79288 (TLS model wrong for static data members since r241137)
PR c++/79288
	* decl.c (grokdeclarator): For static data members, handle thread_p
	only after handling inline.

	* g++.dg/tls/pr79288.C: New test.

From-SVN: r245488
2017-02-15 18:09:18 +01:00
Marek Polacek 6f207d5810 re PR c++/79420 (ICE on invalid C++ code on x86_64-linux-gnu: in tsubst_copy, at cp/pt.c:14573)
PR c++/79420
	PR c++/79463
	* parser.c (cp_parser_postfix_dot_deref_expression): Avoid
	clobbering if the postfix expression isn't an EXPR_P.

	* g++.dg/cpp1y/pr79463.C: New.
	* g++.dg/template/incomplete10.C: New.
	* g++.dg/template/incomplete9.C: New.

From-SVN: r245440
2017-02-14 17:33:21 +00:00
Jason Merrill 8cb7aaa11b PR c++/79461 - ICE with lambda in constexpr constructor
* constexpr.c (build_data_member_initialization): Ignore
	initialization of a local variable.

From-SVN: r245410
2017-02-13 17:31:12 -05:00
Jakub Jelinek 5995f59725 init.c (warn_placement_new_too_small): Add missing space in diagnostics.
* init.c (warn_placement_new_too_small): Add missing space in
	diagnostics.
	* parser.c (cp_parser_oacc_declare): Likewise.
	* mangle.c (maybe_check_abi_tags): Likewise.

From-SVN: r245407
2017-02-13 22:54:01 +01:00
Jakub Jelinek b84702c057 re PR c++/79232 (error: invalid rhs for gimple memory store)
PR c++/79232
	* typeck.c (cp_build_modify_expr): Handle properly COMPOUND_EXPRs
	on lhs that have {PRE{DEC,INC}REMENT,MODIFY,MIN,MAX,COND}_EXPR
	in the rightmost operand.

	* g++.dg/cpp1z/eval-order4.C: New test.
	* g++.dg/other/pr79232.C: New test.

From-SVN: r245401
2017-02-13 20:31:14 +01:00
Nathan Sidwell b9a161ff70 PR c++/79296 - ICE mangling localized template instantiation
PR c++/79296 - ICE mangling localized template instantiation
	* decl2.c (determine_visibility): Use template fn context for
	local class instantiations.

	PR c++/79296
	* g++.dg/cpp0x/pr79296.C: New.

From-SVN: r245398
2017-02-13 17:42:31 +00:00
Jason Merrill 817a77e41e PR c++/77659 - ICE with new and C++14 aggregate NSDMI
* init.c (build_new): Make backups of any CONSTRUCTORs in init.
	(build_new_1): Use replace_placeholders.
	* tree.c (replace_placeholders_t): Also track whether we've seen a
	placeholder.
	(replace_placeholders, replace_placeholders_r): Adjust.
	* cp-tree.h: Adjust.

From-SVN: r245372
2017-02-11 22:31:02 -05:00
Jason Merrill bc61048a14 PR c++/77790 - ICE with auto function in C++11 mode
* decl.c (undeduced_auto_decl): Remove C++14 limitation.
	(require_deduced_type): Add complain parm, return bool.
	* cp-tree.h: Adjust.
	* decl2.c (mark_used): Use require_deduced_type.

From-SVN: r245358
2017-02-11 12:29:45 -05:00
Jason Merrill 6a2cc46b79 PR c++/78908 - template ops and bitfields
* tree.c (build_min_non_dep): Use unlowered_expr_type.

From-SVN: r245343
2017-02-10 15:43:33 -05:00
Jason Merrill 5c97093ba7 PR c++/78897 - constexpr union
* constexpr.c (cxx_eval_store_expression): A store to a union member
	erases a previous store to another member.

From-SVN: r245341
2017-02-10 13:50:30 -05:00
Jason Merrill f494ac0ebd PR c++/71285 - member of fold-expression
* semantics.c (finish_unary_fold_expr)
	(finish_binary_fold_expr): Use null type for fold-expressions.

From-SVN: r245340
2017-02-10 13:24:36 -05:00
Jason Merrill c16b872c8f PR c++/79401 - protected inherited constructor
* call.c (enforce_access): For inheriting constructor, find a base
	binfo in the path we already have.

From-SVN: r245339
2017-02-10 13:01:27 -05:00
Marek Polacek 3799a5b853 re PR c++/79184 (-Wint-in-bool-context triggered erroneously in template parameter)
PR c++/79184
	* cvt.c (ocp_convert): Add a sentinel against -Wint-in-bool-context
	if warnings shouldn't be given.

	* g++.dg/warn/Wint-in-bool-context-1.C: New.

From-SVN: r245335
2017-02-10 16:33:45 +00:00
Marek Polacek 6f4f30bf31 re PR c++/79435 (ICE on invalid C++ code (with member access into an incomplete type) on x86_64-linux-gnu: Segmentation fault)
PR c++/79435
	* pt.c (type_dependent_expression_p): Check if the expression type
	is null.

	* g++.dg/cpp1y/pr79435.C: New.

From-SVN: r245334
2017-02-10 16:32:19 +00:00
Paolo Carlini a7c8ed0c36 re PR c++/71737 (ICE following 2x pack expansion in non-pack with template alias)
/cp
2017-02-10  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/71737
	* pt.c (tsubst_decl): Don't try to preserve a typedef that names
	an error_mark_node as type.

/testsuite
2017-02-10  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/71737
	* g++.dg/cpp0x/pr71737.C: New.

From-SVN: r245327
2017-02-10 13:14:05 +00:00
Jakub Jelinek 9bfc55d096 re PR c++/79143 ([new inheriting constructors] inheriting constructor fails with brace initialization)
PR c++/79143
	* pt.c (instantiate_class_template_1): Copy CLASSTYPE_NON_AGGREGATE
	from pattern to type.

	* g++.dg/cpp1z/pr79143.C: New test.

Co-Authored-By: Jason Merrill <jason@redhat.com>

From-SVN: r245315
2017-02-09 23:12:15 +01:00
Jason Merrill a56c0ac082 PR c++/79316 - default argument in deduction guide
PR c++/79350 - explicit deduction guide
	* parser.c (cp_parser_constructor_declarator_p)
	(cp_parser_direct_declarator): Parse deduction guides more like
	constructors.
	* cp-tree.h (enum special_function_kind): Add sfk_deduction_guide.
	* tree.c (special_function_p): Return it.
	* decl.c (check_special_function_return_type): Handle it.
	(grokdeclarator, grokfndecl): Adjust.
	(cp_finish_decl): Pass flags to do_auto_deduction.
	* error.c (dump_decl_name): Use TFF_UNQUALIFIED_NAME.
	* pt.c (dguide_name_p): Take a const_tree.
	(do_class_deduction): Handle explicit.
	(do_auto_deduction): Pass flags through.
	(build_deduction_guide): Copy explicit flag.

From-SVN: r245314
2017-02-09 15:55:54 -05:00
Jakub Jelinek f08683a154 re PR c++/79429 (ICE in add_stmt, at cp/semantics.c:385)
PR c++/79429
	* parser.c (cp_parser_omp_ordered): Don't check for non-pragma_stmt
	non-pragma_compound context here.
	(cp_parser_omp_target): Likewise.
	(cp_parser_pragma): Don't call push_omp_privatization_clauses and
	parsing for ordered and target omp pragmas in non-pragma_stmt
	non-pragma_compound contexts.

	* c-c++-common/gomp/pr79429.c: New test.
	* g++.dg/gomp/pr79429.C: New test.

From-SVN: r245303
2017-02-09 15:06:58 +01: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
Nathan Sidwell 8e956c2273 method.c (synthesized_method_base_walk): New.
* method.c (synthesized_method_base_walk): New.  Broken out of ...
	(synthesized_method_walk): ... here.  Call it.  Cleanup
	initializations.

From-SVN: r245250
2017-02-07 17:43:12 +00:00
Patrick Palka bb7d75ffce re PR c++/79360 (ICE with NSDMI and enum in union)
Fix PR c++/79360

gcc/cp/ChangeLog:

	PR c++/79360
	* typeck2.c (process_init_constructor_union): Consider only
	FIELD_DECLs when looking for an NSDMI.

gcc/testsuite/ChangeLog:

	PR c++/79360
	* g++.dg/cpp1y/nsdmi-union2.C: New test.

From-SVN: r245239
2017-02-07 02:20:48 +00:00
Jason Merrill 44a6da7bac PR c++/71193 - incomplete types in templates
* parser.c (cp_parser_postfix_dot_deref_expression): In a template
	handle incomplete type by pedwarning and then treating as dependent.

From-SVN: r245223
2017-02-06 16:12:13 -05:00
Jakub Jelinek 98e0924501 re PR c++/79379 (ICE with #pragma GCC ivdep)
PR c++/79379
	* constexpr.c (cxx_eval_constant_expression): Handle ANNOTATE_EXPR.
	(potential_constant_expression_1): Likewise.

	* g++.dg/cpp1y/constexpr-79379.C: New test.

From-SVN: r245220
2017-02-06 21:06:16 +01:00
Jakub Jelinek e8b0383c13 re PR c++/79377 (ICE with increment operator in -fpermissive mode)
PR c++/79377
	* tree.c (build_min_non_dep_op_overload): For POST{INC,DEC}REMENT_EXPR
	allow one fewer than expected arguments if flag_permissive.

	* g++.dg/lookup/pr79377.C: New test.

From-SVN: r245219
2017-02-06 21:05:09 +01:00
Jakub Jelinek a5e8cbd150 re PR c++/79372 (ICE on C++ code with illegal decomposition declaration on x86_64-linux-gnu: in tsubst_decomp_names, at cp/pt.c:15599)
PR c++/79372
	* decl.c (cp_finish_decomp): On error set decl type to error_mark_node.
	* pt.c (tsubst_expr): Don't call tsubst_decomp_names on decompositions
	with error_mark_node type.

	* g++.dg/cpp1z/decomp25.C: New test.

From-SVN: r245218
2017-02-06 21:03:15 +01:00
Jason Merrill 77095a6ab1 PR c++/78689 - ICE on constructor with label
gcc/
	* tree-inline.c (copy_tree_body_r) [COND_EXPR]: Revert change to
	avoid copying non-taken branch.
gcc/cp/
	* optimize.c (maybe_clone_body): Replace omitted parameters with
	null lvalues.
	* class.c (build_clone): Fix logic for omitting inherited parms.

From-SVN: r245172
2017-02-03 17:42:37 -05:00
Jason Merrill 8a87daca9c PR c++/12245 - excessive memory use
* constexpr.c (maybe_constant_value): Fold maybe_constant_value_1
	back in.  Don't cache constants.
	(maybe_constant_init): Don't cache constants.

From-SVN: r245169
2017-02-03 14:44:27 -05:00
Jason Merrill 99be38ec6a PR c++/79294 - ICE with invalid template argument
* pt.c (convert_nontype_argument_function): Check value-dependence.
	(convert_nontype_argument): Don't check it here for function ptrs.

From-SVN: r245168
2017-02-03 14:44:21 -05:00
Richard Biener 27de0fab0f re PR c++/14179 (out of memory while parsing array with many initializers)
2017-02-02  Richard Biener  <rguenther@suse.de>

	PR cp/14179
	* cp-gimplify.c (cp_fold): When folding a CONSTRUCTOR copy
	it lazily on the first changed element only and copy it
	fully upfront, only storing changed elements.

From-SVN: r245118
2017-02-02 08:55:44 +00:00
Paolo Carlini d8d58893e4 re PR c++/69637 (ICE on an invalid bit-field with template name for width)
/cp
2017-02-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/69637
	* decl2.c (grokbitfield): In case of error don't set-up DECL_INITIAL
	to the width.

/testsuite
2017-02-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/69637
	* g++.dg/cpp0x/pr69637-1.C: New.
	* g++.dg/cpp0x/pr69637-2.C: Likewise.

From-SVN: r245117
2017-02-02 08:54:55 +00:00
Jakub Jelinek 19bdccb4be re PR c++/79304 (diagnostic shows bogus expression ((X<T>*)this)->.c)
PR c++/79304
	* error.c (dump_expr) <case COMPONENT_REF>: Don't print .
	after ARROW_EXPR.

	* g++.dg/diagnostic/pr79304.C: New test.

From-SVN: r245073
2017-01-31 22:38:00 +01:00
David Malcolm fcb2cdfcfe Fix ICE with spelling hints within explicit namespace aliases (PR c++/79298)
gcc/cp/ChangeLog:
	PR c++/79298
	* name-lookup.c (suggest_alternative_in_explicit_scope): Resolve
	any namespace aliases.

gcc/testsuite/ChangeLog:
	PR c++/79298
	* g++.dg/spellcheck-pr79298.C: New test case.

From-SVN: r245072
2017-01-31 21:30:42 +00:00
Nathan Sidwell 5ae37bdfce re PR c++/79290 (forming pointer to member function tries to access "__pfn")
PR c++/79290
	* typeck.c (build_ptrmemfunc_access_expr): Set TREE_NO_WARNING.

	PR c++/79290
	* g++.dg/warn/pr79290.C: New.

From-SVN: r245069
2017-01-31 19:37:11 +00:00
Nathan Sidwell de3fbef690 re PR c++/67273 (Incorrect -Wshadow warning with generic lambdas)
PR c++/67273
	PR c++/79253
	* pt.c: (instantiate_decl): Push to top level when current
	function scope doesn't match.  Only push lmabda scope stack when
	pushing to top.

	PR c++/67273
	PR c++/79253
	* g++.dg/cpp1y/pr67273.C: New.
	* g++.dg/cpp1y/pr79253.C: New.

From-SVN: r245067
2017-01-31 18:05:37 +00:00
Nathan Sidwell 1a5bac38b5 cp-tree.h (instantiate_decl): Make defer_ok bool.
* cp-tree.h (instantiate_decl): Make defer_ok bool.
	* pt.c: Fix instantiate_decl calls to pass true/false not 0/1
	(instantiate_decl): Simplify and reorder state saving and restoration.

From-SVN: r245066
2017-01-31 16:56:44 +00:00
Nathan Sidwell 7f357c6164 re PR c++/79264 (ICE verify_type failed)
PR c++/79264
	* lambda.c (maybe_generic_this_capture): Deal with
	template-id-exprs.
	* semantics.c (finish_member_declaration): Assert class is being
	defined.

	PR c++/79264
	* g++.dg/cpp1y/pr61636-1.C: Augment.

From-SVN: r245065
2017-01-31 15:10:41 +00:00
Alexandre Oliva 8db29d88f3 Introduce C++ support in libcc1
Extend libcc1's with an API for C++ support.

Extend libcc1's C API to distinguish between integral types with the
same width, as in C++.  Likewise for float types.

Export small bits of functionality from the C++ front-end for use in
libcc1.  Add support for the C++ front-end to look up names and
addresses using a libcc1-registered binding oracle.  Add support for
global friends.


for  gcc/cp/ChangeLog

	Introduce C++ support in libcc1.
	* cp-tree.h (struct lang_identifier): Add oracle_looked_up.
	(ansi_opname): Rename to...
	(cp_operator_id): ... this.  Adjust all callers.
	(ansi_assopname): Rename to...
	(cp_assignment_operator_id): ... this.  Adjust all callers.
	(cp_literal_operator_id): Declare.
	(set_global_friend): Declare.
	(is_global_friend): Declare.
	(enum cp_oracle_request): New type.
	(cp_binding_oracle_function): New type.
	(cp_binding_oracle): Declare.
	(cp_finish_injected_record_type): Declare.
	* friend.c (global_friend): New var.
	(set_global_friend): New fn.
	(is_global_friend): New fn.
	(is_friend): Call is_global_friend.
	* name-lookup.c (cp_binding_oracle): New var.
	(query_oracle): New fn.
	(qualified_lookup_using_namespace): Call query_oracle.
	(lookup_name_real_1): Likewise.
	* parser.c (cp_literal_operator_id): Drop static.
	* search.c (friend_accessible_p): Call is_global_friend.
	* semantics.c (is_this_parameter): Accept a variable if the
	binding oracle is enabled.

for  include/ChangeLog

	Introduce C++ support in libcc1.
	* gcc-c-fe.def (int_type_v0): Rename from...
	(int_type): ... this.  Introduce new version.
	(float_type_v0): Rename from...
	(float_type): ... this.  Introduce new version.
	(char_type): New.
	* gcc-c-interface.h (gcc_c_api_version): Add GCC_C_FE_VERSION_1.
	(gcc_type_array): Move...
	* gcc-interface.h: ... here.
	* gcc-cp-fe.def: New.
	* gcc-cp-interface.h: New.

for  libcc1/ChangeLog

	Introduce C++ support.
	* Makefile.am (AM_CPPFLAGS): Move some -I flags to...
	(CPPFLAGS_FOR_C_FAMILY, CPPFLAGS_FOR_C, CPPFLAGS_FOR_CXX): ...
	new macros.
	(plugin_LTLIBRARIES): Add libcp1plugin.la.
	(BUILT_SOURCES, MOSTLYCLEANFILES): Add...
	(cp-compiler-name.h): ... this.  New.
	(c-compiler-name.h): Rename all over from...
	(compiler-name.h): ... this.  Create it atomically.
	(marshall_c_source, marshall_cxx_source): New macros.
	(libcc1plugin_la_SOURCES): Rename plugin.cc to libcc1plugin.cc.
	Add marshall_c_source expansion.
	(libcc1plugin.lo_CPPFLAGS): New macro.
	(libcp1plugin_la_LDFLAGS): Likewise.
	(libcp1plugin_la_SOURCES): Likewise.
	(libcp1plugin.lo_CPPFLAGS): Likewise.
	(libcp1plugin_la_LIBADD): Likewise.
	(libcp1plugin_la_DEPENDENCIES): Likewise.
	(libcp1plugin_la_LINK): Likewise.
	(libcc1_la_SOURCES): Added marshall_c_source and
	marshall_cxx_source expansions.
	* Makefile.in: Rebuild.
	* compiler-name.h: Rename all over to...
	* c-compiler-name.h: ... this.  Define C_COMPILER_NAME instead
	of COMPILER_NAME.
	* plugin.cc: Rename all over to...
	* libcc1plugin.cc: ... this.  Include marshall-c.hh.
	(address_rewriter): Drop cleaning up of VLA sizes.
	(plugin_build_decl): Mark decls as external.
	(plugin_tagbind): Propagate name to all variants.
	(build_anonymous_node): New.
	(plugin_build_record_type): Use it instead of make_node.
	(plugin_build_union_type): Likewise.
	(plugin_build_enum_type): Likewise.
	(plugin_finish_record_or_union): Update all type variants.
	(safe_lookup_builtin_type): New.
	(plugin_int_check): Factor out of, and add checks to, ...
	(plugin_int_type): ... this.  Rename to...
	(plugin_int_type_v0): ... this.
	(plugin_int_type): New interface, new implementation.
	(plugin_char_type): New.
	(plugin_float_type_v0): Rename from...
	(plugin_float_type): ... this.  New interface, new implementation.
	(plugin_init): Bump handshake version.
	* libcc1.cc: Include marshall-c.hh.  Drop gcc-interface.h.
	(call_binding_oracle): Rename to...
	(c_call_binding_oracle): ... this, into anonymous namespace.
	(call_symbol_address): Rename to...
	(c_call_symbol_address): ... this, likewise.
	(GCC_METHOD#): Move methods into cc1plugin::c:: namespace.
	(libcc1::compiler::find): Refer to C_COMPILER_NAME.
	(fork_exec): Bump to GCC_C_FE_VERSION_1.
	(libcc1_compile): Prefix callbacks with c_.
	(gcc_c_fe_context): Accept GCC_C_FE_VERSION_1.
	* libcc1.sym: Export gcc_cp_fe_context.
	* libcp1.cc: New, mostly copied and adjusted from libcc1.cc.
	* libcp1plugin.cc: New, initially copied from libcc1plugin.cc.
	* libcp1plugin.sym: New.
	* marshall-c.hh: New.  Move C-specific types from...
	* marshall.cc: ... this.
	(cc1_plugin::marshall_array_start): New.
	(cc1_plugin::marshall_array_elmts): New.
	(cc1_plugin::marshall for gcc_type_array): Use the above.
	(cc1_plugin::unmarshall_array_start): New.
	(cc1_plugin::unmarshall_array_elmts): New.
	(cc1_plugin::unmarshall for gcc_type_array): Use the above.
	* marshall.hh: Declare the new array building blocks.
	Drop C-specific unmarshall declarations.
	* marshall-cp.hh: New.
	* names.cc (GCC_METHOD#): Add LANG:: to method names.
	(LANG): Define while including gcc-c-fe.def and gcc-cp-fe.def.
	* names.hh: Include gcc-c-fe.def and gcc-cp-fe.def in the
	corresponding namespaces.
	* rpc.hh: Don't include marshall.hh.
	[GCC_CP_INTERFACE_H] (argument_wrapper): Specialize for
	gcc_vbase_array, gcc_cp_template_args, gcc_cp_function_args.

From-SVN: r245051
2017-01-31 01:02:03 +00:00
Jason Merrill 20f058d098 PR c++/78771 - ICE with inherited constructor.
* call.c (build_over_call): Call deduce_inheriting_ctor here.
	* pt.c (tsubst_decl): Not here.
	* class.c (add_method): Or here.
	* method.c (deduce_inheriting_ctor): Handle clones.
	(implicitly_declare_fn): Don't deduce inheriting ctors yet.

From-SVN: r244988
2017-01-27 11:48:34 -05:00
Adam Butcher bb6a6ee9db re PR c++/64382 (ICE due to use of `this` inside a lambda that captures everything by ref inside a member function of a class template)
Fix PR c++/64382

	PR c++/64382
	* cp/parser.c (parsing_default_capturing_generic_lambda_in_template):
	New function.
	* cp/cp-tree.h: Declare it.
	* cp/semantics.c (finish_id_expression): Resolve names within a default
	capturing generic lambda defined within a template prior to
	instantiation to allow for captures to be added to the closure type.

	PR c++/64382
	* g++.dg/cpp1y/pr64382.C: New test.

From-SVN: r244962
2017-01-27 07:59:06 +00:00
Jakub Jelinek 905d2812e7 re PR c++/68727 (invalid offsetof expressions accepted)
PR c++/68727
	* cp-tree.def (OFFSETOF_EXPR): Bump number of operands to 2.
	* cp-tree.h (finish_offsetof): Add OBJECT_PTR argument.
	* parser.c (cp_parser_builtin_offsetof): Pass result of
	build_static_cast of null_pointer_node to finish_offsetof.
	* semantics.c (finish_offsetof): Add OBJECT_PTR argument, use
	it for -Winvalid-offsetof pedwarn instead of trying to guess
	original offsetof type from EXPR.  Save OBJECT_PTR as a new
	second operand to OFFSETOF_EXPR.
	* pt.c (tsubst_copy_and_build) <case OFFSETOF_EXPR>: Adjust
	finish_offsetof caller, pass the second operand of OFFSETOF_EXPR
	as OBJECT_PTR.

	* g++.dg/other/offsetof8.C: Add expected error.
	* g++.dg/other/offsetof9.C: New test.

From-SVN: r244949
2017-01-26 20:39:40 +01:00
Jason Merrill 5668970a07 * name-lookup.c (parse_using_directive): Deprecate strong using.
From-SVN: r244936
2017-01-26 10:32:22 -05:00
Jason Merrill effdaefed3 PR c++/79176 - lambda ICE with -flto -Os
* decl2.c (vague_linkage_p): Handle decloned 'tors.
	* tree.c (decl_linkage): Likewise.

From-SVN: r244935
2017-01-26 10:30:43 -05:00
Martin Sebor 9f35c9535f decl.c (grokdeclarator): Fix a typo in a comment.
gcc/cp/ChangeLog:
	* decl.c (grokdeclarator): Fix a typo in a comment.
This line, and those below, will be ignored--

M    ChangeLog
M    decl.c

From-SVN: r244912
2017-01-25 17:02:25 -07:00
Martin Sebor 58feaa5f52 PR c++/71290 - Flexible array member is not diagnosed with -pedantic
gcc/cp/ChangeLog:
	PR c++/71290
	* decl.c (grokdeclarator): Warn on flexible array members.

gcc/testsuite/ChangeLog:
	PR c++/71290
	* g++.dg/ext/flexarray-mangle-2.C: Adjust.
	* g++.dg/ext/flexarray-mangle.C: Same.
	* g++.dg/ext/flexarray-subst.C: Same.
	* g++.dg/ext/flexary10.C: Same.
	* g++.dg/ext/flexary11.C: Same.
	* g++.dg/ext/flexary14.C: Same.
	* g++.dg/ext/flexary16.C: Same.
	* g++.dg/ext/flexary18.C: Same.
	* g++.dg/ext/flexary19.C: Same.
	* g++.dg/ext/flexary7.C: Same.
	* gcc/testsuite/g++.dg/cpp1z/has-unique-obj-representations1.C: Same.
	* gcc/testsuite/g++.dg/ubsan/object-size-1.C: Same.
	* gcc/testsuite/obj-c++.dg/property/at-property-23.mm: Same.

From-SVN: r244910
2017-01-25 16:11:53 -07:00
Jakub Jelinek a25608aa6f re PR c++/78896 ([C++17] Segmentation fault occurs when use variable initialized using structured binding with capture-by-ref lambda)
PR c++/78896
	* decl.c (cp_finish_decomp): Disallow memberwise decomposition of
	lambda expressions.

	* g++.dg/cpp1z/decomp24.C: New test.

From-SVN: r244909
2017-01-25 23:36:18 +01:00
Jakub Jelinek 0e3438689a re PR c++/77914 (Wrong lambda definition accepted)
PR c++/77914
	* parser.c (cp_parser_lambda_declarator_opt): Pedwarn with
	OPT_Wpedantic on lambda templates for -std=c++14 and higher.

	* g++.dg/cpp1y/lambda-generic-77914.C: New test.
	* g++.dg/cpp1y/lambda-generic-dep.C: Add -pedantic to dg-options,
	expect a warning.
	* g++.dg/cpp1y/lambda-generic-x.C: Add -Wpedantic to dg-options,
	expect warnings.
	* g++.dg/cpp1y/lambda-generic-mixed.C: Add empty dg-options.
	* g++.dg/cpp1y/pr59636.C: Likewise.
	* g++.dg/cpp1y/pr60190.C: Likewise.

From-SVN: r244907
2017-01-25 21:51:10 +01:00
Maxim Ostapenko e5e391d630 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 name.

gcc/fortran/

	* f95-lang.c (gfc_create_decls): Include stringpool.h.
	Pass main_input_filename to build_translation_unit_decl.

gcc/ada/

	* gcc-interface/utils.c (get_global_context): Pass main_input_filename
	to build_translation_unit_decl.

gcc/c/

	* c-decl.c (pop_scope): Pass main_input_filename to
	build_translation_unit_decl.

gcc/cp/

	* decl.c (cxx_init_decl_processing): Pass main_input_filename
	to build_translation_unit_decl.

From-SVN: r244890
2017-01-25 09:45:40 +02:00
Jakub Jelinek 7cfd79d60b re PR c++/79205 (ICE in create_tmp_var, at gimple-expr.c:473)
PR c++/79205
	* cp-gimplify.c (cp_genericize_r): Add result of
	convert_from_reference on invisiref parm to p_set.

	* g++.dg/cpp1z/decomp22.C: New test.
	* g++.dg/cpp1z/decomp23.C: New test.

From-SVN: r244885
2017-01-24 23:33:41 +01:00
Nathan Sidwell 1d7bc790d7 PR c++/78469 - defaulted ctor and inaccessible dtor
PR c++/78469 - defaulted ctor and inaccessible dtor
	* cp-tree.h (tsubst_flags): Add tf_no_cleanup.
	* init.c (build_new_1): Pass tf_no_cleanup to build_value_init.
	* tree.c (build_target_expr): Check tf_no_cleanup.

	PR c++/78469
	* g++.dg/cpp0x/pr78469.C: New.

From-SVN: r244882
2017-01-24 19:29:44 +00:00
Nathan Sidwell 3e4b91f275 PR c++/79118 - anon-members and constexpr
PR c++/79118 - anon-members and constexpr
	* constexpr.c (cx_check_missing_mem_inits): Caller passes type not
	ctor decl.  Recursively check anonymous members.
	(register_constexpr_fundef): Adjust cx_check_missing_mem_inits
	call.
	(explain_invalid_constexpr_fn): Likewise.


	PR c++/79118
	* g++.dg/cpp0x/pr79118.C: New.

From-SVN: r244881
2017-01-24 19:25:32 +00:00
Nathan Sidwell fc7612fd02 PR c++/71710 - template using directive of field
PR c++/71710 - template using directive of field
	* pt.c (tsubst_copy_and_build [COMPONENT_REF]): Move FIELD_DECL
	check earlier.

	PR C++/71710
	* g++.dg/template/pr71710.C: New.

From-SVN: r244833
2017-01-23 20:24:32 +00:00
Nathan Sidwell e6b8075cce PR c++/71406 - ICE with scope-ref'd template id exprs
PR c++/71406 - ICE with scope-ref'd template id exprs
	PR c++/77508
	* typeck.c (finish_class_member_access_expr): Break up SCOPE_REF
	before breaking up TEMPLATE_ID_EXPR.

	PR c++/71406
	PR c++/77508
	* g++.dg/template/pr71406.C: New.

From-SVN: r244832
2017-01-23 20:19:07 +00:00
Nathan Sidwell 4b9f211511 PR c++/78495 - wrong code inherited ctor and invisi-ref parm
PR c++/78495 - wrong code inherited ctor and invisi-ref parm
	* cp-gimplify.c (cp_generize_r): Don't skip thunks.

	PR c++/79495
	* g++.dg/cpp1z/inh-ctor38.C: New.

From-SVN: r244728
2017-01-20 17:53:44 +00:00
David Malcolm ebed71751b C++: fix fix-it hints for misspellings within explicit namespaces
gcc/cp/ChangeLog:
	PR c++/77829
	PR c++/78656
	* cp-tree.h (suggest_alternatives_for): Add bool param.
	(suggest_alternative_in_explicit_scope): New decl.
	* error.c (qualified_name_lookup_error): When SCOPE is a namespace
	that isn't the global one, call new function
	suggest_alternative_in_explicit_scope, only calling
	suggest_alternatives_for if it fails, and disabling near match
	searches fort that case.  When SCOPE is the global namespace,
	pass true for new param to suggest_alternatives_for to allow for
	fuzzy name lookups.
	* lex.c (unqualified_name_lookup_error): Pass true for new param
	to suggest_alternatives_for.
	* name-lookup.c (consider_binding_level): Add forward decl.
	(suggest_alternatives_for): Add "suggest_misspellings" param,
	using it to conditionalize the fuzzy name-lookup code.
	(suggest_alternative_in_explicit_scope): New function.
	* parser.c (cp_parser_primary_expression): When calling
	finish_id_expression, pass location of id_expression rather
	than that of id_expr_token.
	(cp_parser_id_expression): Convert local "unqualified_id" from
	tree to cp_expr to avoid implicitly dropping location information.

gcc/testsuite/ChangeLog:
	PR c++/77829
	PR c++/78656
	* g++.dg/spellcheck-pr77829.C: New test case.
	* g++.dg/spellcheck-pr78656.C: New test case.

From-SVN: r244715
2017-01-20 14:36:46 +00: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
Jason Merrill b2c06d0530 US 20 - forwarding references and class template argument deduction
* cp-tree.h (TEMPLATE_TYPE_PARM_FOR_CLASS): New.
	* pt.c (push_template_decl_real): Set it.
	(maybe_adjust_types_for_deduction): Check it.
	(rewrite_template_parm): Copy it.

From-SVN: r244682
2017-01-19 23:43:19 -05:00
Jason Merrill 689f867c9c US 19 - deduction guides and constructors
* call.c (joust): Prefer deduction guides to constructors.
	* pt.c (build_deduction_guide): Set DECL_ARTIFICIAL.
	(deduction_guide_p): Check DECL_P.

From-SVN: r244681
2017-01-19 23:43:13 -05:00
Jason Merrill a08895999d Array decomposition fix.
* decl.c (check_initializer): Always use build_aggr_init for array
	decomposition.

From-SVN: r244639
2017-01-19 10:59:04 -05:00
Jason Merrill 0655c6d556 PR c++/79130 - decomposition and direct-initialization
* init.c (build_aggr_init): Communicate direct-initialization to
	build_vec_init.
	(build_vec_init): Check for array copy sooner.
	* parser.c (cp_parser_decomposition_declaration): Remove call to
	build_x_compound_expr_from_list.

From-SVN: r244635
2017-01-19 09:37:51 -05:00
Jason Merrill 8b1346a80a PR c++/68666 - member variable template-id
* typeck.c (finish_class_member_access_expr): Handle variable
	template-id.
	* pt.c (lookup_and_finish_template_variable): No longer static.
	* cp-tree.h: Declare it.

From-SVN: r244599
2017-01-18 16:05:12 -05:00
Nathan Sidwell c484627cf6 re PR c++/78488 (P0136R1 ICE when building call to inherited default constructor.)
PR c++/78488
	* call.c (build_over_call): When checking ellipsis conversions for
	an inherited ctor, make sure there is at least one conversion.

	* g++.dg/cpp1z/inh-ctor37.C: New.

From-SVN: r244592
2017-01-18 19:27:52 +00:00
Jason Merrill 46c4e8a1cf fix date
From-SVN: r244583
2017-01-18 11:45:27 -05:00
Jason Merrill e3aeb9d39a PR c++/78894 - ICE with class deduction and default arg
* pt.c (build_deduction_guide): Set DECL_PRIMARY_TEMPLATE.

From-SVN: r244582
2017-01-18 11:44:27 -05:00
Markus Trippelsdorf 0c6299bbfd PR c++/77489 -- Reorganize abi warning check
PR c++/77489
	* mangle.c (write_discriminator): Reorganize abi warning check.

From-SVN: r244580
2017-01-18 15:49:15 +00:00
Nathan Sidwell 96176bb3f1 cp-tree.h: Clarify exception spec node comment.
* cp-tree.h: Clarify exception spec node comment.
	* except.c (nothrow_spec_p): Simplify by checking node-equality.

From-SVN: r244576
2017-01-18 12:52:24 +00:00
Nathan Sidwell 2c65d990eb re PR c++/79091 (ICE in write_unnamed_type)
PR c++/79091
	* mangle.c (write_exception_spec): Check nothrow explicitly.
	(write_encoding): Don't increment processing_template_decl around
	encoding.

	PR c++/79091
	* g++.dg/pr79091.C: New.

From-SVN: r244575
2017-01-18 12:51:28 +00:00
Markus Trippelsdorf 4bbc35f33f Fix PR70182 -- missing "on" in mangling of unresolved operators
The ABI says:

<unresolved-name>
   ::= [gs] <base-unresolved-name>
   ::= sr <unresolved-type> <base-unresolved-name>
   ::= srN <unresolved-type> <unresolved-qualifier-level>+ E <base-unresolved-name>
   ::= [gs] sr <unresolved-qualifier-level>+ E <base-unresolved-name>

<base-unresolved-name>
   ::= <simple-id>
   ::= on <operator-name>
   ::= on <operator-name> <template-args>
   ::= dn <destructor-name

libiberty:

	PR c++/70182
	* cp-demangle.c (d_unqualified_name): Handle "on" for
	operator names.
	* testsuite/demangle-expected: Add tests.

gcc/cp:

	PR c++/70182
	* mangle.c (write_template_args): Add "on" for operator names.

gcc:

	PR c++/70182
	* doc/invoke.texi (fabi-version): Mention mangling fix for
	operator names.

From-SVN: r244567
2017-01-18 08:49:11 +00:00
Markus Trippelsdorf f6efea5163 Fix PR77489 -- mangling of discriminator >= 1
libiberty:

	PR c++/77489
	* cp-demangle.c (d_discriminator): Handle discriminator >= 10.
	* testsuite/demangle-expected: Add tests for discriminator.

gcc:
	PR c++/77489
	* doc/invoke.texi (fabi-version): Document discriminator mangling.

gcc/cp:

	PR c++/77489
	* mangle.c (write_discriminator): Handle discriminator >= 10.

From-SVN: r244566
2017-01-18 08:40:05 +00:00
Nathan Sidwell 8ddfdbc265 re PR c++/61636 (generic lambda: segfault / "cannot call member function without object")
PR c++/61636
	* cp-tree.h (maybe_generic_this_capture): Declare.
	* lambda.c (resolvable_dummy_lambda): New, broken out of ...
	(maybe_resolve_dummy): ... here.  Call it.
	(maybe_generic_this_capture): New.
	* parser.c (cp_parser_postfix_expression): Speculatively capture
	this in generic lambda in unresolved member function call.
	* pt.c (tsubst_copy_and_build): Force hard error from failed
	member function lookup in generic lambda.

	PR c++/61636
	* g++.dg/cpp1y/pr61636-1.C: New.
	* g++.dg/cpp1y/pr61636-2.C: New.
	* g++.dg/cpp1y/pr61636-3.C: New.

From-SVN: r244544
2017-01-17 18:22:34 +00:00
Aldy Hernandez 893ffa2c8f re PR c++/70565 (ICE at gimplify.c:8832 (cilkplus array extension))
PR c++/70565
	* cp-array-notation.c (expand_array_notation_exprs): Handle
	OMP_PARALLEL.

From-SVN: r244538
2017-01-17 16:54:55 +00:00
Jason Merrill 91d01bf40a PR c++/78337 - ICE on invalid with generic lambda
* semantics.c (process_outer_var_ref): Check if containing_function
	is null.  Move inform call under complain test.

From-SVN: r244340
2017-01-11 16:43:42 -05:00
Nathan Sidwell 01bfd25762 re PR c++/77812 (incorrectly rejects valid C++ code that uses enum in template instantiation)
cp/
	PR c++/77812
	* name-lookup.c (set_namespace_binding_1): An overload of 1 decl
	is a new overload.

	testsuite/
	PR c++/77812
	* g++.dg/pr77812.C: New.

From-SVN: r244335
2017-01-11 20:37:16 +00:00
Nathan Sidwell 5b33cc835c * name-lookup.c (push_overloaded_decl_1): Refactor OVERLOAD creation.
From-SVN: r244334
2017-01-11 20:11:56 +00:00
Jakub Jelinek 1f258a55a9 re PR c++/78341 (ICE on invalid C++ code on x86_64-linux-gnu (internal compiler error: in cp_parser_std_attribute_spec, at cp/parser.c:24597))
PR c++/78341
	* parser.c (cp_parser_std_attribute_spec): Remove over-eager
	assertion.  Formatting fix.

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

From-SVN: r244329
2017-01-11 19:09:58 +01:00
Jakub Jelinek 6b5b4e9cec re PR c++/72813 (atomic header cannot be compiled into translation unit with -fkeep-inline-functions)
PR c++/72813
	* gcc.c (default_compilers): Don't add -o %g.s for -S -save-temps
	of c-header.

	* c-decl.c (pop_file_scope): Set flag_syntax_only to 1 after writing
	PCH file.

	* decl2.c (c_parse_final_cleanups): Set flag_syntax_only to 1 after
	writing PCH file.

From-SVN: r244328
2017-01-11 19:08:57 +01:00
David Malcolm b9f4757f8e Fix issues with unrepresentable column numbers (PR c++/77949)
PR c++/77949 identifies an ICE when the C++ frontend attempts to emit a
fix-it hint inserting a missing semicolon at column 4097 of a source file.

This column value exceeds LINE_MAP_MAX_COLUMN_NUMBER and hence isn't
representable using a location_t.

Attempting to do so leads to these problems, which this patch fixes:

(a) when encountering a column number > LINE_MAP_MAX_COLUMN_NUMBER we
create a new linemap with m_column_and_range_bits == 0, but
linemap_position_for_column doesn't check for this, and hence can emit
a bogus location_t value that's calculated relative to the previous
linemap start, but which will be decoded relative to the new linemap,
leading to very large incorrect line values.

(b) when encountering a column number that can't be represented, and
for which the linemap was pre-existing, the code would hit this assertion:
  if (linemap_assert_fails (column < (1u << map->m_column_and_range_bits)))
around a bail-out condition.  The patch replaces this assertion with a
simple conditional, to stop the ICE when this occurs, and fixes the
bit count (effective column bits, vs column+range bits)

(c) the C++ frontend wasn't checking for failure of
linemap_position_for_loc_and_offset when considering emitting the fix-it
hint.  The patch adds a conditional, so that no fix-it hint is emitted
if the location is bogus.

gcc/cp/ChangeLog:
	PR c++/77949
	* parser.c (cp_parser_class_specifier_1): Only suggest inserting
	a missing semicolon if we have a valid insertion location for
	the fix-it hint.

gcc/ChangeLog:
	PR c++/77949
	* input.c (selftest::test_accessing_ordinary_linemaps): Verify
	that we correctly handle column numbers greater than
	LINE_MAP_MAX_COLUMN_NUMBER.

gcc/testsuite/ChangeLog:
	PR c++/77949
	* g++.dg/diagnostic/pr77949.C: New test case.

libcpp/ChangeLog:
	PR c++/77949
	* line-map.c (linemap_position_for_column): When calling
	linemap_start_line, detect if a new linemap was created with
	0 column bits, and bail out early if this is the case.
	(linemap_position_for_loc_and_offset): Replace overzealous
	linemap_assert_fails with a simple conditional; use correct
	bit count.

From-SVN: r244292
2017-01-10 21:54:09 +00:00
Jason Merrill 2af5cb5013 FI 20, decomposition declaration with parenthesized initializer.
* parser.c (cp_parser_decomposition_declaration): Use
	cp_parser_initializer.

From-SVN: r244282
2017-01-10 14:04:22 -05:00
Jason Merrill f4da28a0ab Implement P0195R2, C++17 variadic using.
* parser.c (cp_parser_using_declaration): Handle ellipsis and comma.
	* pt.c (tsubst_decl): Handle pack expansion in USING_DECL_SCOPE.
	* error.c (dump_decl): Likewise.

From-SVN: r244246
2017-01-09 16:51:08 -05: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
Jason Merrill 38285dd719 PR c++/78948 - instantiation from discarded statement
PR c++/78948 - instantiation from discarded statement
	* parser.h (struct cp_parser): Remove in_discarded_stmt field.
	* cp-tree.h (in_discarded_stmt): Declare it.
	(struct saved_scope): Add discarded_stmt bitfield.
	(in_discarded_stmt): New macro.
	* decl2.c (mark_used): Check it.
	* parser.c (cp_parser_selection_statement): Adjust.
	(cp_parser_jump_statement): Adjust.

From-SVN: r244206
2017-01-08 01:36:10 -05:00
Jakub Jelinek 26f203712b re PR c++/78931 (ICE on C++17 structured bindings from struct with reference member)
PR c++/78931
	* decl.c (cp_finish_decomp): Remove probe variable, if tt is
	REFERENCE_REF_P, set tt to its operand.

	* g++.dg/cpp1z/decomp19.C: New test.

From-SVN: r244113
2017-01-05 22:13:09 +01:00
Jakub Jelinek 962c5679b3 re PR c++/78890 (ICE on invalid reference type in union)
PR c++/78890
	* class.c (check_field_decls): Diagnose REFERENCE_TYPE fields in
	unions even for C++11 and later.

	* g++.dg/init/ref14.C: Expect error even in C++11 and later.
	* g++.dg/init/union1.C: Likewise.
	* g++.dg/cpp0x/union6.C: Expect errors.
	* g++.dg/cpp0x/union8.C: New test.
	* g++.dg/cpp0x/pr78890-1.C: New test.
	* g++.dg/cpp0x/pr78890-2.C: New test.

From-SVN: r244112
2017-01-05 22:12:02 +01:00
Nathan Sidwell dc7650cc6d re PR c++/78765 (ICE on invalid C++ code on x86_64-linux-gnu (internal compiler error: in cp_build_addr_expr_1, at cp/typeck.c:5708))
cp/
	PR c++/78765
	* pt.c (convert_nontype_argument): Don't try and see if integral
	or enum expressions are constants prematurely.

	testsuite/
	PR c++/78765
	* g++.dg/cpp0x/pr78765.C: New.

From-SVN: r244101
2017-01-05 12:30:26 +00:00
Marek Polacek a9342885b1 re PR c++/64767 (Could GCC warn when a pointer is compared against '\0'?)
PR c++/64767
	* c.opt (Wpointer-compare): New option.

	* c-parser.c (c_parser_postfix_expression): Mark zero character
	constants by setting original_type in c_expr.
	* c-typeck.c (parser_build_binary_op): Warn when a pointer is compared
	with a zero character constant.
	(char_type_p): New function.

	* typeck.c (cp_build_binary_op): Warn when a pointer is compared with
	a zero character literal.

	* doc/invoke.texi: Document -Wpointer-compare.

	* c-c++-common/Wpointer-compare-1.c: New test.

From-SVN: r244076
2017-01-04 21:47:04 +00:00
Jakub Jelinek abec4284a6 re PR c++/78949 (incorrect "unused variable" warning with SSE2)
PR c++/78949
	* typeck.c (cp_build_unary_op): Call mark_rvalue_use on arg if it has
	vector type.

	* c-c++-common/Wunused-var-16.c: New test.

From-SVN: r244075
2017-01-04 22:34:27 +01:00
Jakub Jelinek 26c43e2744 re PR c++/78693 (Bogus 'inconsistent deduction for ‘auto’' error when having a dependent initializer and a nondependent one in the same declaration)
PR c++/78693
	* parser.c (cp_parser_simple_declaration): Only complain about
	inconsistent auto deduction if auto_result doesn't use auto.

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

From-SVN: r244074
2017-01-04 22:30:35 +01:00
Jakub Jelinek c9cf3863bd parser.c (cp_parser_simple_declaration): Diagnose function declaration among more than one init-declarators with auto...
* parser.c (cp_parser_simple_declaration): Diagnose function
	declaration among more than one init-declarators with auto
	specifier.

	* g++.dg/cpp1y/auto-fn34.C: New test.

From-SVN: r244071
2017-01-04 21:13:14 +01:00
Jakub Jelinek 066435fe10 re PR c++/71182 (parser.c cp_lexer_previous_token sanitizer detects member call on null pointer)
PR c++/71182
	* parser.c (cp_lexer_previous_token): Use vec_safe_address in the
	assertion, as lexer->buffer may be NULL.

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

From-SVN: r244070
2017-01-04 21:05:14 +01:00
Marek Polacek baf9ebc8cc re PR c++/77545 (ICE on valid C++11 code: in potential_constant_expression_1, at cp/constexpr.c:5480)
PR c++/77545
	PR c++/77284
	* constexpr.c (potential_constant_expression_1): Handle CLEANUP_STMT.

	* g++.dg/cpp0x/range-for32.C: New test.
	* g++.dg/cpp0x/range-for33.C: New test.

From-SVN: r244062
2017-01-04 17:47:04 +00:00
Nathan Sidwell 4bf07f3f5f re PR c++/66735 ([C++14] lambda init-capture fails for const references)
cp/
	PR c++/66735
	* cp-tree.h (DECLTYPE_FOR_REF_CAPTURE): New.
	(lambda_capture_field_type): Update prototype.
	* lambda.c (lambda_capture_field_type): Add is_reference parm.
	Add referenceness here.
	(add_capture): Adjust lambda_capture_field_type call, refactor
	error checking.
	* pt.c (tsubst): Adjust lambda_capture_field_type call.

	testsuite/
	PR c++/66735
	* g++.dg/cpp1y/pr66735.C: New.

From-SVN: r244056
2017-01-04 15:23:40 +00:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Jakub Jelinek 6b56d5f57d re PR middle-end/78901 (ICE: verify_gimple failed (error: statement marked for throw in middle of block))
PR middle-end/78901
	* except.c (nothrow_libfn_p): Expect libc_name_p to return
	const struct libc_name_struct *, if it returns NULL, return 0,
	otherwise check c_ver and use flag_isoc99 or flag_isoc11.
	* cfns.gperf: Add %struct-type and libc_name_struct definition.
	For all C89 C library functions add , 89 after the name, add
	C99 C library functions with , 99 and C11 C library functions
	with , 11 suffix.
	* cfns.h: Regenerated.

From-SVN: r243914
2016-12-24 12:15:44 +01:00
Jason Merrill bcf77f8ae6 PR c++/78906 - ICE with member variable template
* pt.c (finish_template_variable): Use most_general_template.

From-SVN: r243897
2016-12-22 15:29:07 -05:00
Jason Merrill dd809fdeca PR c++/78898 - ICE on constructor with TTP
PR c++/42329
	* pt.c (unify): Don't look for a class template from a non-class.

From-SVN: r243890
2016-12-22 10:19:54 -05:00
Jakub Jelinek b5f8e89ed7 re PR c++/72707 (local anonymous union member hides names in the same scope)
PR c++/72707
	* name-lookup.c (pushdecl_maybe_friend_1): Do check shadowing of
	artificial x if it is an anonymous union variable.

	* g++.dg/warn/Wshadow-12.C: New test.

From-SVN: r243877
2016-12-21 23:49:59 +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
Jakub Jelinek bc2a38dff8 re PR c++/77830 (internal compiler error: in output_constructor_regular_field, at varasm.c:4968, when using constexpr (with testcase))
PR c++/77830
	* constexpr.c (cxx_eval_array_reference): Perform out of bounds
	verification even if lval is true, just allow one past the last
	element in that case.
	(cxx_eval_store_expression): Detect stores to out of bound
	ARRAY_REF.

	* g++.dg/cpp1y/pr77830.C: New test.
	* g++.dg/cpp0x/pr65398.C: Adjust expected diagnostics.

From-SVN: r243873
2016-12-21 22:58:23 +01:00
Jason Merrill 31bfc9b9dd Implement P0522R0, matching of template template arguments.
gcc/c-family/
	* c.opt (-fnew-ttp-matching): New flag.
	* c-opts.c (c_common_post_options): Default on if -std=c++1z.
gcc/cp/
	* pt.c (coerce_template_template_parms): Allow a template argument
	that's less specialized than the parameter.
	(unify_bound_ttp_args): Adjust parm's args to apply to arg's
	template.
	(coerce_template_args_for_ttp): Split out from
	lookup_template_class_1.
	(coerce_ttp_args_for_tta, store_defaulted_ttp)
	(lookup_defaulted_ttp, add_defaults_to_ttp): New.
	(process_partial_specialization): Set DECL_CONTEXT of
	template template-parameters.
	(coerce_template_parms): Only inform when complain.
	(expand_template_argument_pack): Handle error_mark_node.
	(convert_template_argument, template_args_equal, unify): Handle
	any_targ_node.
	* cp-tree.h (enum cp_tree_index): Add CPTI_ANY_TARG.
	(any_targ_node): New.
	* decl.c (cxx_init_decl_processing): Set it.
	* name-lookup.c (consider_binding_level): Ignore names with embedded
	spaces.

From-SVN: r243871
2016-12-21 14:39:04 -05:00
Jason Merrill 3c75aaa3d8 PR c++/42329 - deducing base template for template template arg
* pt.c (unify_bound_ttp_args): Split out from unify.
	(try_class_unification): Handle BOUND_TEMPLATE_TEMPLATE_PARM.
	(unify): Check for type/non-type mismatch early.
	[BOUND_TEMPLATE_TEMPLATE_PARM]: Try get_template_base.

From-SVN: r243870
2016-12-21 14:38:50 -05:00
Jason Merrill 57a6add274 Fix handling of explicit function template arguments with TTPs.
gcc/cp/
	* pt.c (coerce_template_parms): Consider variadic_args_p before
	complaining about too many template arguments.
libstdc++-v3/
	* testsuite/util/testsuite_tr1.h (test_property): Don't define both
	variadic and non-variadic overloads.

From-SVN: r243869
2016-12-21 14:38:44 -05:00
Jason Merrill a9410b4fe9 Check that a partial specialization is more specialized.
* pt.c (process_partial_specialization): Use
	get_partial_spec_bindings to check that the partial specialization
	is more specialized than the primary template.

From-SVN: r243868
2016-12-21 14:38:35 -05:00
Jason Merrill a93634ba09 Fixes for P0127R2 implementation.
* pt.c (convert_template_argument): Pass args to do_auto_deduction.
	(mark_template_parm): Handle deducibility from type of non-type
	argument here.
	(for_each_template_parm_r): Not here.

From-SVN: r243867
2016-12-21 14:38:29 -05:00
Jason Merrill 0856b5d78d Improve C++ debug_tree.
* ptree.c (cxx_print_type): Print args of
	BOUND_TEMPLATE_TEMPLATE_PARM.
	(cxx_print_decl): Print DECL_TEMPLATE_PARMS.

From-SVN: r243865
2016-12-21 14:11:41 -05:00
Jason Merrill 0bcd172dbf PR c++/78767 - ICE with inherited constructor default argument
* method.c (strip_inheriting_ctors): Strip template as appropriate.

From-SVN: r243864
2016-12-21 14:10:23 -05:00
Jason Merrill 8f0db5664a PR c++/78749 - friend in anonymous namespace
* decl.c (wrapup_globals_for_namespace): Don't complain about friend
	pseudo-template instantiations.

From-SVN: r243862
2016-12-21 13:28:54 -05:00
Richard Biener b7fc43d7c7 re PR c++/71694 (store-data race with bitfields and tail-padding in C++)
2016-12-16  Richard Biener  <rguenther@suse.de>

	PR c++/71694
	* langhooks-def.h (lhd_unit_size_without_reusable_padding): Declare.
	(LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING): Define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Adjust.
	* langhooks.h (struct lang_hooks_for_types): Add
	unit_size_without_reusable_padding.
	* langhooks.c (lhd_unit_size_without_reusable_padding): New.
	* stor-layout.c (finish_bitfield_representative): Use
	unit_size_without_reusable_padding langhook to decide on the
	last representatives size.

	cp/
	* cp-objcp-common.h (cp_unit_size_without_reusable_padding): Declare.
	(LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING): Define.
	* cp-objcp-common.c (cp_unit_size_without_reusable_padding): New.

	* g++.dg/pr71694.C: New testcase.

From-SVN: r243738
2016-12-16 09:40:03 +00:00
Jakub Jelinek ce7888dae8 P0490R0 GB 20: decomposition declaration should commit to tuple interpretation early
P0490R0 GB 20: decomposition declaration should commit to tuple
	interpretation early
	* decl.c (get_tuple_size): Make static.  If inst is error_mark_node
	or non-complete type, return NULL_TREE, otherwise if
	lookup_qualified_name fails or doesn't fold into INTEGER_CST, return
	error_mark_node.
	(get_tuple_element_type, get_tuple_decomp_init): Make static.
	(cp_finish_decomp): Pass LOC to get_tuple_size.  If it returns
	error_mark_node, complain and fail.

	* g++.dg/cpp1z/decomp10.C (f1): Adjust expected diagnostics.

From-SVN: r243724
2016-12-15 21:42:11 +01:00
Nathan Sidwell 2a810dedce re PR c++/77585 (g++ incorrectly decides that member function is called without object in generic lambda)
PR c++/77585
	* pt.c (instantiate_decl): Push to class scope lambda resides
	within when instantiating a generic lambda function.

	PR c++/77585
	* g++.dg/cpp1y/pr77585.C: New.

From-SVN: r243723
2016-12-15 19:50:25 +00:00
Martin Sebor 1750f2a55a PR c++/78774 - [6/7 Regression] ICE in constexpr string literals and templates
gcc/cp/ChangeLog:

	PR c++/78774
	* pt.c (convert_template_argument): Avoid assuming operand type
	is non-null since that of SCOPE_REF is not.

gcc/testsuite/ChangeLog:

	PR c++/78774
	* g++.dg/cpp1y/pr78774.C: New test.

From-SVN: r243683
2016-12-14 20:08:14 -07: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
Marek Polacek 964b79eb33 re PR c++/72775 (internal compiler error: in finish_expr_stmt, at cp/semantics.c:677)
PR c++/72775
	* init.c (perform_member_init): Diagnose member initializer for
	flexible array member. 

	* g++.dg/ext/flexary12.C: Adjust dg-error.
	* g++.dg/ext/flexary20.C: New.
	* g++.dg/ext/flexary21.C: New.

From-SVN: r243669
2016-12-14 20:41:43 +00:00
Nathan Sidwell b4ba085209 re PR c++/78701 (ICE: unexpected expression N of kind template_parm_index)
PR c++/78701
	* pt.c (type_unification_real): Check tsubst arg doesn't have
	remaining template parms before converting it.

	PR c++/78701
	* g++.dg/cpp0x/pr78701.C: New.

From-SVN: r243657
2016-12-14 16:45:33 +00:00
Nathan Sidwell fa0c02c38c re PR c++/69481 (ICE with C++11 alias using with templates)
PR c++/69481
	* cp-tree.h (TYPE_TEMPLATE_INFO_MAYBE_ALIAS): Always use
	TYPE_ALIAS_TEMPLATE_INFO for aliases.

From-SVN: r243656
2016-12-14 16:43:07 +00:00
Nathan Sidwell 5bfd81e715 re PR c++/69481 (ICE with C++11 alias using with templates)
cp/
	PR c++/69481
	* cp-tree.h (TYPE_TEMPLATE_INFO): Remove alias type checking.
	(TYPE_ALIAS_TEMPLATE_INFO): New.
	(TYPE_TEMPLATE_INFO_MAYBE_ALIAS): New.  Use those macros.
	* error.c (dump_alias_template_specialization): Adjust.
	* pt.c (maybe_process_partial_specialization)
	iterative_has_template_arg, find_parameter_packs_r,
	alias_template_specialization_p, dependent_alias_template_spec_p,
	get_underlying_template, lookup_template_class_1, unify): Adjust
	template using decl access.

	testsuite/
	PR c++/69481
	* g++.dg/cpp0x/pr69481.C: New.
(--This line, and those below, will be ignored--

M    gcc/testsuite/ChangeLog
A    gcc/testsuite/g++.dg/cpp0x/pr69481.C
M    gcc/cp/cp-tree.h
M    gcc/cp/error.c
M    gcc/cp/ChangeLog
M    gcc/cp/pt.c

From-SVN: r243624
2016-12-13 20:43:08 +00:00
Paolo Carlini a1f7d967aa re PR c++/78637 (ICE on invalid C++ code on x86_64-linux-gnu (internal compiler error: in pop_namespace, at cp/name-lookup.c:3826))
/cp
2016-12-11  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/78637
	* parser.c (cp_parser_namespace_definition): Increment
	nested_definition_count only if push_namespace succeeds.

/testsuite
2016-12-11  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/78637
	* g++.dg/parse/namespace14.C: New.

From-SVN: r243529
2016-12-11 18:15:31 +00:00
Nathan Sidwell d6b46fca8d re PR c++/78551 (Internal compiler error with constexpr initialization of union)
PR c++/78551
	* constexpr.c (extract_string_elt): New.  Broken out of ...
	(cxx_eval_array_reference): ... here.  Call it.
	(cxx_eval_store_expression): Convert init by STRING_CST into
	CONSTRUCTOR, if needed.

	PR c++/78551
	* g++.dg/cpp1y/pr78551.C: New.

From-SVN: r243448
2016-12-08 18:34:04 +00:00
Jakub Jelinek 1d09844a1c P0003R5 - removal of dynamic exception specification from C++17
P0003R5 - removal of dynamic exception specification from C++17
	* parser.c (cp_parser_exception_specification_opt): For C++17
	error out on throw ( type-id-list ), for C++11 and C++14 issue
	-Wdeprecated warning on it.  Formatting fix.  Treat throw()
	in C++17 as noexcept(true).

	* g++.dg/compat/eh/ctor1.h: Adjust for deprecation of
	throw (type-id-list) in C++11 and C++14 and removal in C++17.
	* g++.dg/compat/eh/ctor1_y.C: Likewise.
	* g++.dg/compat/eh/new1_x.C: Likewise.
	* g++.dg/compat/eh/new1_y.C: Likewise.
	* g++.dg/compat/eh/spec3_x.C: Likewise.
	* g++.dg/compat/eh/spec3_y.C: Likewise.
	* g++.dg/compat/eh/template1.h: Likewise.
	* g++.dg/compat/eh/template1_y.C: Likewise.
	* g++.dg/compat/eh/unexpected1_x.C: Likewise.
	* g++.dg/compat/eh/unexpected1_y.C: Likewise.
	* g++.dg/cpp0x/auto9.C: Likewise.
	* g++.dg/cpp0x/defaulted23.C: Likewise.
	* g++.dg/cpp0x/error5.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-eh2.C: Likewise.
	* g++.dg/cpp0x/noexcept02.C: Likewise.
	* g++.dg/cpp0x/noexcept07.C: Likewise.
	* g++.dg/cpp0x/noexcept08.C: Likewise.
	* g++.dg/cpp0x/noexcept19.C: Likewise.
	* g++.dg/cpp0x/variadic73.C: Likewise.
	* g++.dg/cpp0x/variadic-throw.C: Likewise.
	* g++.dg/cpp1z/noexcept-type1.C: Likewise.
	* g++.dg/eh/async-unwind2.C: Likewise.
	* g++.dg/eh/cond4.C: Likewise.
	* g++.dg/eh/delete1.C: Likewise.
	* g++.dg/eh/ehopt1.C: Likewise.
	* g++.dg/eh/forced3.C: Likewise.
	* g++.dg/eh/forced4.C: Likewise.
	* g++.dg/eh/init-temp2.C: Likewise.
	* g++.dg/eh/pr38662.C: Likewise.
	* g++.dg/eh/pr41819.C: Likewise.
	* g++.dg/eh/shadow1.C: Likewise.
	* g++.dg/eh/spec2.C: Likewise.
	* g++.dg/eh/spec3.C: Likewise.
	* g++.dg/eh/spec5.C: Likewise.
	* g++.dg/eh/spec6.C: Likewise.
	* g++.dg/eh/spec7.C: Likewise.
	* g++.dg/eh/spec8.C: Likewise.
	* g++.dg/eh/spec9.C: Likewise.
	* g++.dg/eh/template1.C: Likewise.
	* g++.dg/eh/unexpected1.C: Likewise.
	* g++.dg/ext/has_nothrow_assign.C: Likewise.
	* g++.dg/ext/has_nothrow_constructor.C: Likewise.
	* g++.dg/ext/has_nothrow_copy-1.C: Likewise.
	* g++.dg/ext/has_nothrow_copy-2.C: Likewise.
	* g++.dg/ext/has_nothrow_copy-4.C: Likewise.
	* g++.dg/ext/has_nothrow_copy-5.C: Likewise.
	* g++.dg/ext/has_nothrow_copy-6.C: Likewise.
	* g++.dg/ext/has_nothrow_copy-7.C: Likewise.
	* g++.dg/gcov/gcov-7.C: Likewise.
	* g++.dg/init/new13.C: Likewise.
	* g++.dg/init/new25.C: Likewise.
	* g++.dg/lookup/exception1.C: Likewise.
	* g++.dg/opt/noreturn-1.C: Likewise.
	* g++.dg/other/error3.C: Likewise.
	* g++.dg/rtti/crash3.C: Likewise.
	* g++.dg/template/eh2.C: Likewise.
	* g++.dg/template/error36.C: Likewise.
	* g++.dg/tm/pr46567.C: Likewise.
	* g++.dg/tm/pr47340.C: Likewise.
	* g++.dg/torture/pr46364.C: Likewise.
	* g++.dg/torture/pr49394.C: Likewise.
	* g++.dg/torture/pr52918-1.C: Likewise.
	* g++.dg/torture/pr57190.C: Likewise.
	* g++.dg/torture/stackalign/eh-alloca-1.C: Likewise.
	* g++.dg/torture/stackalign/eh-fastcall-1.C: Likewise.
	* g++.dg/torture/stackalign/eh-global-1.C: Likewise.
	* g++.dg/torture/stackalign/eh-inline-1.C: Likewise.
	* g++.dg/torture/stackalign/eh-inline-2.C: Likewise.
	* g++.dg/torture/stackalign/eh-thiscall-1.C: Likewise.
	* g++.dg/torture/stackalign/eh-vararg-1.C: Likewise.
	* g++.dg/torture/stackalign/eh-vararg-2.C: Likewise.
	* g++.dg/tree-ssa/pr45605.C: Likewise.
	* g++.dg/warn/Wreturn-type-3.C: Likewise.
	* g++.old-deja/g++.eh/badalloc1.C: Likewise.
	* g++.old-deja/g++.eh/cleanup2.C: Likewise.
	* g++.old-deja/g++.eh/spec1.C: Likewise.
	* g++.old-deja/g++.eh/spec2.C: Likewise.
	* g++.old-deja/g++.eh/spec3.C: Likewise.
	* g++.old-deja/g++.eh/spec4.C: Likewise.
	* g++.old-deja/g++.eh/spec6.C: Likewise.
	* g++.old-deja/g++.eh/throw1.C: Likewise.
	* g++.old-deja/g++.eh/throw2.C: Likewise.
	* g++.old-deja/g++.eh/tmpl1.C: Likewise.
	* g++.old-deja/g++.eh/tmpl3.C: Likewise.
	* g++.old-deja/g++.mike/eh15.C: Likewise.
	* g++.old-deja/g++.mike/eh25.C: Likewise.
	* g++.old-deja/g++.mike/eh33.C: Likewise.
	* g++.old-deja/g++.mike/eh34.C: Likewise.
	* g++.old-deja/g++.mike/eh50.C: Likewise.
	* g++.old-deja/g++.mike/eh51.C: Likewise.
	* g++.old-deja/g++.mike/eh55.C: Likewise.
	* g++.old-deja/g++.mike/p10416.C: Likewise.
	* g++.old-deja/g++.other/crash28.C: Likewise.
	* g++.old-deja/g++.other/crash30.C: Likewise.
	* g++.old-deja/g++.other/new7.C: Likewise.
	* g++.old-deja/g++.pt/ehspec1.C: Likewise.
	* g++.old-deja/g++.robertl/eb123.C: Likewise.

	* testsuite/util/testsuite_new_operators.h: Include testsuite_hooks.h.
	(operator new): Use THROW macro.

From-SVN: r243429
2016-12-08 09:26:06 +01:00
Martin Jambor 716c5aced1 Use dump_function_name rather than emit <built-in>
2016-12-07  Martin Jambor  <mjambor@suse.cz>

	PR c++/78589
	* error.c (dump_decl): Use dump_function_name to dump
	!DECL_LANG_SPECIFIC function decls with no or self-referencing
	abstract origin.

From-SVN: r243344
2016-12-07 14:09:07 +01:00
Nathan Sidwell 098eae0067 pt.c (tsubst <{NON,}TYPE_ARGUMENT_PACK>): Simplify control flow and avoid re-tsubsting type.
* pt.c (tsubst <{NON,}TYPE_ARGUMENT_PACK>: Simplify control flow
	and avoid re-tsubsting type.

From-SVN: r243343
2016-12-07 13:00:02 +00:00
Nathan Sidwell b3235e974f cp-tree.h (enum cp_tree_index): Add CPTI_AUTO_IDENTIFIER & CPTI_DECLTYPE_AUTO_IDENTIFIER.
* cp-tree.h (enum cp_tree_index): Add CPTI_AUTO_IDENTIFIER &
	CPTI_DECLTYPE_AUTO_IDENTIFIER.
	(auto_identifier, decltype_auto_identifier): New.
	*decl.c (initialize_predefined_identifiers): Add 'auto' and
	'decltype(auto)'.
	(grokdeclarator): Use cached identifier.
	* pt.c (make_decltype_auto, make_auto, make_constrained_auto,
	is_auto): Likewise.

From-SVN: r243342
2016-12-07 12:52:39 +00:00
Jakub Jelinek a3f7c896a5 re PR c++/78649 (ICE on invalid C++ code on x86_64-linux-gnu (internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in build_value_init_noctor, at cp/init.c:380))
PR c++/78649
	* pt.c (tsubst_init): Don't call build_value_init if decl's type
	is error_mark_node.

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

From-SVN: r243204
2016-12-02 22:23:22 +01:00
Cesar Philippidis c5af52eb8c c-parser.c (c_parser_pragma): Error when PRAGMA_OACC_{ENTER_DATA...
gcc/c/
	* c-parser.c (c_parser_pragma): Error when PRAGMA_OACC_{ENTER_DATA,
	EXIT_DATA,WAIT} are not used in compound statements.
	(c_parser_oacc_enter_exit_data): Update diagnostics.

	gcc/cp/
	* parser.c (cp_parser_oacc_enter_exit_data): Update diagnostics.
	(cp_parser_pragma): Error when PRAGMA_OACC_{ENTER_DATA,
	EXIT_DATA,WAIT} are not used in compound statements.

	gcc/testsuite/
	* c-c++-common/goacc/data-2.c: Adjust test.
	* c-c++-common/goacc/executeables-1.c: New test.
	* g++.dg/goacc/data-1.C: Adjust test.


Co-Authored-By: James Norris <jnorris@codesourcery.com>

From-SVN: r243185
2016-12-02 06:54:39 -08:00
Jason Merrill 310a7f9699 call.c (add_function_candidate): Also exclude inherited ctors that take a type reference-related to the derived...
* call.c (add_function_candidate): Also exclude inherited ctors
	that take a type reference-related to the derived class.

From-SVN: r243178
2016-12-02 08:58:32 -05:00
Jason Merrill 03e88100e1 call.c (add_function_candidate): Exclude inherited copy/move ctors.
* call.c (add_function_candidate): Exclude inherited copy/move
	ctors.

From-SVN: r243138
2016-12-01 17:13:06 -05:00
Jason Merrill c1ff51dc9f fix PR number
From-SVN: r243137
2016-12-01 17:10:57 -05:00
David Malcolm 8bf3cdff10 spellcheck bugfixes: don't offer the goal string as a suggestion
gcc/cp/ChangeLog:
	PR c++/77922
	* name-lookup.c (lookup_name_fuzzy): Filter out reserved words
	that were filtered out by init_reswords.

gcc/ChangeLog:
	PR c++/72774
	PR c++/72786
	PR c++/77922
	PR c++/78313
	* spellcheck.c (selftest::test_find_closest_string): Verify that
	we don't offer the goal string as a suggestion.
	* spellcheck.h (best_match::get_best_meaningful_candidate): Don't
	offer the goal string as a suggestion.

gcc/testsuite/ChangeLog:
	PR c++/72774
	PR c++/72786
	PR c++/77922
	PR c++/78313
	* g++.dg/spellcheck-c++-11-keyword.C: New test case.
	* g++.dg/spellcheck-macro-ordering.C: New test case.
	* g++.dg/spellcheck-pr78313.C: New test case.

From-SVN: r242965
2016-11-29 16:25:01 +00:00
Jakub Jelinek f28fd43ea8 re PR c++/72808 (ICE on valid c++ code in verify_type (gcc/tree.c:14047))
PR c++/72808
	* decl.c (finish_enum_value_list): Call fixup_type_variants on
	current_class_type after
	insert_late_enum_def_into_classtype_sorted_fields.

	* g++.dg/debug/pr72808.C: New test.

Co-Authored-By: Jason Merrill <jason@redhat.com>

From-SVN: r242930
2016-11-28 20:20:02 +01:00
Jakub Jelinek f4bb5c171e re PR c++/77591 (decltype(auto) and ternary operator allow returning local reference without a warning)
PR c++/77591
	* typeck.c (maybe_warn_about_returning_address_of_local): Optimize
	whats_returned through fold_for_warn.

	* g++.dg/cpp1y/pr77591.C: New test.

From-SVN: r242924
2016-11-28 16:21:53 +01:00
Jason Merrill f9438bbb2e PR c++/77907 - static init and PMF
* constexpr.c (cxx_eval_constant_expression): Use cp_fold_convert.

From-SVN: r242906
2016-11-27 23:00:36 -05:00
Martin Liska bf2df7a9b3 cp_parser_range_for: use safe_push instead of quick_push (PR
PR bootstrap/78493
	* parser.c (cp_parser_range_for): Use safe_push instead of quick_push.
	PR bootstrap/78493
	* g++.dg/cpp1z/decomp18.C: New test.

From-SVN: r242828
2016-11-24 11:26:12 +00:00
Jakub Jelinek 25cb6b33f7 re PR c++/77907 (Add "const" to argument of constexpr constructor causes the object to be left in unconstructed state)
PR c++/77907
	* cp-gimplify.c (cp_fold) <case CALL_EXPR>: When calling constructor
	and maybe_constant_value returns non-CALL_EXPR, create INIT_EXPR
	with the object on lhs and maybe_constant_value returned expr on rhs.

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

From-SVN: r242790
2016-11-23 19:45:27 +01:00
Jakub Jelinek 1b3314ddb1 re PR c++/71450 (ICE on invalid C++11 code on x86_64-linux-gnu: in tree check: expected record_type or union_type or qual_union_type, have template_type_parm in lookup_base, at cp/search.c:203)
PR c++/71450
	* pt.c (tsubst_copy): Return error_mark_node when mark_used
	fails, even when complain & tf_error.

	* g++.dg/cpp0x/pr71450-1.C: New test.
	* g++.dg/cpp0x/pr71450-2.C: New test.

From-SVN: r242767
2016-11-23 16:59:25 +01:00
Jakub Jelinek e2df23288c re PR c++/77739 (internal compiler error: in create_tmp_var, at gimple-expr.c:524)
PR c++/77739
	* cp-gimplify.c (cp_gimplify_tree) <case VEC_INIT_EXPR>: Pass
	false as handle_invisiref_parm_p to cp_genericize_tree.
	(struct cp_genericize_data): Add handle_invisiref_parm_p field.
	(cp_genericize_r): Don't wrap is_invisiref_parm into references
	if !wtd->handle_invisiref_parm_p.
	(cp_genericize_tree): Add handle_invisiref_parm_p argument,
	set wtd.handle_invisiref_parm_p to it.
	(cp_genericize): Pass true as handle_invisiref_parm_p to
	cp_genericize_tree.  Formatting fix.

	* g++.dg/cpp1y/pr77739.C: New test.

From-SVN: r242766
2016-11-23 16:54:39 +01: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
Jason Merrill 29c90a3c28 PR objc++/78418 - ICE in string tests on darwin
* tree.c (lvalue_kind): Guard DECL_HAS_VALUE_EXPR_P.

From-SVN: r242647
2016-11-20 23:41:21 -05:00
Jakub Jelinek 6c554a2ab8 re PR c++/77285 (extern thread_local linkage)
PR c++/77285
	* mangle.c (mangle_tls_init_fn, mangle_tls_wrapper_fn): Call
	check_abi_tags.

	* g++.dg/tls/pr77285-1.C: New test.
	* g++.dg/tls/pr77285-2.C: New test.

From-SVN: r242607
2016-11-18 22:56:50 +01:00
Jason Merrill 0bdc4c1ce9 PR c++/67631 - list-init and explicit conversions
* semantics.c (finish_compound_literal): Call digest_init_flags.
	* typeck2.c (digest_init_flags): Add complain parm.
	(store_init_value): Pass it.

From-SVN: r242603
2016-11-18 15:27:26 -05: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
Jason Merrill c2f2350e9b PR c++/78193 - inherited ctor regressions on sparc32.
* call.c (build_over_call): Don't set CALL_FROM_THUNK_P here.
	(build_call_a): Set it here, and don't insert EMPTY_CLASS_EXPR.
	(convert_like_real) [ck_rvalue]: Also pass non-addressable
	types along directly.

From-SVN: r242573
2016-11-17 17:40:28 -05:00
Paolo Carlini 80557bb787 re PR c++/55080 (-pedantic produces error: floating-point literal cannot appear in a constant-expression)
/cp
2016-11-17  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/55080
	* parser.c (cp_parser_non_integral_constant_expression): Issue a
	pedwarn instead of an error for case NIC_FLOAT.

/testsuite
2016-11-17  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/55080
	* g++.dg/parse/pr55080.C: New.

From-SVN: r242565
2016-11-17 21:44:05 +00:00