Commit Graph

11106 Commits

Author SHA1 Message Date
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
Jason Merrill f8691e9818 PR c++/78124 - list-initialization and inherited ctor
* name-lookup.c (do_class_using_decl): Set CLASSTYPE_NON_AGGREGATE.

From-SVN: r242563
2016-11-17 16:41:09 -05:00
Jason Merrill 07a67f7b09 PR c++/78369 - {} as default argument
* call.c (build_special_member_call): Handle CONSTRUCTOR.

From-SVN: r242562
2016-11-17 16:40:48 -05:00
Jason Merrill d168b3daa6 PR c++/68377 - parenthesized expr in fold-expression
* parser.c (cp_parser_fold_expression): Check TREE_NO_WARNING.

From-SVN: r242561
2016-11-17 16:40:41 -05:00
Jason Merrill 46b2baa723 PR c++/78373 - ICE with TREE_CONSTANT reference
* decl.c (cp_finish_decl): Don't set TREE_CONSTANT on a reference.
	* typeck2.c (store_init_value): Likewise.

From-SVN: r242523
2016-11-16 17:42:24 -05:00
Jason Merrill fc72d1ed3c Fix tuple decomposition decltype.
* decl.c (store_decomp_type, lookup_decomp_type): New.
	(cp_finish_decomp): Call store_decomp_type.
	* semantics.c (finish_decltype_type): Call lookup_decomp_type.
	* cp-tree.h: Declare lookup_decomp_type.

From-SVN: r242513
2016-11-16 16:30:41 -05:00
Jakub Jelinek a0f5b98752 decl.c (cp_finish_decomp): For DECL_NAMESPACE_SCOPE_P decl, set DECL_ASSEMBLER_NAME.
* decl.c (cp_finish_decomp): For DECL_NAMESPACE_SCOPE_P decl,
	set DECL_ASSEMBLER_NAME.
	* parser.c (cp_parser_decomposition_declaration): Likewise
	if returning error_mark_node.
	* mangle.c (mangle_decomp): New function.
	* cp-tree.h (mangle_decomp): New declaration.

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

From-SVN: r242434
2016-11-15 18:05:23 +01:00
Jason Merrill 944608029f PR c++/78358 - tuple decomposition decltype
* semantics.c (finish_decltype_type): Strip references for a tuple
	decomposition.
	* cp-tree.h (DECL_DECOMPOSITION_P): False for non-variables.

From-SVN: r242432
2016-11-15 11:32:38 -05:00
Uros Bizjak 22b15758c0 ChangeLog: Fix ChangeLog entry.
* gcc/ChangeLog: Fix ChangeLog entry.
	* gcc/c/ChangeLog: Ditto.
	* gcc/c-family/ChangeLog: Ditto.
	* gcc/cp/ChangeLog: Ditto.

From-SVN: r242429
2016-11-15 16:43:40 +01:00
Jason Merrill fd338b1364 Allow references in constant-expressions.
* decl2.c (decl_maybe_constant_var_p): References qualify.
	* constexpr.c (non_const_var_error): Handle references.
	* init.c (constant_value_1): Always check decl_constant_var_p.
	* cp-gimplify.c (cp_fold_maybe_rvalue): Don't fold references.
	* error.c (dump_decl_name): Split out from dump_decl.

From-SVN: r242422
2016-11-15 09:55:52 -05:00
Jason Merrill 47e5d7ccf1 Various C++17 decomposition fixes.
* tree.c (bitfield_p): New.
	* cp-tree.h: Declare it.
	* typeck.c (cxx_sizeof_expr, cxx_alignof_expr)
	(cp_build_addr_expr_1): Use it instead of DECL_C_BIT_FIELD.
	* decl.c (cp_finish_decomp): Look through reference.  Always
	SET_DECL_DECOMPOSITION_P.
	* semantics.c (finish_decltype_type): Adjust decomposition handling.

From-SVN: r242408
2016-11-15 00:22:28 -05:00
Jakub Jelinek 8e745a1709 c-cppbuiltin.c (c_cpp_builtins): Define __cpp_structured_bindings.
* c-cppbuiltin.c (c_cpp_builtins): Define __cpp_structured_bindings.

	* g++.dg/cpp1z/feat-cxx1z.C: Test __cpp_structured_bindings macro.

From-SVN: r242395
2016-11-14 20:00:32 +01:00
Jakub Jelinek 70f40fea6a Implement P0217R3 - C++17 structured bindings
gcc/
	* match.pd: Don't try to compare addresses of variables with
	DECL_VALUE_EXPR.
gcc/cp/
	* cp-tree.h (struct lang_decl_base): Add decomposition_p.
	(DECL_DECOMPOSITION_P): New
	(enum auto_deduction_context): Add adc_decomp_type.
	(enum cp_declarator_kind): Add cdk_decomp.
	* constexpr.c (cxx_eval_constant_expression): Look through
	DECL_VALUE_EXPR.
	(potential_constant_expression_1): Likewise.
	* decl.c (reshape_init): Preserve CONSTRUCTOR_IS_DIRECT_INIT.
	(check_initializer): Use build_aggr_init for DECL_DECOMPOSITION_P.
	(cp_finish_decl): Pass adc_decomp_type for decomposition.
	(find_decomp_class_base, get_tuple_size, get_tuple_element_type)
	(get_tuple_decomp_init, cp_finish_decomp): New.
	(grokdeclarator): Handle decomposition.
	* init.c (build_aggr_init): Handle decomposition array.
	(build_vec_init): Handle initialization from { array }.
	* name-lookup.c (add_function): Always wrap TEMPLATE_DECL in
	OVERLOAD.
	* parser.c (declarator_can_be_parameter_pack): Handle cdk_decomp.
	(function_declarator_p, strip_declarator_types)
	(cp_parser_check_declarator_template_parameters): Likewise.
	(cp_parser_range_for, cp_convert_range_for): Handle decomposition.
	(cp_parser_simple_declaration): Parse decomposition.
	(cp_parser_decomposition_declaration): New.
	* pt.c (tsubst_decomp_names): New.
	(subst_expr) [DECL_EXPR, RANGE_FOR_STMT]: Handle decomposition.
	(do_auto_deduction): Handle adc_decomp_type.
	* semantics.c (finish_decltype_type): Look through DECL_VALUE_EXPR.
	* typeck.c (is_bitfield_expr_with_lowered_type): Likewise.
	* tree.c (lvalue_kind): Likewise.
	(cp_build_reference_type): Handle reference collapsing.

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

From-SVN: r242377
2016-11-14 00:02:58 -05:00
Jason Merrill e7555e42d0 Improve various diagnostic issues.
* call.c (build_new_method_call_1): Include template arguments in
	error message.
	(print_error_for_call_failure): Likewise.
	(build_new_function_call): Pass them in.
	* name-lookup.c (supplement_binding_1): Don't complain about a
	conflict with an erroneous declaration.
	* error.c (dump_decl): Fix printing of alias declaration.
	* decl.c (make_typename_type): Call cxx_incomplete_type_error.
	* parser.c (cp_parser_diagnose_invalid_type_name): Likewise.
	* semantics.c (perform_koenig_lookup): Don't wrap an error in
	TEMPLATE_ID_EXPR.

From-SVN: r242376
2016-11-13 23:58:45 -05:00
Jason Merrill 559f2bbc36 CWG 2233 - default arg and parameter pack
* typeck.c (convert_arguments): Handle default arg followed by none.

From-SVN: r242350
2016-11-13 01:52:43 -05:00
Jason Merrill dc8d2d00c5 Fix constexpr lvalue use of __real and __imag.
* constexpr.c (potential_constant_expression_1): REALPART_EXPR and
	IMAGPART_EXPR can be lvalues.

From-SVN: r242349
2016-11-13 01:52:15 -05:00
Jason Merrill ba1e69c03f DR 374 - specialization in outer namespace
PR c++/56840
	* pt.c (check_specialization_namespace): Allow any enclosing
	namespace.
	(check_unqualified_spec_or_inst): New.
	(check_explicit_specialization): Call it.
	* parser.c (cp_parser_elaborated_type_specifier)
	(cp_parser_class_head): Call it.

From-SVN: r242348
2016-11-13 01:51:23 -05:00
Jason Merrill f065303fcf PR c++/77337 - auto return and lambda
* pt.c (tsubst_friend_function): Don't set DECL_INITIAL.
	(instantiate_decl): It's OK to defer a constexpr function.
	* cp-tree.h (DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION): Check
	DECL_LANG_SPECIFIC.
	* decl2.c (decl_defined_p): Use it.  No longer static.
	* decl.c (redeclaration_error_message): Use decl_defined_p.
	* constexpr.c (cxx_eval_call_expression): Set input_location around
	call to instantiate_decl.

From-SVN: r242056
2016-11-10 16:42:36 -05:00
Jakub Jelinek 0569479efa mangle.c (mangle_decl): Only emit -Wc++1z-compat warnings for public or external symbols.
* mangle.c (mangle_decl): Only emit -Wc++1z-compat warnings for
	public or external symbols.

	* g++.dg/cpp1z/noexcept-type14.C: New test.
	* g++.dg/asan/asan_test.C: Remove -Wno-c++1z-compat from dg-options.

From-SVN: r242042
2016-11-10 18:04:06 +01:00
Jakub Jelinek 0391e4a3b3 re PR c++/78283 (-Wc++1z-compat warning is sticky)
PR c++/78283
	* mangle.c (start_mangling): Reset G.need_cxx1z_warning.

	* g++.dg/cpp1z/noexcept-type13.C: New test.

From-SVN: r242026
2016-11-09 23:56:35 +01:00
Jason Merrill e922b25690 Fix C++17 template placeholder for template template parm.
* parser.c (cp_parser_simple_type_specifier): Allow placeholder
	for template template parameter.
	(cp_parser_type_id_1): Improve diagnostic.
	* decl.c (grokdeclarator): Handle class deduction diagnostics here.
	* pt.c (splice_late_return_type): Not here.
	(tsubst) [TEMPLATE_TYPE_PARM]: Substitute into placeholder template.
	(do_class_deduction): Handle non-class templates.

From-SVN: r242018
2016-11-09 15:02:56 -05:00
Jason Merrill 4a826ca6fe Implement P0127R2, Declaring non-type parameters with auto.
gcc/cp/
	* cp-tree.h (enum auto_deduction_context): Add adc_unify.
	* decl.c (grokdeclarator): Allow 'auto' in C++17 template non-type
	parameter types.
	* pt.c (do_auto_deduction): Add outer_targs parameter.
	(convert_template_argument): Call do_auto_deduction.  If adc_unify,
	don't give up on dependent init.
	(unify): Likewise.  In C++17, walk into the type of a
	TEMPLATE_PARM_INDEX.
	(for_each_template_parm): Add any_fn parameter.
	(struct pair_fn_data): Likewise.
	(for_each_template_parm_r): Call it for any tree.  In C++17, walk
	into the type of a TEMPLATE_PARM_INDEX.
	(zero_r, array_deduction_r, try_array_deduction): New.
	(type_unification_real): Call try_array_deduction.
	(get_partial_spec_bindings): Likewise.
gcc/c-family/
	* c-cppbuiltin.c (c_cpp_builtins): Define __cpp_template_auto.

From-SVN: r242017
2016-11-09 15:02:50 -05:00
Jason Merrill 51dc660315 Implement P0012R1, Make exception specifications part of the type system.
gcc/cp/
	* cp-tree.h (enum tsubst_flags): Add tf_fndecl_type.
	(flag_noexcept_type, ce_type): New.
	* call.c (build_conv): Add ck_fnptr.
	(enum conversion_kind): Change ck_tsafe to ck_fnptr.
	(convert_like_real): Likewise.
	(standard_conversion): Likewise.  Allow function pointer
	conversions for pointers to member functions.
	(reference_compatible_p): Allow function pointer conversions.
	(direct_reference_binding): Likewise.
	(reference_binding): Reference-compatible is no longer a subset of
	reference-related.
	(is_subseq): Also strip ck_lvalue after next_conversion.
	* class.c (instantiate_type): Check fnptr_conv_p.
	(resolve_address_of_overloaded_function): Likewise.
	* cvt.c (can_convert_tx_safety): Now static.
	(noexcept_conv_p, fnptr_conv_p, strip_fnptr_conv): New.
	* decl.c (flag_noexcept_type): Define.
	(cxx_init_decl_processing): Set it.
	(bad_specifiers): Check it.
	(grokdeclarator) [cdk_function]: Add exception-spec to type here.
	* lambda.c (maybe_add_lambda_conv_op): Add exception-spec to
	returned pointer.
	* mangle.c (struct globals): Add need_cxx1z_warning.
	(mangle_decl): Check it.
	(write_exception_spec): New.
	(write_function_type): Call it.
	(canonicalize_for_substitution): Handle exception spec.
	(write_type): Likewise.
	(write_encoding): Set processing_template_decl across mangling of
	partially-instantiated type.
	* pt.c (determine_specialization): Pass tf_fndecl_type.
	(tsubst_decl, fn_type_unification): Likewise.
	(tsubst): Strip tf_fndecl_type, pass it to
	tsubst_exception_specification.
	(convert_nontype_argument_function): Handle function pointer
	conversion.
	(convert_nontype_argument): Likewise.
	(unify, for_each_template_parm_r): Walk into noexcept-specifier.
	* rtti.c (ptr_initializer): Encode noexcept.
	* tree.c (canonical_eh_spec): New.
	(build_exception_variant): Use it.
	* typeck.c (composite_pointer_type): Handle fnptr conversion.
	(comp_except_specs): Compare canonical EH specs.
	(structural_comptypes): Call it.
gcc/c-family/
	* c.opt (Wc++1z-compat): New.
	* c-cppbuiltin.c (c_cpp_builtins): Add __cpp_noexcept_function_type.
libstdc++-v3/
	* include/bits/c++config (_GLIBCXX_NOEXCEPT_PARM)
	(_GLIBCXX_NOEXCEPT_QUAL): New.
	* include/std/type_traits (is_function): Use them.
	* libsubc++/new (launder): Likewise.
	* libsupc++/cxxabi.h (__pbase_type_info::__masks): Add
	__noexcept_mask.
	* libsupc++/pbase_type_info.cc (__do_catch): Handle function
	pointer conversion.
libiberty/
	* cp-demangle.c (is_fnqual_component_type): New.
	(d_encoding, d_print_comp_inner, d_print_mod_list): Use it.
	(FNQUAL_COMPONENT_CASE): New.
	(d_make_comp, has_return_type, d_print_comp_inner)
	(d_print_function_type): Use it.
	(next_is_type_qual): New.
	(d_cv_qualifiers, d_print_mod): Handle noexcept and throw-spec.
include/
	* demangle.h (enum demangle_component_type): Add
	DEMANGLE_COMPONENT_NOEXCEPT, DEMANGLE_COMPONENT_THROW_SPEC.

From-SVN: r241944
2016-11-07 18:09:29 -05:00
Jason Merrill 452811eb53 C++ cleanups before C++17 noexcept in types.
* call.c (standard_conversion): Reorganize pointer conversions.
	* pt.c (convert_nontype_argument_function): Convert to ref here.
	(convert_nontype_argument): Not here.
	(convert_template_argument): Add original type to error message.
	(RECUR_AND_CHECK_FAILURE): Remove trailing semicolon.
	(unify): Compare function-qualifiers.
	* typeck.c (same_type_ignoring_top_level_qualifiers_p): Use
	cp_build_qualified_type rather than TYPE_MAIN_VARIANT.

From-SVN: r241943
2016-11-07 18:09:21 -05:00
Jason Merrill c9c039100a Add template instantiations to the announce_function stream.
* pt.c (push_tinst_level_loc): Add template instantiations to the
	announce_function stream.

From-SVN: r241928
2016-11-07 14:35:13 -05:00
Paolo Carlini 6e3ae7e6f5 re PR c++/67980 (left shift count is negative [-Wshift-count-negative] generated for unreachable code)
/cp
2016-11-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67980
	* pt.c (tsubst_expr, case IF_STMT): Use fold_non_dependent_expr
	to suppress unwanted warnings.

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

	PR c++/67980
	* g++.dg/cpp1y/pr67980.C: New.

From-SVN: r241858
2016-11-04 18:58:53 +00:00
Jason Merrill 866115cd8a PR c++/78198 - inherited template ctor with default arg
* call.c (convert_default_arg): Look through inheriting ctors.

From-SVN: r241843
2016-11-04 08:47:01 -04:00
Jakub Jelinek 6905c577d1 re PR debug/28767 (GCC should output DW_TAG_ptr_to_member for member functions)
PR debug/28767
	PR debug/56974
	* langhooks.h (struct lang_hooks_for_types): Add type_dwarf_attribute
	langhook.
	* langhooks.c (lhd_type_dwarf_attribute): New function.
	* langhooks-def.h (lhd_type_dwarf_attribute): Declare.
	(LANG_HOOKS_TYPE_DWARF_ATTRIBUTE): Define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add
	LANG_HOOKS_TYPE_DWARF_ATTRIBUTE.
	(check_qualified_type, check_aligned_type): Call it.
	* dwarf2out.c (modified_type_die): Don't use type_main_variant
	for FUNCTION_TYPE or METHOD_TYPE, instead walk over variants with
	check_base_type and check_lang_type.
	(gen_ptr_to_mbr_type_die): If lookup_type_die is already non-NULL,
	return early.  For pointer-to-data-member add DW_AT_use_location
	attribute.
	(gen_subroutine_type_die): Add DW_AT_{,rvalue_}reference attribute
	if needed.
	(gen_type_die_with_usage): Don't use type_main_variant
	for FUNCTION_TYPE or METHOD_TYPE, instead walk over variants with
	check_base_type and check_lang_type.  Formatting fixes. Call
	get_debug_type langhook.
cp/
	* tree.c (cp_check_qualified_type): Use check_base_type and
	TYPE_QUALS comparison instead of check_qualified_type.
	(cxx_type_hash_eq): Return false if type_memfn_rqual don't match.
	* cp-objcp-common.c (cp_get_debug_type): New function.
	(cp_decl_dwarf_attribute): Don't handle types here.
	(cp_type_dwarf_attribute): New function.
	* cp-objcp-common.h (cp_get_debug_type, cp_type_dwarf_attribute):
	Declare.
	(LANG_HOOKS_GET_DEBUG_TYPE, LANG_HOOKS_TYPE_DWARF_ATTRIBUTE):
	Define.
testsuite/
	* g++.dg/debug/dwarf2/ptrdmem-1.C: New test.
	* g++.dg/debug/dwarf2/ref-3.C: New test.
	* g++.dg/debug/dwarf2/ref-4.C: New test.
	* g++.dg/debug/dwarf2/refqual-1.C: New test.
	* g++.dg/debug/dwarf2/refqual-2.C: New test.

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

From-SVN: r241831
2016-11-03 15:52:58 -04:00
Jason Merrill 31f7f784fe Implement P0136R1, Rewording inheriting constructors.
gcc/c-family/
	* c.opt (-fnew-inheriting-ctors): New.
	* c-opts.c: Default to on for ABI 11+.
gcc/cp/
	* call.c (enum rejection_reason_code): Add rr_inherited_ctor.
	(inherited_ctor_rejection): New.
	(add_function_candidate): Reject inherited ctors for copying.
	(enforce_access): Use strip_inheriting_ctors.
	(print_z_candidate): Likewise.  Handle rr_inherited_ctor.
	(convert_like_real): Avoid copying inheriting ctor parameters.
	(build_over_call): Likewise.  A base ctor inheriting from vbase
	has no parms.  Sorry about varargs.
	(joust): A local constructor beats inherited with the same convs.
	* class.c (add_method): Handle hiding inheriting ctors.
	(one_inherited_ctor): Handle new semantics.
	(add_implicitly_declared_members): Pass using_decl down.
	(build_clone): A base ctor inheriting from vbase has no parms.
	* cp-tree.h (DECL_INHERITED_CTOR): Store this instead of the base.
	(SET_DECL_INHERITED_CTOR): Likewise.
	(DECL_INHERITED_CTOR_BASE): Adjust.
	* constexpr.c: Adjust.
	* error.c (dump_function_decl): Decorate inheriting ctors.
	* init.c (emit_mem_initializers): Suppress access control in
	inheriting ctor.
	* mangle.c (write_special_name_constructor): Handle new inheriting
	ctor mangling.
	* method.c (strip_inheriting_ctors, inherited_ctor_binfo)
	(ctor_omit_inherited_parms, binfo_inherited_from): New.
	(synthesized_method_walk): Use binfo_inherited_from.  Suppress
	access control in inheriting ctor.
	(deduce_inheriting_ctor): Deleted if ambiguous ctor inheritance.
	(maybe_explain_implicit_delete): Explain ambigous ctor inheritance.
	(add_one_base_init, do_build_copy_constructor): Adjust.
	(locate_fn_flags, explain_implicit_non_constexpr): Adjust.
	(implicitly_declare_fn): Adjust.
	(get_inherited_ctor): Remove.
	* name-lookup.c (do_class_using_decl): Check for indirect ctor
	inheritance.
	* optimize.c (cdtor_comdat_group): Adjust for new mangling.
	(maybe_clone_body): Handle omitted parms in base clone.
	(maybe_thunk_body): Don't thunk if base clone omits parms.
	* pt.c (tsubst_decl): Adjust.
	(instantiate_template_1): Suppress access control in inheriting
	ctor.
	(fn_type_unification): Do deduction with inherited ctor.
	* tree.c (special_function_p): Adjust.
gcc/
	* tree-inline.c (copy_tree_body_r): Only copy the taken branch of
	a COND_EXPR with constant condition.
libiberty/
	* cp-demangle.c (d_ctor_dtor_name): Handle inheriting constructor.

From-SVN: r241765
2016-11-01 21:50:29 -04:00
Jakub Jelinek 70d288130f dwarf2out.c (add_name_and_src_coords_attributes): Add NO_LINKAGE_NAME argument, don't call add_linkage_name if it is true.
* dwarf2out.c (add_name_and_src_coords_attributes): Add NO_LINKAGE_NAME
	argument, don't call add_linkage_name if it is true.
	(gen_variable_die): For C++ inline static data members, consider the
	initial call when old_die is NULL to be declaration and call
	add_name_and_src_coords_attributes in that case with true as
	NO_LINKAGE_NAME.  Add DW_AT_inline attribute if needed.
	(gen_member_die): For C++ inline static data members, emit a
	definition DIE right away in DW_TAG_compile_unit context.
cp/
	* cp-objcp-common.c (cp_decl_dwarf_attribute): Handle DW_AT_inline.
testsuite/
	* g++.dg/debug/dwarf2/inline-var-1.C: New test.

From-SVN: r241753
2016-11-01 19:35:06 +01:00
Jason Merrill cc656415cf * class.c (declared_access): Split out from handle_using_decl.
From-SVN: r241739
2016-11-01 09:41:50 -04:00
Jakub Jelinek 9782e1ec0a re PR c++/77886 (-Wimplicit-fallthrough: breaks duff's device (in function templates))
PR c++/77886
	* pt.c (tsubst_expr) <case CASE_LABEL_EXPR> Copy over
	FALLTHROUGH_LABEL_P flag to the new LABEL_DECL.
	(tsubst_expr) <case LABEL_EXPR>: Likewise.

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

From-SVN: r241711
2016-10-31 18:10:30 +01:00
Jakub Jelinek c5fed5c6f2 re PR c++/78089 (__builtin_shuffle parsing bug)
PR c++/78089
	* parser.c (cp_parser_postfix_expression): Replace return statement in
	the first switch with setting postfix_expression to the return
	expression and break;.

	* c-c++-common/builtin-shuffle-1.c: New test.
	* g++.dg/cpp0x/addressof3.C: New test.

From-SVN: r241710
2016-10-31 18:08:36 +01:00
Jakub Jelinek e8d8d3c8bf re PR c++/77886 (-Wimplicit-fallthrough: breaks duff's device (in function templates))
PR c++/77886
	* pt.c (tsubst_expr) <case CASE_LABEL_EXPR> Copy over
	FALLTHROUGH_LABEL_P flag to the new LABEL_DECL.
	(tsubst_expr) <case LABEL_EXPR>: Likewise.

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

From-SVN: r241700
2016-10-31 14:39:49 +01:00
Le-Chun Wu 84ff4775d4 Add -Wshadow=global -Wshadow=local and -Wshadow=compatible-local.
This patch from Le-Chun Wu adds two new shadow warning flags for
C and C++:

  -Wshadow=local which warns if a local variable shadows another local
  variable or parameter,

  -Wshadow=compatible-local which warns if a local variable shadows
  another local variable or parameter whose type is compatible with
  that of the shadowing variable.

It is already on the google/main branch (Google ref 39127) and was
previously submitted by Diego Novillo and reviewed on
http://codereview.appspot.com/4452058

I addressed the review comments and made the following changes:
- Add -Wshadow=global (the default alias for -Wshadow).
- Make the documented options -Wshadow=global, -Wshadow=local
  and -Wshadow=compatible-local (with hidden undocumented aliases
  -Wshadow-local and -Wshadow-compatible-local for compatibility).
- The -Wshadow=global, -Wshadow=local and -Wshadow=compatible-local
  relationships are expressed in common.opt instead of in opts.c
  and documented in invoke.texi.
- The "previous declaration" warnings were turned into notes and use
  the (now) existing infrastructure instead of duplicating the warnings.
  The testcases have been adjusted to expect the notes.
- The conditional change in name-lookup.c for non-locals (where we
  don't want to change the warnings, but just check the global ones)
  has been dropped.
- Use warning_at in c-decl.c (warn_if_shadowing).

gcc/ChangeLog:
2016-10-30  Le-Chun Wu  <lcwu@google.com>
            Mark Wielaard  <mjw@redhat.com>

       * doc/invoke.texi: Document Wshadow-local and Wshadow-compatible-local.
       * common.opt (Wshadow=global): New option. Default for -Wshadow.
       (Wshadow=local): New option.
       (Wshadow-local): Hidden alias for -Wshadow=local.
       (Wshadow=compatible-local): New option.
       (Wshadow-compatible-local): Hidden alias for
       -Wshadow=compatible-local.
       * doc/invoke.texi: Document Wshadow=global, Wshadow=local and
       Wshadow=compatible-local.

gcc/c/ChangeLog:
2016-10-30  Le-Chun Wu  <lcwu@google.com>
            Mark Wielaard  <mjw@redhat.com>

       * c-decl.c (warn_if_shadowing): Use the warning code corresponding
       to the given -Wshadow= variant. Use warning_at.

gcc/cp/ChangeLog:
2016-10-30  Le-Chun Wu  <lcwu@google.com>
            Mark Wielaard  <mjw@redhat.com>

       * name-lookup.c (pushdecl_maybe_friend): When emitting a
       shadowing warning, use the code corresponding to the
       given -Wshadow= variant.

gcc/testsuite/ChangeLog
2016-10-30  Le-Chun Wu  <lcwu@google.com>
            Mark Wielaard  <mjw@redhat.com>

       * gcc.dg/Wshadow-compatible-local-1.c: New test.
       * gcc.dg/Wshadow-local-1.c: Likewise.
       * gcc.dg/Wshadow-local-2.c: Likewise.
       * g++.dg/warn/Wshadow-compatible-local-1.C: Likewise.
       * g++.dg/warn/Wshadow-local-1.C: Likewise.
       * g++.dg/warn/Wshadow-local-2.C: Likewise.

Co-Authored-By: Mark Wielaard <mjw@redhat.com>

From-SVN: r241699
2016-10-31 13:21:59 +00:00
Jason Merrill 7c92f4ec61 * class.c (add_method): Allow using-declarations to coexist.
From-SVN: r241620
2016-10-27 09:39:48 -04:00
Jason Merrill f64e0c029c constexpr.c (maybe_constant_init): Pull out TARGET_EXPR_INITIAL.
* constexpr.c (maybe_constant_init): Pull out TARGET_EXPR_INITIAL.

	(cxx_eval_outermost_constant_expr): Don't return a CONSTRUCTOR
	with CONSTRUCTOR_NO_IMPLICIT_ZERO.
	(cxx_eval_call_expression): Clear CONSTRUCTOR_NO_IMPLICIT_ZERO.

From-SVN: r241531
2016-10-25 13:23:44 -04:00
Jakub Jelinek bc352be13c * parser.c (cp_parser_postfix_expression): Adding missing break;.
From-SVN: r241509
2016-10-25 12:47:47 +02:00
Jakub Jelinek e16f1cc79d internal-fn.def (LAUNDER): New internal function.
* internal-fn.def (LAUNDER): New internal function.
	* internal-fn.c (expand_LAUNDER): New function.
c-family/
	* c-common.h (enum rid): Add RID_BUILTIN_LAUNDER.
	* c-common.c (c_common_reswords): Add __builtin_launder.
cp/
	* cp-tree.h (finish_builtin_launder): Declare.
	* parser.c (cp_parser_postfix_expression): Handle RID_BUILTIN_LAUNDER.
	* semantics.c (finish_builtin_launder): New function.
	* pt.c (tsubst_copy_and_build): Handle instantiation of IFN_LAUNDER.
	* constexpr.c (cxx_eval_internal_function): Handle IFN_LAUNDER.
	(potential_constant_expression_1): Likewise.
testsuite/
	* g++.dg/cpp1z/launder1.C: New test.
	* g++.dg/cpp1z/launder2.C: New test.

From-SVN: r241506
2016-10-25 10:47:15 +02:00
Jakub Jelinek 0f2a9e37fa dwarf2out.c (gen_subprogram_die): Add DW_AT_reference or DW_AT_rvalue_reference attributes.
* dwarf2out.c (gen_subprogram_die): Add DW_AT_reference or
	DW_AT_rvalue_reference attributes.

	* cp-objcp-common.c (cp_decl_dwarf_attribute): Handle DW_AT_reference
	and DW_AT_rvalue_reference.

	* g++.dg/debug/dwarf2/ref-2.C: New test.

From-SVN: r241492
2016-10-24 20:44:30 +02:00
Jakub Jelinek 86287716e8 cxx-pretty-print.c (pp_cxx_check_constraint): Use VAR_P (x) instead of TREE_CODE (x) == VAR_DECL.
* cxx-pretty-print.c (pp_cxx_check_constraint): Use VAR_P (x)
	instead of TREE_CODE (x) == VAR_DECL.
	* constraint.cc (get_concept_definition): Likewise.
	(finish_shorthand_constraint): Likewise.
	* init.c (warn_placement_new_too_small): Likewise.
	* cp-gimplify.c (cp_genericize_r): Likewise.

From-SVN: r241480
2016-10-24 18:04:01 +02:00
Jason Merrill 16b61424dd re PR c++/77656 (64-bit integral template parameter gets incorrectly sized as 32-bits)
PR c++/77656
	* pt.c (convert_template_argument): Call convert_nontype_argument
	on value-dependent but not type-dependent arguments.
	(convert_nontype_argument): Handle value-dependent arguments.
	(canonicalize_expr_argument): New.
	(deducible_expression, unify): Skip CONVERT_EXPR.
	* error.c (dump_template_argument): Likewise.
	* mangle.c (write_expression): Likewise.

From-SVN: r241425
2016-10-21 15:45:45 -04:00
Jason Merrill a7564a05ff * ptree.c (cxx_print_xnode) [TEMPLATE_PARM_INDEX]: Dump the decl.
From-SVN: r241424
2016-10-21 15:45:39 -04:00
Jakub Jelinek 8e6982f7aa dwarf2out.c (gen_variable_die): Emit DW_AT_const_expr attribute if needed.
* dwarf2out.c (gen_variable_die): Emit DW_AT_const_expr attribute
	if needed.  Re-add origin_die variable and its initialization.
cp/
	* cp-objcp-common.c (cp_decl_dwarf_attribute): Handle
	DW_AT_const_expr.
testsuite/
	* g++.dg/debug/dwarf2/constexpr-var-1.C: New test.

From-SVN: r241408
2016-10-21 17:11:48 +02:00
Jakub Jelinek 81b42cc69b langhooks.h (struct lang_hooks_for_decls): Remove function_decl_explicit_p...
* langhooks.h (struct lang_hooks_for_decls): Remove
	function_decl_explicit_p, function_decl_deleted_p and
	function_decl_defaulted hooks.  Add decl_dwarf_attribute hook.
	* langhooks-def.h (lhd_decl_dwarf_attribute): Declare.
	(LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P,
	LANG_HOOKS_FUNCTION_DECL_DELETED_P,
	LANG_HOOKS_FUNCTION_DECL_DEFAULTED): Remove.
	(LANG_HOOKS_DECL_DWARF_ATTRIBUTE): Define.
	(LANG_HOOKS_DECLS): Remove LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P,
	LANG_HOOKS_FUNCTION_DECL_DELETED_P and
	LANG_HOOKS_FUNCTION_DECL_DEFAULTED.  Add
	LANG_HOOKS_DECL_DWARF_ATTRIBUTE.
	* langhooks.c (lhd_decl_dwarf_attribute): New function.
	* dwarf2out.c (gen_subprogram_die): Use
	lang_hooks.decls.decl_dwarf_attribute instead of
	lang_hooks.decls.function_decl_*.
cp/
	* cp-objcp-common.h (cp_function_decl_explicit_p,
	cp_function_decl_deleted_p, cp_function_decl_defaulted): Remove.
	(cp_decl_dwarf_attribute): Declare.
	(LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P,
	LANG_HOOKS_FUNCTION_DECL_DELETED_P,
	LANG_HOOKS_FUNCTION_DECL_DEFAULTED): Remove.
	(LANG_HOOKS_DECL_DWARF_ATTRIBUTE): Redefine.
	* cp-objcp-common.c (cp_function_decl_explicit_p,
	cp_function_decl_deleted_p, cp_function_decl_defaulted): Remove.
	(cp_decl_dwarf_attribute): New function.

From-SVN: r241227
2016-10-17 08:53:00 +02:00
Jason Merrill 68d0192058 PR c++/77945 - constexpr and trivial copy
* constexpr.c (maybe_simplify_trivial_copy): New.
	(cxx_eval_store_expression): Call it.
	* call.c (build_over_call): Use unsigned char for trivial copy.

From-SVN: r241204
2016-10-15 17:25:55 -04:00
Jason Merrill ec2416b5ff Implement P0017R1, C++17 aggregates with bases.
* class.c (build_base_field_1): Split out from...
	(build_base_field): ...here.  In C++17 mode, build a field for
	empty bases.
	* decl.c (xref_basetypes): In C++17 aggregates can have bases.
	(next_initializable_field): Allow base fields in C++17.
	* typeck2.c (process_init_constructor_record): Likewise.

From-SVN: r241187
2016-10-14 17:54:39 -04:00
Jakub Jelinek 064ed55a66 DR 1511 - const volatile variables and ODR
DR 1511 - const volatile variables and ODR
	* decl.c (grokvardecl): Change flags argument to type_quals,
	add conceptp argument.  Set TREE_PUBLIC for non-static volatile vars.
	(grokdeclarator): Adjust grokvardecl caller.

	* g++.dg/DRs/dr1511-1.C: New test.
	* g++.dg/DRs/dr1511-2.C: New test.

From-SVN: r241176
2016-10-14 21:00:38 +02:00
Martin Sebor 9603204722 PR c++/71912 - [6/7 regression] flexible array in struct in union rejected
gcc/cp/ChangeLog:

	PR c++/71912
	* class.c (struct flexmems_t):  Add members.
	(find_flexarrays): Add arguments.  Correct handling of anonymous
	structs.
	(diagnose_flexarrays): Adjust to issue warnings in addition to errors.
	(check_flexarrays): Add argument.
	(diagnose_invalid_flexarray): New functions.

gcc/testsuite/ChangeLog:

	PR c++/71912
	* g++.dg/ext/flexary4.C: Adjust.
	* g++.dg/ext/flexary5.C: Same.
	* g++.dg/ext/flexary9.C: Same.
	* g++.dg/ext/flexary19.C: New test.
	* g++.dg/ext/flexary18.C: New test.
	* g++.dg/torture/pr64312.C: Add a dg-error directive to an ill-formed
	regression test.
        * g++.dg/compat/struct-layout-1_generate.c (subfield): Add argument.
        Avoid generating a flexible array member in an array.

From-SVN: r241143
2016-10-13 16:26:36 -06:00
Jason Merrill 14a2c9aac0 Implement P0386R2 - C++17 inline variables
2016-10-11  Jakub Jelinek  <jakub@redhat.com>

	* dwarf2out.c (gen_member_die): Handle inline static data member
	definitions.
c-family/
	* c-cppbuiltin.c (c_cpp_builtins): Add __cpp_inline_variables.
cp/
	* cp-tree.h (struct lang_type): Shrink language field to 1 bit
	from 4.  Add var_declared_inline_p field.  Mention 2 spare bits.
	(DECL_VAR_DECLARED_INLINE_P): Define.
	(SET_DECL_VAR_DECLARED_INLINE_P): Define.
	(DECL_INLINE_VAR_P): Define.
	(diagnose_inline_vars_for_namespace): Declare.
	* decl.c (diagnose_inline_vars_for_namespace): New function.
	(duplicate_decls): For static data members copy
	DECL_DECLARED_CONSTEXPR_P.
	(redeclaration_error_message): Handle C++17 redundant redeclaration
	of constexpr static data member outside of class.
	(maybe_commonize_var): Handle inline variables.
	(check_initializer): Ignore inline variables for diagnostics.
	Adjust diagnostic wording for C++17.
	(make_rtl_for_nonlocal_decl): Allow in-class definition of
	inline static data members.
	(bad_specifiers): Don't diagnose inline on variables here.
	(grokvardecl): Add inlinep argument, non-static const inline variables
	are TREE_PUBLIC.
	(check_static_variable_definition): Return early also for inline
	variables.
	(grokdeclarator): Handle inline variables and inline static data
	members.
	* typeck2.c (store_init_value): Don't diagnose non-constant
	initializers for non-constexpr inline static data members.
	* decl2.c (vague_linkage_p): Return true for inline variables.
	(c_parse_final_cleanups): In-class declaration of inline static
	data members is a definition.  Call diagnose_inline_vars_for_namespace
	through walk_namespaces.
	* pt.c (instantiate_decl): Set pattern_defined for in-class definitions
	of inline static data members.

From-SVN: r241137
2016-10-13 15:26:54 -04:00
Thomas Preud'homme 4d0cdd0ce6 Move MEMMODEL_* from coretypes.h to memmodel.h
2016-10-13  Thomas Preud'homme  <thomas.preudhomme@arm.com>

    gcc/
    * coretypes.h: Move MEMMODEL_* macros and enum memmodel definition
    into ...
    * memmodel.h: This file.
    * alias.c, asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c,
      caller-save.c, calls.c, ccmp.c, cfgbuild.c, cfgcleanup.c,
      cfgexpand.c, cfgloopanal.c, cfgrtl.c, cilk-common.c, combine.c,
      combine-stack-adj.c, common/config/aarch64/aarch64-common.c,
      common/config/arm/arm-common.c, common/config/bfin/bfin-common.c,
      common/config/c6x/c6x-common.c, common/config/i386/i386-common.c,
      common/config/ia64/ia64-common.c, common/config/nvptx/nvptx-common.c,
      compare-elim.c, config/aarch64/aarch64-builtins.c,
      config/aarch64/aarch64-c.c, config/aarch64/cortex-a57-fma-steering.c,
      config/arc/arc.c, config/arc/arc-c.c, config/arm/arm-builtins.c,
      config/arm/arm-c.c, config/avr/avr.c, config/avr/avr-c.c,
      config/avr/avr-log.c, config/bfin/bfin.c, config/c6x/c6x.c,
      config/cr16/cr16.c, config/cris/cris.c, config/darwin-c.c,
      config/darwin.c, config/epiphany/epiphany.c,
      config/epiphany/mode-switch-use.c,
      config/epiphany/resolve-sw-modes.c, config/fr30/fr30.c,
      config/frv/frv.c, config/ft32/ft32.c, config/h8300/h8300.c,
      config/i386/i386-c.c, config/i386/winnt.c, config/iq2000/iq2000.c,
      config/lm32/lm32.c, config/m32c/m32c.c, config/m32r/m32r.c,
      config/m68k/m68k.c, config/mcore/mcore.c,
      config/microblaze/microblaze.c, config/mmix/mmix.c,
      config/mn10300/mn10300.c, config/moxie/moxie.c,
      config/msp430/msp430.c, config/nds32/nds32-cost.c,
      config/nds32/nds32-intrinsic.c, config/nds32/nds32-md-auxiliary.c,
      config/nds32/nds32-memory-manipulation.c,
      config/nds32/nds32-predicates.c, config/nds32/nds32.c,
      config/nios2/nios2.c, config/nvptx/nvptx.c, config/pa/pa.c,
      config/pdp11/pdp11.c, config/rl78/rl78.c, config/rs6000/rs6000-c.c,
      config/rx/rx.c, config/s390/s390-c.c, config/s390/s390.c,
      config/sh/sh.c, config/sh/sh-c.c, config/sh/sh-mem.cc,
      config/sh/sh_treg_combine.cc, config/sol2.c, config/spu/spu.c,
      config/stormy16/stormy16.c, config/tilegx/tilegx.c,
      config/tilepro/tilepro.c, config/v850/v850.c, config/vax/vax.c,
      config/visium/visium.c, config/vms/vms-c.c, config/xtensa/xtensa.c,
      coverage.c, cppbuiltin.c, cprop.c, cse.c, cselib.c, dbxout.c, dce.c,
      df-core.c, df-problems.c, df-scan.c, dojump.c, dse.c, dwarf2asm.c,
      dwarf2cfi.c, dwarf2out.c, emit-rtl.c, except.c, explow.c, expmed.c,
      expr.c, final.c, fold-const.c, function.c, fwprop.c, gcse.c,
      ggc-page.c, haifa-sched.c, hsa-brig.c, hsa-gen.c, hw-doloop.c,
      ifcvt.c, init-regs.c, internal-fn.c, ira-build.c, ira-color.c,
      ira-conflicts.c, ira-costs.c, ira-emit.c, ira-lives.c, ira.c, jump.c,
      loop-doloop.c, loop-invariant.c, loop-iv.c, loop-unroll.c,
      lower-subreg.c, lra.c, lra-assigns.c, lra-coalesce.c,
      lra-constraints.c, lra-eliminations.c, lra-lives.c, lra-remat.c,
      lra-spills.c, mode-switching.c, modulo-sched.c, omp-low.c, passes.c,
      postreload-gcse.c, postreload.c, predict.c, print-rtl-function.c,
      recog.c, ree.c, reg-stack.c, regcprop.c, reginfo.c, regrename.c,
      reload.c, reload1.c, reorg.c, resource.c, rtl-chkp.c, rtl-tests.c,
      rtlanal.c, rtlhooks.c, sched-deps.c, sched-rgn.c, sdbout.c,
      sel-sched-ir.c, sel-sched.c, shrink-wrap.c, simplify-rtx.c,
      stack-ptr-mod.c, stmt.c, stor-layout.c, target-globals.c,
      targhooks.c, toplev.c, tree-nested.c, tree-outof-ssa.c,
      tree-profile.c, tree-ssa-coalesce.c, tree-ssa-ifcombine.c,
      tree-ssa-loop-ivopts.c, tree-ssa-loop.c, tree-ssa-reassoc.c,
      tree-ssa-sccvn.c, tree-vect-data-refs.c, ubsan.c, valtrack.c,
      var-tracking.c, varasm.c: Include memmodel.h.
    * genattrtab.c (write_header): Include memmodel.h in generated file.
    * genautomata.c (main): Likewise.
    * gengtype.c (open_base_files): Likewise.
    * genopinit.c (main): Likewise.
    * genconditions.c (write_header): Include memmodel.h earlier in
    generated file.
    * genemit.c (main): Likewise.
    * genoutput.c (output_prologue): Likewise.
    * genpeep.c (main): Likewise.
    * genpreds.c (write_insn_preds_c): Likewise.
    * genrecog.c (write_header): Likewise.
    * Makefile.in (PLUGIN_HEADERS): Include memmodel.h

    gcc/ada/
    * gcc-interface/utils2.c: Include memmodel.h.

    gcc/c-family/
    * c-cppbuiltin.c: Include memmodel.h.
    * c-opts.c: Likewise.
    * c-pragma.c: Likewise.
    * c-warn.c: Likewise.

    gcc/c/
    * c-typeck.c: Include memmodel.h.

    gcc/cp/
    * decl2.c: Include memmodel.h.
    * rtti.c: Likewise.

    gcc/fortran/
    * trans-intrinsic.c: Include memmodel.h.

    gcc/go/
    * go-backend.c: Include memmodel.h.

    libgcc/
    * libgcov-profiler.c: Replace MEMMODEL_* macros by their __ATOMIC_*
    equivalent.
    * config/tilepro/atomic.c: Likewise and stop casting model to
    enum memmodel.

From-SVN: r241121
2016-10-13 14:17:52 +00:00
Jason Merrill 2ec69f5660 PR c++/77742 - -Waligned-new and placement new.
* init.c (build_new_1): Don't -Waligned-new about placement new.
	(malloc_alignment): New.  Consider MALLOC_ABI_ALIGNMENT.
	* decl.c (cxx_init_decl_processing): New.

From-SVN: r241073
2016-10-12 14:04:51 -04:00
Jason Merrill b7beb16ac1 C++17 class deduction issues
PR c++/77890
	PR c++/77912
	* pt.c (do_class_deduction): Set cp_unevaluated_operand.
	(tsubst) [TEMPLATE_TYPE_PARM]: Copy CLASS_PLACEHOLDER_TEMPLATE.

From-SVN: r240948
2016-10-10 16:48:51 -04:00
Jason Merrill e525cfa7e3 * cp-gimplify.c (cp_fold): Add variable name.
From-SVN: r240897
2016-10-08 22:41:47 -04:00
Jason Merrill 627be19fe1 Delay folding of bool conversion into COND_EXPR.
gcc/c-family/
	* c-common.c (c_common_truthvalue_conversion): Don't distribute
	into COND_EXPR in C++.
gcc/cp/
	* cp-gimplify.c (cp_fold): Distribute cp_truthvalue_conversion
	into COND_EXPR.

From-SVN: r240893
2016-10-08 13:40:22 -04:00
Jason Merrill 36cbfdb066 Further P0135 refinement.
* call.c (build_user_type_conversion_1): Consider conversions from
	a single element in an initializer-list.
	(build_temp): Undo early_elide_copy change.
	(build_over_call): Check that we don't try to copy a TARGET_EXPR
	in C++17 mode.  Set user_conv_p here.
	(convert_like_real): Not here.
	(check_self_delegation): Split out from...
	(build_special_member_call): ...here.  Handle C++17 copy elision.
	* cvt.c (early_elide_copy): Remove.
	(ocp_convert): Undo early_elide_copy change.
	* except.c (build_throw): Likewise.
	* init.c (expand_default_init): Likewise.
	* typeck.c (cp_build_modify_expr): Likewise.

From-SVN: r240889
2016-10-08 12:23:26 -04:00
Nathan Sidwell 45e2bf2e5e re PR c++/64433 (Segmentation fault while compiling)
cp/
	PR c++/64433
	DR1658, DR1611
	* init.c (emit_mem_initializers): Don't construct vbases of
	abstract classes.
	(push_base_cleanups): Don't push vbase cleanups for abstract class
	when in C++14 mode.
	* method.c (synthethesized_method_walk): Don't walk vbases of
	abstract classes when in C++14 mode.

	testsuite/
	PR c++/66443
	* g++.dg/cpp0x/pr66443-cxx11.C: New.
	* g++.dg/cpp0x/pr66443-cxx11-2.C: New.
	* g++.dg/cpp1y/pr66443-cxx14.C: New
	* g++.dg/cpp1y/pr66443-cxx14-2.C: New.
	* g++.dg/cpp1y/pr66443-cxx14-3.C: New.

From-SVN: r240874
2016-10-07 20:01:17 +00:00
Jakub Jelinek be845b04a8 Implement LWG2296 helper intrinsic c-family/
Implement LWG2296 helper intrinsic
c-family/
	* c-common.h (enum rid): Add RID_ADDRESSOF.
	* c-common.c (c_common_reswords): Add __builtin_addressof.
cp/
	* parser.c (cp_parser_postfix_expression): Handle RID_ADDRESSOF.
	* cp-objcp-common.c (cp_common_init_ts): Handle ADDRESSOF_EXPR.
	* constexpr.c (potential_constant_expression_1): Likewise.
	* error.c (dump_expr): Likewise.
	* typeck.c (cp_build_addressof): New function.
	* cp-tree.h (cp_build_addressof): Declare.
	* cxx-pretty-print.h (pp_cxx_addressof_expression): Declare.
	* cp-tree.def (ADDRESSOF_EXPR): New tree code.
	* cxx-pretty-print.c (cxx_pretty_printer::primary_expression): Handle
	ADDRESSOF_EXPR.  Add __builtin_addressof and
	__has_unique_object_representations into syntax in function comment.
	(pp_cxx_addressof_expression): New function.
	* pt.c (tsubst_copy_and_build): Handle ADDRESSOF_EXPR.
testsuite/
	* g++.dg/cpp0x/addressof1.C: New test.
	* g++.dg/cpp0x/addressof2.C: New test.

From-SVN: r240873
2016-10-07 21:37:46 +02:00
Bernd Edlinger c09c4992ac re PR c++/77700 (suspicios code in cp/parser.c)
2016-10-07  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77700
        * c-common.c (c_common_truthvalue_conversion): Warn also for
        suspicious enum values in boolean context.

cp:
2016-10-07  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77700
        * parser.c (cp_parser_base_specifier): Fix a warning.

testsuite:
2016-10-07  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77700
        * c-c++-common/Wint-in-bool-context.c: Update test.

From-SVN: r240867
2016-10-07 17:10:38 +00:00
Bernd Schmidt 8a14afd065 re PR c++/69733 (-Wignored-qualifiers points to wrong const)
c/
	PR c++/69733
	* c-decl.c (smallest_type_quals_location): New static function.
	(grokdeclarator): Try to find the correct location for an ignored
	qualifier.
cp/
	PR c++/69733
	* decl.c (grokdeclarator): Try to find the correct location for an
	ignored qualifier.
testsuite/
	PR c++/69733
	* c-c++-common/pr69733.c: New test.
	* gcc.dg/pr69733.c: New test.
	* gcc.target/i386/pr69733.c: New test.

From-SVN: r240863
2016-10-07 12:21:55 +00:00
Martin Liska 5d341f0895 Fix profiled bootstrap (part 2)
* lambda.c (maybe_add_lambda_conv_op): Set default value.

From-SVN: r240856
2016-10-07 08:34:49 +00:00
Jason Merrill b7558a2c1f C++17 copy elision improvements.
* call.c (build_temp, convert_like_real): Don't re-copy
	TARGET_EXPR.  Handle packed fields.
	(build_x_va_arg): Wrap it in a TARGET_EXPR.
	(build_over_call): Add sanity check.
	* cvt.c (early_elide_copy): New.
	(ocp_convert): Use it.
	* except.c (build_throw): Use it.
	* init.c (get_nsdmi): Put back the TARGET_EXPR.
	(expand_default_init): Call early_elide_copy.
	* typeck.c (cp_build_modify_expr): Call early_elide_copy.

From-SVN: r240845
2016-10-06 17:24:40 -04:00
Jakub Jelinek 342cfb3e73 Implement P0258R2 - helper for C++17 std::has_unique_object_representations trait c-family/
Implement P0258R2 - helper for C++17
	std::has_unique_object_representations trait
c-family/
	* c-common.h (enum rid): Add RID_HAS_UNIQUE_OBJ_REPRESENTATIONS.
	* c-common.c (c_common_reswords): Add
	__has_unique_object_representations.
cp/
	* cp-tree.h (enum cp_trait_kind): Add
	CPTK_HAS_UNIQUE_OBJ_REPRESENTATIONS.
	(struct lang_type_class): Add unique_obj_representations
	and unique_obj_representations_set bitfields.
	(CLASSTYPE_UNIQUE_OBJ_REPRESENTATIONS,
	CLASSTYPE_UNIQUE_OBJ_REPRESENTATIONS_SET): Define.
	(type_has_unique_obj_representations): Declare.
	* parser.c (cp_parser_primary_expression): Handle
	RID_HAS_UNIQUE_OBJ_REPRESENTATIONS.
	(cp_parser_trait_expr): Likewise.  Formatting fix.
	* semantics.c (trait_expr_value, finish_trait_expr): Handle
	CPTK_HAS_UNIQUE_OBJ_REPRESENTATIONS.
	* tree.c (type_has_unique_obj_representations): New function.
	(record_has_unique_obj_representations): New function.
	* cxx-pretty-print.c (pp_cxx_trait_expression): Handle
	CPTK_HAS_UNIQUE_OBJ_REPRESENTATIONS.
testsuite/
	* g++.dg/cpp1z/has-unique-obj-representations1.C: New test.
	* g++.dg/cpp1z/has-unique-obj-representations2.C: New test.

From-SVN: r240843
2016-10-06 23:17:44 +02:00
Jason Merrill bf9b09fbe2 Implement P0135R1, Guaranteed copy elision.
* cvt.c (ocp_convert): Don't re-copy a TARGET_EXPR in C++17.

From-SVN: r240820
2016-10-05 18:59:02 -04:00
Jason Merrill 5794b9f622 PR c++/54293 - binding reference to member of temporary
* call.c (reference_binding): Fix binding to member of temporary.

From-SVN: r240819
2016-10-05 18:58:55 -04:00
Jason Merrill 27afd940ce * call.c (extend_ref_init_temps): Fix TARGET_EXPR handling.
From-SVN: r240818
2016-10-05 18:57:58 -04:00
Jason Merrill 3bd034d018 * parser.c (cp_parser_skip_to_end_of_statement): Add missing break.
From-SVN: r240809
2016-10-05 15:59:28 -04:00
Jason Merrill 8b7033e0e1 * semantics.c (finish_compound_literal): Handle class placeholder.
From-SVN: r240802
2016-10-05 14:57:45 -04:00
Marek Polacek 17a9e3802a Implement P0305R1, Selection statements with initializer.
* cp-array-notation.c (create_an_loop): Call finish_init_stmt
	instead of finish_for_init_stmt.
	* cp-tree.h (finish_for_init_stmt): Rename to finish_init_stmt.
	* decl.c (poplevel): Adjust a comment.
	* init.c (build_vec_init): Call finish_init_stmt instead of
	finish_for_init_stmt.
	* name-lookup.c (pushdecl_maybe_friend_1): Adjust a comment.
	* name-lookup.h (enum scope_kind): Likewise.
	* parser.c (cp_parser_statement): Update commentary.
	(cp_parser_init_statement_p): New function.
	(cp_parser_selection_statement): Parse the optional init-statement.
	(cp_parser_for): Call finish_init_stmt instead of finish_for_init_stmt.
	(cp_parser_c_for): Likewise.
	(cp_convert_range_for): Call finish_init_stmt instead of finish_for_init_stmt.
	(cp_parser_range_for_member_function): Update commentary.
	(cp_parser_iteration_statement):
	(cp_parser_for_init_statement): Rename to cp_parser_init_statement.
	* pt.c (tsubst_omp_for_iterator): Update commentary.
	(tsubst_expr): Call finish_init_stmt instead of finish_for_init_stmt.
	* semantics.c (finish_for_init_stmt): Rename to finish_init_stmt.
	Update commentary.

	* g++.dg/cpp1z/init-statement1.C: New test.
	* g++.dg/cpp1z/init-statement2.C: New test.
	* g++.dg/cpp1z/init-statement3.C: New test.
	* g++.dg/cpp1z/init-statement4.C: New test.
	* g++.dg/cpp1z/init-statement5.C: New test.
	* g++.dg/cpp1z/init-statement6.C: New test.
	* g++.dg/cpp1z/init-statement7.C: New test.
	* g++.dg/cpp1z/init-statement8.C: New test.

From-SVN: r240798
2016-10-05 18:02:06 +00:00
Jason Merrill f1644724b5 PR c++/77852 - class deduction from list-init
* pt.c (do_class_deduction): Handle list-initialization.
	(do_auto_deduction): Call it sooner.
	(build_deduction_guide): Use tsubst_arg_types.
	(rewrite_template_parm): Don't copy_type.

From-SVN: r240765
2016-10-04 21:24:38 -04:00
Jason Merrill 2db613e5d3 PR c++/77775 - misoptimization of PMF comparison
* constexpr.c (cxx_eval_component_reference): Use name matching
	for PMFs.

From-SVN: r240757
2016-10-04 17:14:18 -04:00
Jason Merrill 76b294d48d Implement P0091R2, Template argument deduction for class templates.
* parser.c (cp_parser_simple_type_specifier): Parse class placeholder.
Use the location of the beginning of the type-specifier.
(cp_parser_init_declarator): Parse deduction guide.
(cp_parser_diagnose_invalid_type_name): Mention class deduction.
(cp_parser_type_id_1): Don't accept class placeholder as template arg.
* cp-tree.h (CLASS_PLACEHOLDER_TEMPLATE): New.
* decl.c (grokdeclarator): Check for uninitialized auto here.
(start_decl_1): Not here.
(cp_finish_decl): Or here.  Don't collapse a list when doing
class deduction.
(grokfndecl): Check deduction guide scope and body.
* error.c (dump_decl, dump_function_decl, dump_function_name):
Handle deduction guides.
* pt.c (make_template_placeholder, do_class_deduction): New.
(build_deduction_guide, rewrite_template_parm): New.
(dguide_name, dguide_name_p, deduction_guide_p): New.
(do_auto_deduction): Call do_class_deduction.
(splice_late_return_type, is_auto): Handle class placeholders.
(template_parms_level_to_args): Split from template_parms_to_args.
(tsubst_template_parms_level): Split from tsubst_template_parms.
* typeck2.c (build_functional_cast): Handle class placeholder.

From-SVN: r240756
2016-10-04 16:42:58 -04:00
Martin Sebor 8ff04ff92d PR c++/77804 - Internal compiler error on incorrect initialization of new-d array
gcc/cp/ChangeLog:

	PR c++/77804
	* init.c (warn_placement_new_too_small): Avoid assuming an array type
	has a constant size.

gcc/testsuite/ChangeLog:

	PR c++/77804
	* g++.dg/warn/Wplacement-new-size-4.C: New test.

From-SVN: r240754
2016-10-04 11:34:00 -06:00
Jakub Jelinek f72da96757 re PR c++/77791 (ICE on invalid C++11 code with redefined function parameter: tree check: expected tree that contains ‘decl minimal’ structure, have ‘error_mark’ in cp_parser_lambda_declarator_opt, at cp/parser.c:1011)
PR c++/77791
	* parser.c (cp_parser_lambda_declarator_opt): Only pedwarn
	for C++11 on decls in the param_list.  Test cxx_dialect < cxx14 before
	the loop just once.

	* g++.dg/cpp0x/lambda/lambda-77791.C: New test.

From-SVN: r240751
2016-10-04 17:34:16 +02:00
Jakub Jelinek bfecd57cd4 extend.texi (Java Exceptions): Remove.
* doc/extend.texi (Java Exceptions): Remove.
	(java_interface): Remove.
cp/
	* cp-tree.h (enum cp_tree_index): Remove CPTI_JAVA_*,
	CPTI_LANG_NAME_JAVA and CPTI_JCLASS.
	(java_byte_type_node, java_short_type_node, java_int_type_node,
	java_long_type_node, java_float_type_node, java_double_type_node,
	java_char_type_node, java_boolean_type_node, lang_name_java,
	jclass_node): Remove.
	(enum languages): Remove lang_java.
	(TYPE_FOR_JAVA): Remove.
	(struct lang_type_class): Remove java_interface bit-field.
	(TYPE_JAVA_INTERFACE): Remove.
	(pragma_java_exceptions): Remove.
	(check_java_method, build_java_class_ref): Remove prototypes.
	* name-lookup.c (pushtag_1): Don't set TYPE_FOR_JAVA.
	* decl2.c (acceptable_java_type, check_java_method): Remove.
	(import_export_decl): Remove TYPE_FOR_JAVA handling.
	(build_java_method_aliases): Remove.
	(c_parse_final_cleanups): Don't call build_java_method_aliases.
	(possibly_inlined_p): Don't test pragma_java_exceptions.
	* init.c (build_new_1): Remove TYPE_FOR_JAVA handling.
	(build_java_class_ref): Remove.
	* pt.c (maybe_new_partial_specialization, lookup_template_class_1,
	instantiate_class_template_1): Don't copy TYPE_FOR_JAVA.
	* except.c (eh_type_info): Remove java type handling.
	(decl_is_java_type, choose_personality_routine): Remove.
	(initialize_handler_parm): Don't call choose_personality_routine.
	(expand_start_catch_block): Don't handle java types.
	(build_throw): Likewise.
	* cp-lang.c (cp_eh_personality): Don't handle pragma_java_exceptions.
	* typeck.c (structural_comptypes): Don't compare TYPE_FOR_JAVA.
	* call.c (build_over_call): Don't handle TYPE_JAVA_INTERFACE.
	(java_iface_lookup_fn): Remove.
	(build_java_interface_fn_ref): Remove.
	* tree.c (cxx_attribute_table): Remove java_interface.
	(handle_java_interface_attribute): Remove.
	* lex.c (pragma_java_exceptions): Remove.
	(init_cp_pragma): Don't register GCC java_exceptions pragma.
	(handle_pragma_java_exceptions): Remove.
	(retrofit_lang_decl): Don't handle lang_name_java.
	* method.c (implicitly_declare_fn): Don't handle TYPE_FOR_JAVA.
	* error.c (language_to_string): Don't handle lang_java.
	* decl.c (record_builtin_java_type): Remove.
	(initialize_predefined_identifiers): Remove Java.
	(cxx_init_decl_processing): Remove java_*_type_node.
	(cp_finish_decl): Don't handle TYPE_FOR_JAVA.
	(grokfndecl): Likewise.
	(check_special_function_return_type): Likewise.
	(grokdeclarator): Don't set TYPE_FOR_JAVA.
	(grokparms): Don't handle TYPE_FOR_JAVA.
	(xref_basetypes): Likewise.
	(check_function_type): Likewise.
	(finish_constructor_body): Likewise.
	* mangle.c (write_builtin_type): Don't handle TYPE_FOR_JAVA
	and java_*_type_node.
	(write_bare_function_type): Don't handle TYPE_FOR_JAVA.
	(write_java_integer_type_codes): Remove.
	* class.c (add_method): Don't handle TYPE_FOR_JAVA.
	(add_implicitly_declared_members, determine_key_method,
	finish_struct_1): Likewise.
	(push_lang_context): Don't handle lang_name_java.
testsuite/
	* g++.dg/other/java3.C: Remove.
	* g++.dg/other/java1.C: Remove.
	* g++.dg/other/error12.C: Remove.
	* g++.dg/other/java2.C: Remove.
	* g++.dg/warn/Wnvdtor.C: Remove.
	* g++.dg/lookup/java1.C: Remove.
	* g++.dg/lookup/java2.C: Remove.
	* g++.dg/ext/pr34829.C: Remove.
	* g++.dg/ext/java-3.C: Remove.
	* g++.dg/ext/java-1.C: Remove.
	* g++.dg/ext/java-2.C: Remove.
	* g++.old-deja/g++.oliva/dwarf2.C: Remove.

From-SVN: r240750
2016-10-04 17:32:31 +02:00
Marek Polacek f41f1ceba6 Core 903
Core 903
	* typeck.c (cp_build_binary_op): Pass original operands to
	null_ptr_cst_p, not those after the default conversions.

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

From-SVN: r240707
2016-10-03 08:10:43 +00:00
Bernd Edlinger 1633d3b91a invoke.texi: Update -Wint-in-bool-context.
2016-10-03  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * doc/invoke.texi: Update -Wint-in-bool-context.

c-family:
2016-10-03  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * c-common.c (c_common_truthvalue_conversion): Warn for suspicious
        left shift in boolean context.

cp:
2016-10-03  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * parser.c (cp_parser_condition): Fix a warning.

testsuite:
2016-10-03  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * c-c++-common/Wint-in-bool-context.c: Update test.

From-SVN: r240706
2016-10-03 08:00:21 +00:00
Jakub Jelinek a2c6e7f26e Implement P0001R1 - C++17 removal of register storage class specifier c-family/
Implement P0001R1 - C++17 removal of register storage class specifier
c-family/
	* c.opt (Wregister): New warning.
	* c-opts.c (c_common_post_options): Enable -Wregister by
	default for C++17.
cp/
	* decl.c (cp_finish_decl): Diagnose register storage class
	on vars except when used in GNU global or local register variable
	extension.
	(grokdeclarator): Diagnose register storage class on parameters.
	* except.c (expand_start_catch_block): Set DECL_REGISTER only
	after cp_finish_decl call.
testsuite/
	* c-c++-common/Wvarargs-2.c (foo1): Except new warning for C++17.
	* c-c++-common/vector-subscript-2.c (vf): Expect new error for
	C++17.
	* c-c++-common/vector-subscript-5.c (foo): Don't use register
	keyword if not __SSE2__.
	* c-c++-common/Wvarargs.c (foo1, foo3): Expect new warnings for
	C++17.
	* g++.dg/compat/struct-layout-1_generate.c (iterative_hash): Remove
	register keywords.
	* g++.dg/eh/pr29166.C: Add -Wno-register option.
	* g++.dg/warn/register-parm-1.C (erroneous_warning,
	no_erroneous_warning): Expect new warnings for C++17.
	* g++.dg/warn/register-var-2.C (f): Likewise.
	* g++.dg/parse/register1.C (f): Expect new error for C++17.
	* g++.dg/parse/linkage2.C (foo): Likewise.
	* g++.dg/torture/pr36826.C (CoinMin, CoinMax): Avoid register
	keyword on parameters for C++17.
	* g++.dg/cpp1z/register1.C: New test.
	* g++.dg/cpp1z/register2.C: New test.
	* g++.dg/cpp1z/register3.C: New test.

From-SVN: r240638
2016-09-29 22:54:56 +02:00
Marek Polacek 0b4b9552ee rtti.c (involves_incomplete_p): Add fall through comment.
* rtti.c (involves_incomplete_p): Add fall through comment.

	* dwarf2out.c (loc_descriptor): Add fall through comment.
	(add_const_value_attribute): Likewise.

From-SVN: r240624
2016-09-29 16:04:17 +00:00
Jakub Jelinek 4b3906980a re PR c++/77467 (Segmentation fault with switch statement in constexpr function)
PR c++/77467
	* constexpr.c (enum constexpr_switch_state): New.
	(struct constexpr_ctx): Add css_state field.
	(label_matches): Add CTX and STMT arguments, remove I and
	DEFAULT_LABEL.  For CASE_LABEL_EXPR assert ctx->css_state != NULL,
	handle default labels according to css_state.
	(cxx_eval_statement_list): Remove statement skipping, label_matches
	and default_label handling code.
	(cxx_eval_loop_expr): Exit after first iteration even if
	switches (jump_target).
	(cxx_eval_switch_expr): Set up css_state field in ctx, if default
	label has been seen in the body, but no cases matched, evaluate
	the body second time.
	(cxx_eval_constant_expression): Handle stmt skipping and label_matches
	here.  Handle PREDICT_EXPR.  For MODIFY_EXPR or INIT_EXPR, assert
	statement is not skipped.  For COND_EXPR during skipping, don't
	evaluate condition, just the then block and if still skipping at the
	end also the else block.
	(cxx_eval_outermost_constant_expr): Adjust constexpr_ctx initializer.
	(is_sub_constant_expr): Likewise.

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

From-SVN: r240591
2016-09-28 21:21:47 +02:00
Jakub Jelinek 8ca3334717 Implement P0018R3, C++17 lambda capture of *this by value as [=,*this]
Implement P0018R3, C++17 lambda capture of *this by value as [=,*this]
	* parser.c (cp_parser_lambda_introducer): Formatting fix.  Pass
	true instead of false as by_reference_p to add_capture for 'this'.
	Parse '*this' simple-capture.
	* lambda.c (build_capture_proxy): Handle '*this' capture by value.
	(add_capture): Adjust function comment.  For id == this_identifier,
	treat by_reference_p as capturing '*this' by reference, i.e. 'this'
	by value, and !by_reference_p as capturing '*this' by value.
	(add_default_capture): For implicit 'this' capture, always pass
	by_reference_p true rather than false.

	* g++.dg/cpp1z/lambda-this1.C: New test.
	* g++.dg/cpp1z/lambda-this2.C: New test.

From-SVN: r240556
2016-09-27 21:10:38 +02:00
Jakub Jelinek 459bcfb0be re PR c++/77722 (-fsanitize=undefined doesn't give runtime error in function without return value, unless at least 2 instructions)
PR c++/77722
	* cp-gimplify.c (cp_ubsan_maybe_instrument_return): Instrument also
	functions that have just a STATEMENT_LIST instead of BIND_EXPR, or
	BIND_EXPR with some statement rather than STATEMENT_LIST as body.

	* g++.dg/ubsan/return-4.C: New test.
	* g++.dg/ubsan/return-5.C: New test.
	* g++.dg/ubsan/return-6.C: New test.

From-SVN: r240555
2016-09-27 20:15:21 +02:00
Nathan Sidwell c0cdf62c2e init.c (expand_default_init): Fix } indentation.
* init.c (expand_default_init): Fix } indentation.
	* method.c (process_subob_fn): Simplify control structure to
	remove gotos.
	(implicitly_declare_fn): Remove duplicated lambda ctor check.

From-SVN: r240489
2016-09-26 10:29:53 +00:00
Marek Polacek 81fea426da Implement -Wimplicit-fallthrough.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r240485
2016-09-26 09:42:50 +00:00
Marek Polacek 9a2300e956 re PR c/77490 (bit-not (~) on boolean should be warned about)
PR c/77490
	* c.opt (Wbool-operation): New.

	* c-typeck.c (build_unary_op): Warn about bit not on expressions that
	have boolean value.  Warn about ++/-- on booleans.

	* typeck.c (cp_build_unary_op): Warn about bit not on expressions that
	have boolean value.

	* doc/invoke.texi: Document -Wbool-operation.

	* c-c++-common/Wbool-operation-1.c: New test.
	* gcc.dg/Wbool-operation-1.c: New test.

From-SVN: r240462
2016-09-24 09:39:23 +00:00
Jakub Jelinek d664d76d00 Implement P0138R2, C++17 construction rules for enum class values
Implement P0138R2, C++17 construction rules for enum class values
	* cp-tree.h (is_direct_enum_init): Declare.
	* decl.c (is_direct_enum_init): New function.
	(reshape_init): Use it.
	* typeck.c (convert_for_assignment): Likewise.

	* g++.dg/cpp1z/direct-enum-init1.C: New test.

From-SVN: r240449
2016-09-23 19:38:29 +02:00
Jakub Jelinek 24cae8cb9a Make-lang.in (check-c++1z): Pass RUNTESTFLAGS down to make check-g++.
* Make-lang.in (check-c++1z): Pass RUNTESTFLAGS down to
	make check-g++.

From-SVN: r240448
2016-09-23 19:32:38 +02:00
Jakub Jelinek 7de76362e4 sel-sched-ir.c (sel_global_bb_info, [...]): Remove unnecessary = vNULL initialization of file scope vec.
* sel-sched-ir.c (sel_global_bb_info, sel_region_bb_info,
	loop_nests, s_i_d, last_added_blocks): Remove unnecessary
	= vNULL initialization of file scope vec.
	* passes.c (pass_tab, enabled_pass_uid_range_tab,
	disabled_pass_uid_range_tab): Likewise.
	* haifa-sched.c (sched_luids, h_i_d): Likewise.
	* tree-chkp-opt.c (check_infos): Likewise.
	* sel-sched.c (vec_av_set, vec_temp_moveop_nops): Likewise.
c/
	* c-parser.c (incomplete_record_decls): Remove unnecessary
	= vNULL initialization of file scope vec.
cp/
	* constexpr.c (call_stack): Remove unnecessary
	= vNULL initialization of file scope vec.

From-SVN: r240444
2016-09-23 18:58:40 +02:00
Jakub Jelinek 199d1d488f ipa-cp.c (ipcp_store_vr_results): Avoid static local var zero.
* ipa-cp.c (ipcp_store_vr_results): Avoid static local
	var zero.
	* sreal.h (sreal::min, sreal::max): Avoid static local vars,
	construct values without normalization.
	* tree-ssa-sccvn.c (vn_reference_lookup_3): Don't initialize
	static local lhs_ops to vNULL.
cp/
	* name-lookup.c (store_bindings, store_class_bindings): Don't
	initialize static local bindings_need_stored to vNULL.

From-SVN: r240408
2016-09-23 11:43:09 +02:00
Jakub Jelinek aaa1b10f54 * hsa-gen.c (hsa_op_immed::hsa_op_immed Use CONSTRUCTOR_NELTS (...)
instead of vec_safe_length (CONSTRUCTOR_ELTS (...)).
	(gen_hsa_ctor_assignment): Likewise.
	* print-tree.c (print_node): Likewise.
	* tree-dump.c (dequeue_and_dump): Likewise.
	* tree-sra.c (sra_modify_constructor_assign): Likewise.
	* expr.c (store_constructor): Likewise.
	* fold-const.c (operand_equal_p): Likewise.
	* tree-pretty-print.c (dump_generic_node): Likewise.
	* hsa-brig.c (hsa_op_immed::emit_to_buffer): Likewise.
	* ipa-icf-gimple.c (func_checker::compare_operand): Likewise.
cp/
	* typeck2.c (process_init_constructor_record): Use
	CONSTRUCTOR_NELTS (...) instead of
	vec_safe_length (CONSTRUCTOR_ELTS (...)).
	* decl.c (reshape_init_r): Likewise.
	(check_initializer): Likewise.
ada/
	* gcc-interface/decl.c (gnat_to_gnu_entity): Use
	CONSTRUCTOR_NELTS (...) instead of
	vec_safe_length (CONSTRUCTOR_ELTS (...)).

From-SVN: r240390
2016-09-23 09:34:43 +02:00
Paolo Carlini a608d15bed re PR c++/71979 (ICE with on C++ code with incorrect type in overloaded base class '=' operator: in build_base_path, at cp/class.c:304)
/cp
2016-09-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/71979
	* class.c (build_base_path): Allow for lookup_base returning
	NULL_TREE.

/testsuite
2016-09-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/71979
	* g++.dg/cpp0x/pr71979.C: New.

From-SVN: r240373
2016-09-22 15:26:23 +00:00
Jason Merrill c67c64efbe Core 903
Core 903
	* call.c (null_ptr_cst_p): Check char_type_p.

From-SVN: r240329
2016-09-21 15:49:32 -04:00
Jakub Jelinek 2e1c20b144 re PR c++/77651 (c++ -Wno-aligned-new ICEs)
PR c++/77651
c-family/
	* c.opt (Waligned-new=): Add RejectNegative.
	(faligned-new=): Likewise.  Spelling fix - change
	aligned_new_threshhold to aligned_new_threshold.
	* c-cppbuiltin.c (c_cpp_builtins): Change aligned_new_threshhold
	to aligned_new_threshold.
cp/
	* init.c (build_new_1): Don't suggest to use -faligned-new if
	aligned_new_threshold is non-zero.
	(type_has_new_extended_alignment): Change aligned_new_threshhold
	to aligned_new_threshold.
	* call.c (second_parm_is_size_t, aligned_allocation_fn_p,
	aligned_deallocation_fn_p, build_op_delete_call): Likewise.
	* decl.c (cxx_init_decl_processing): Likewise.
testsuite/
	* g++.dg/cpp1z/aligned-new6.C: New test.

From-SVN: r240317
2016-09-21 17:13:46 +02:00
Jakub Jelinek b912f962e2 re PR c++/77626 (ICE with -Wall on x86_64-linux-gnu (internal compiler error: Segmentation fault, byte_from_pos, cxx_fold_indirect_ref))
PR c++/77626
	* constexpr.c (cxx_fold_indirect_ref): Don't call byte_position on
	FIELD_DECLs with error_mark_node type.  Remove useless break; after
	return.

	* g++.dg/other/pr77626.C: New test.

From-SVN: r240267
2016-09-20 17:18:31 +02:00
Jakub Jelinek eaf1ece131 re PR c++/77638 (ICE on x86_64-linux-gnu (internal compiler error: tree check: expected tree that contains ‘decl common’ structure, have ‘error_mark’ in cp_parser_template_declaration_after_parameters, at cp/parser.c:25722))
PR c++/77638
	* parser.c (cp_parser_template_declaration_after_parameter): For 2
	argument operator"" template set ok to false for
	parm == error_mark_node.

	* g++.dg/cpp0x/udlit-tmpl-arg-neg2.C: New test.

From-SVN: r240266
2016-09-20 17:17:41 +02:00
Jakub Jelinek 590b62e90d re PR c++/77637 (ICE on x86_64-linux-gnu (Segmentation fault, tree_check, cp_parser_std_attribute_list...))
PR c++/77637
	* parser.c (cp_parser_std_attribute_list): Reject ... without
	preceding attribute.

	* g++.dg/cpp0x/gen-attrs-62.C: New test.

From-SVN: r240265
2016-09-20 17:16:55 +02:00
Bernd Edlinger 144a96e4c9 re PR c++/77434 (warn about suspicious precedence of ternary operator (?:))
gcc:
2016-09-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77434
        * doc/invoke.texi: Document -Wint-in-bool-context.

c-family:
2016-09-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77434
        * c.opt (Wcond-in-bool-context): New warning.
        * c-common.c (c_common_truthvalue_conversion): Warn on integer
        constants in boolean context.

cp:
2016-09-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77434
        * cvt.c (cp_convert_and_check): Suppress Wint-in-bool-context here.

testsuite:
2016-09-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77434
        * c-c++-common/Wint-in-bool-context.c: New test.

From-SVN: r240251
2016-09-19 22:10:11 +00:00
Patrick Palka 6101a7ab87 Fix PR c++/77639 (ICE during error recovery)
gcc/cp/ChangeLog:

	PR c++/77639
	* parser.c (cp_parser_class_head): When
	processing_template_parmlist, don't assume that the
	class-head may start an explicit specialization.

gcc/testsuite/ChangeLog:

	PR c++/77639
	* g++.dg/template/error-recovery4.C: New test.

From-SVN: r240245
2016-09-19 18:12:36 +00:00
Jakub Jelinek 8f03e02f36 re PR c++/77482 (Segfault when compiling ill-formed constexpr code)
PR c++/77482
	* error.c (dump_simple_decl): Only check DECL_DECLARED_CONCEPT_P
	if DECL_LANG_SPECIFIC is non-NULL.  Fix up formatting.

	* g++.dg/cpp0x/constexpr-77482.C: New test.

From-SVN: r240198
2016-09-16 22:25:17 +02:00
Jakub Jelinek 1c2f613fbc re PR c++/77338 (ICE on invalid C++11 code on x86_64-linux-gnu: Segmentation fault)
PR c++/77338
	* constexpr.c (cxx_eval_constant_expression) <case PARM_DECL>: Only
	call is_really_empty_class on complete types.

	* g++.dg/cpp0x/decltype-77338.C: New test.

From-SVN: r240196
2016-09-16 22:22:35 +02:00
Jakub Jelinek e7d6117809 re PR c++/77375 (constant object with mutable subobject allocated in read-only memory)
PR c++/77375
	* class.c (check_bases): Set CLASSTYPE_HAS_MUTABLE if any TYPE_HAS_MUTABLE_P
	for any bases.

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

From-SVN: r240195
2016-09-16 22:21:29 +02:00
Jason Merrill 146ec50fd5 Add inline functions for various bitwise operations.
* hwint.h (least_bit_hwi, pow2_or_zerop, pow2p_hwi, ctz_or_zero):
	New.
	* hwint.c (exact_log2): Use pow2p_hwi.
	(ctz_hwi, ffs_hwi): Use least_bit_hwi.
	* alias.c (memrefs_conflict_p): Use pow2_or_zerop.
	* builtins.c (get_object_alignment_2, get_object_alignment)
	(get_pointer_alignment, fold_builtin_atomic_always_lock_free): Use
	least_bit_hwi.
	* calls.c (compute_argument_addresses, store_one_arg): Use
	least_bit_hwi.
	* cfgexpand.c (expand_one_stack_var_at): Use least_bit_hwi.
	* combine.c (force_to_mode): Use least_bit_hwi.
	* emit-rtl.c (set_mem_attributes_minus_bitpos, adjust_address_1):
	Use least_bit_hwi.
	* expmed.c (synth_mult, expand_divmod): Use ctz_or_zero, ctz_hwi.
	(init_expmed_one_conv): Use pow2p_hwi.
	* fold-const.c (round_up_loc, round_down_loc): Use pow2_or_zerop.
	(fold_binary_loc): Use pow2p_hwi.
	* function.c (assign_parm_find_stack_rtl): Use least_bit_hwi.
	* gimple-fold.c (gimple_fold_builtin_memory_op): Use pow2p_hwi.
	* gimple-ssa-strength-reduction.c (replace_ref): Use least_bit_hwi.
	* hsa-gen.c (gen_hsa_addr_with_align, hsa_bitmemref_alignment):
	Use least_bit_hwi.
	* ipa-cp.c (ipcp_alignment_lattice::meet_with_1): Use least_bit_hwi.
	* ipa-prop.c (ipa_modify_call_arguments): Use least_bit_hwi.
	* omp-low.c (oacc_loop_fixed_partitions)
	(oacc_loop_auto_partitions): Use least_bit_hwi.
	* rtlanal.c (nonzero_bits1): Use ctz_or_zero.
	* stor-layout.c (place_field): Use least_bit_hwi.
	* tree-pretty-print.c (dump_generic_node): Use pow2p_hwi.
	* tree-sra.c (build_ref_for_offset): Use least_bit_hwi.
	* tree-ssa-ccp.c (ccp_finalize): Use least_bit_hwi.
	* tree-ssa-math-opts.c (bswap_replace): Use least_bit_hwi.
	* tree-ssa-strlen.c (handle_builtin_memcmp): Use pow2p_hwi.
	* tree-vect-data-refs.c (vect_analyze_group_access_1)
	(vect_grouped_store_supported, vect_grouped_load_supported)
	(vect_permute_load_chain, vect_shift_permute_load_chain)
	(vect_transform_grouped_load): Use pow2p_hwi.
	* tree-vect-generic.c (expand_vector_divmod): Use ctz_or_zero.
	* tree-vect-patterns.c (vect_recog_divmod_pattern): Use ctz_or_zero.
	* tree-vect-stmts.c (vectorizable_mask_load_store): Use
	least_bit_hwi.
	* tsan.c (instrument_expr): Use least_bit_hwi.
	* var-tracking.c (negative_power_of_two_p): Use pow2_or_zerop.

From-SVN: r240194
2016-09-16 15:20:44 -04:00
Jakub Jelinek 28ca05f00a re PR c++/77549 (ICE on invalid C++ code that references undeclared variable)
PR c++/77549
	* name-lookup.c (consider_binding_level): Look through TREE_LIST
	and OVERLOAD.

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

From-SVN: r240148
2016-09-14 23:55:10 +02:00
Marek Polacek 20a1e5b8c8 typeck.c (cp_build_unary_op): Diagnose incrementing boolean expressions.
* typeck.c (cp_build_unary_op): Diagnose incrementing boolean
	expressions.  Tweak an error message.

	* c-c++-common/gomp/atomic-12.c: Use -Wno-deprecated.
	* c-c++-common/gomp/atomic-13.c: Likewise.
	* c-c++-common/gomp/atomic-14.c: Likewise.
	* g++.dg/cpp1y/lambda-init11.C: Remove invalid code.
	* g++.dg/cpp1z/bool-increment1.C: New test.
	* c-c++-common/pr60439.c: Add dg-warning.
	* g++.dg/expr/bitfield4.C: Likewise.
	* g++.dg/expr/bitfield5.C: Likewise.
	* g++.dg/expr/bitfield6.C: Likewise.
	* g++.dg/expr/bool1.C: Likewise.
	* g++.dg/expr/bool3.C: Likewise.
	* g++.dg/expr/lval3.C: Likewise.
	* g++.dg/expr/lval4.C: Likewise.
	* g++.old-deja/g++.jason/bool5.C: Likewise.
	* g++.dg/expr/bitfield3.C: Adjust dg-error.
	* g++.dg/other/error18.C: Likewise.
	* g++.dg/gomp/atomic-14.C: Likewise.
libgomp/
	* testsuite/libgomp.c++/atomic-3.C: Use -Wno-deprecated.
libstdc++-v3/
	* testsuite/23_containers/vector/debug/insert6_neg.cc: Use
	-Wno-deprecated.

From-SVN: r240141
2016-09-14 17:46:59 +00:00
Marek Polacek e51fbec3ff c-common.c (c_common_truthvalue_conversion): Use false instead of 0.
* c-common.c (c_common_truthvalue_conversion): Use false instead of 0.
	* c-common.h (build_unary_op): Change nonconvert parameter type to bool.
	* c-omp.c (c_finish_omp_atomic): Use false instead of 0.

	* c-array-notation.c (create_cmp_incr): Use false instead of 0.
	(fix_array_notation_expr): Likewise.
	* c-decl.c (finish_decl): Likewise.
	* c-parser.c (c_parser_postfix_expression_after_primary): Likewise.
	* c-typeck.c (array_to_pointer_conversion): Use true instead of 1.
	(function_to_pointer_conversion): Use false instead of 0.
	(convert_lvalue_to_rvalue): Likewise.
	(parser_build_unary_op): Likewise.
	(build_atomic_assign): Likewise.
	(build_unary_op): Change nonconvert parameter type to bool, use
	true/false instead of 1/0.
	(build_binary_op): Use true instead of 1.

	* cp-tree.h (cp_build_unary_op): Change nonconvert parameter type to
	bool.
	* decl2.c (one_static_initialization_or_destruction): Use true instead
	of 1.
	* init.c (build_vec_init): Use false instead of 0.
	* pt.c (tsubst_copy_and_build): Likewise.
	* semantics.c (simplify_loop_decl_cond): Likewise.
	* typeck.c (rationalize_conditional_expr): Likewise.
	(cp_build_binary_op): Use true instead of 1.
	(cp_build_unary_op): Change nonconvert parameter type to bool.  Use true
	instead of 1.
	(build_unary_op): Change nonconvert parameter type to bool.
	(unary_complex_lvalue): Use false instead of 0.

From-SVN: r240137
2016-09-14 15:05:00 +00:00
Jakub Jelinek 9952908a4b Implement P0028R4, C++17 using attribute namespaces without repetition
Implement P0028R4, C++17 using attribute namespaces without repetition
	* parser.c (cp_parser_std_attribute): Add ATTR_NS argument.  Diagnose
	non-NULL ATTR_NS with scoped attribute token.  Handle non-NULL
	ATTR_NS with non-scoped attribute tokens.  Allow named ops in
	identifier after ::.
	(cp_parser_std_attribute_list): Add ATTR_NS argument, pass it down
	to cp_parser_std_attribute calls.
	(cp_parser_std_attribute_spec): Parse optional C++17
	attribute-using-prefix, adjust grammar in function comment.

	* g++.dg/cpp0x/gen-attrs-61.C: New test.
	* g++.dg/cpp1z/gen-attrs1.C: New test.

From-SVN: r240121
2016-09-13 21:20:38 +02:00
Jakub Jelinek ea8661cd47 re PR c++/77553 (wrong code with post-increment operator in constexpr)
PR c++/77553
	* constexpr.c (cxx_fold_pointer_plus_expression): New function.
	(cxx_eval_binary_expression): Use it for POINTER_PLUS_EXPR.
	(cxx_eval_pointer_plus_expression): Remove.
	(cxx_eval_constant_expression) <case POINTER_PLUS_EXPR>: Don't
	call cxx_eval_pointer_plus_expression.

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

From-SVN: r240119
2016-09-13 19:10:39 +02:00
David Malcolm 254830bab2 fix-it hints: insert_before vs insert_after
The API for adding "insert text" fix-it hints was unclear
about exactly where the text should be inserted relative
to the given insertion point.

This patch clarifies things by renaming the pertinent methods from
  richloc.add_fixit_insert
to
  richloc.add_fixit_insert_before
and adding:
  richloc.add_fixit_insert_after

The latter allows us to consolidate some failure-handling into
class rich_location, rather than having to have every such diagnostic
check for it.

The patch also adds a description of how fix-it hints work to the
comment for class rich_location within libcpp/include/line-map.h.

gcc/c-family/ChangeLog:
	* c-common.c (warn_logical_not_parentheses): Replace
	rich_location::add_fixit_insert calls with add_fixit_insert_before
	and add_fixit_insert_after, eliminating the "next_loc" calculation.

gcc/c/ChangeLog:
	* c-parser.c (c_parser_declaration_or_fndef): Update for renaming
	of add_fixit_insert to add_fixit_insert_before.

gcc/cp/ChangeLog:
	* parser.c (cp_parser_class_specifier_1): Update for renaming of
	add_fixit_insert to add_fixit_insert_before.
	(cp_parser_class_head): Likewise.

gcc/ChangeLog:
	* diagnostic-show-locus.c (selftest::test_one_liner_fixit_insert):
	Rename to...
	(selftest::test_one_liner_fixit_insert_before): ...this, and update
	for renaming of add_fixit_insert to add_fixit_insert_before.
	(selftest::test_one_liner_fixit_insert_after): New function.
	(selftest::test_one_liner_fixit_validation_adhoc_locations):
	Update for renaming of add_fixit_insert to
	add_fixit_insert_before.
	(selftest::test_one_liner_many_fixits): Likewise.
	(selftest::test_diagnostic_show_locus_one_liner): Update for
	renaming, call new test function.
	(selftest::test_diagnostic_show_locus_fixit_lines): Update for
	renaming of add_fixit_insert to add_fixit_insert_before.
	(selftest::test_fixit_consolidation): Likewise.
	* diagnostic.c (selftest::test_print_parseable_fixits_insert):
	Likewise.
	* edit-context.c (selftest::test_applying_fixits_insert): Rename
	to...
	(selftest::test_applying_fixits_insert_before): ...this.
	(selftest::test_applying_fixits_insert): Update for renaming of
	add_fixit_insert to add_fixit_insert_before.
	(selftest::test_applying_fixits_insert_after): New function.
	(selftest::test_applying_fixits_insert_after_at_line_end): New
	function.
	(selftest::test_applying_fixits_insert_after_failure): New
	function.
	(selftest::test_applying_fixits_multiple): Update for renaming of
	add_fixit_insert to add_fixit_insert_before.
	(selftest::change_line): Likewise.
	(selftest::test_applying_fixits_unreadable_file): Likewise.
	(selftest::test_applying_fixits_line_out_of_range): Likewise.
	(selftest::test_applying_fixits_column_validation): Likewise.
	(selftest::test_applying_fixits_column_validation): Likewise.
	(selftest::edit_context_c_tests): Update for renamed test
	function; call new test functions.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
	(test_show_locus): Replace rich_location::add_fixit_insert calls
	with add_fixit_insert_before and add_fixit_insert_after.

libcpp/ChangeLog:
	* include/line-map.h (class rich_location): Add description of
	fix-it hints to leading comment.
	(rich_location::add_fixit_insert): Rename both overloaded methods
	to..
	(rich_location::add_fixit_insert_before): ...this, updating their
	comments.
	(rich_location::add_fixit_insert_after): Two new overloaded
	methods.
	(rich_location::stop_supporting_fixits): New method.
	* line-map.c (rich_location::add_fixit_insert): Rename both
	overloaded methods to..
	(rich_location::add_fixit_insert_before): ...this, updating their
	comments.
	(rich_location::add_fixit_insert_after): Two new methods.
	(rich_location::reject_impossible_fixit): Split out
	failure-handling into...
	(rich_location::stop_supporting_fixits): New method.

From-SVN: r240115
2016-09-13 16:08:59 +00:00
Bernd Edlinger 54dcdb8895 re PR c++/77496 (ICE in instantiate_type, at cp/class.c:8270)
gcc/c-family:
2016-09-12  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77496
        * c-common.c (warn_for_omitted_condop): Also warn for boolean data.

gcc/c:
2016-09-12  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77496
        * c-parser.c (c_parser_conditional_expression): Pass the rightmost
        COMPOUND_EXPR to warn_for_omitted_condop.

gcc/cp:
2016-09-12  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77496
        * call.c (build_conditional_expr_1): Call warn_for_omitted_condop.
        * class.c (instantiate_type): Look through the SAVE_EXPR.

gcc/testsuite:
2016-09-12  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77496
        * c-c++-common/warn-ommitted-condop.c: Add more test cases.
        * g++.dg/ext/pr77496.C: New test.
        * g++.dg/warn/pr77496.C: New test.

From-SVN: r240098
2016-09-12 20:18:16 +00:00
Jason Merrill af63ba4b30 Implement P0035R4, C++17 new of over-aligned types.
gcc/cp/
	* cp-tree.h (enum cp_tree_index): Add CPTI_ALIGN_TYPE.
	(align_type_node): New macro.
	* call.c (build_operator_new_call): Handle C++17 aligned new.
	(second_parm_is_size_t, build_op_delete_call): Likewise.
	(non_placement_deallocation_fn_p): Likewise. Rename to
	usual_deallocation_fn_p.
	(aligned_allocation_fn_p, aligned_deallocation_fn_p): New.
	* decl.c (cxx_init_decl_processing): Add aligned new support.
	* init.c (type_has_new_extended_alignment): New.
	(build_new_1): Handle aligned new.
	* tree.c (vec_copy_and_insert): New.
gcc/c-family/
	* c.opt: Add -faligned-new and -Waligned-new.
	* c-common.c (max_align_t_align): Split out from...
	(cxx_fundamental_alignment_p): ...here.
	* c-common.h: Declare it.
	* c-cppbuiltin.c (c_cpp_builtins): Handle aligned new.
libstdc++-v3/
	* libsupc++/new: Declare aligned new/delete operators.
	* config/abi/pre/gnu.ver: Export them.
	* configure.ac: Check for aligned_alloc, posix_memalign, memalign,
	_aligned_malloc.
	* libsupc++/new_opa.cc: New.
	* libsupc++/new_opant.cc: New.
	* libsupc++/new_opva.cc: New.
	* libsupc++/new_opva.cc: New.
	* libsupc++/del_opa.cc: New.
	* libsupc++/del_opant.cc: New.
	* libsupc++/del_opsa.cc: New.
	* libsupc++/del_opva.cc: New.
	* libsupc++/del_opvant.cc: New.
	* libsupc++/del_opvsa.cc: New.
	* libsupc++/Makefile.am: Build them.

From-SVN: r240056
2016-09-09 17:22:15 -04:00
Jakub Jelinek 3f8257db2e ChangeLog formatting fixes.
From-SVN: r239997
2016-09-05 21:42:42 +02:00
Jakub Jelinek 94087e88e0 re PR sanitizer/77396 (address sanitizer crashes if all static global variables are optimized)
PR sanitizer/77396
	* sanopt.c: Include gimple-ssa.h, tree-phinodes.h and ssa-iterators.h.
	(sanopt_optimize_walker): Optimize away
	__asan_before_dynamic_init (...) followed by
	__asan_after_dynamic_init () without intervening memory loads/stores.
	* ipa-pure-const.c (special_builtin_state): Handle
	BUILT_IN_ASAN_BEFORE_DYNAMIC_INIT and
	BUILT_IN_ASAN_AFTER_DYNAMIC_INIT.

	* decl2.c (do_static_initialization_or_destruction): Only
	call asan_dynamic_init_call if INITP is true.

	* g++.dg/asan/pr77396.C: New test.

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

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

gcc/cp/ChangeLog:

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

gcc/go/ChangeLog:

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

gcc/java/ChangeLog:

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

gcc/ChangeLog:

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

From-SVN: r239949
2016-09-01 16:47:49 -06:00
Marek Polacek 295844f687 re PR c/7652 (-Wswitch-break : Warn if a switch case falls through)
PR c/7652
gcc/c-family/
	* c-common.c (resolve_overloaded_builtin): Fix formatting.  Add
	FALLTHRU comments.
gcc/c/
	* c-typeck.c (composite_type): Add FALLTHRU comment.
gcc/gcc/cp/
	* error.c (dump_type): Fix falls through comment.
	(dump_decl): Likewise.
	(dump_expr): Likewise.

From-SVN: r239939
2016-09-01 14:59:50 +00:00