Commit Graph

871 Commits

Author SHA1 Message Date
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
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
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
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +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
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
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 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 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 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 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
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
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
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 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
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
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
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
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
Jason Merrill 49b5925f02 PR c++/72457 - ICE with list-value-initialized base.
* init.c (expand_aggr_init_1): Only handle value-init of bases.
	* constexpr.c (build_data_member_initialization): Handle multiple
	initializers for the same field.

From-SVN: r238867
2016-07-29 10:03:26 -04:00
Jason Merrill f388b7be18 PR c++/55922 - list-value-initialization of base
PR c++/63151
	* init.c (expand_aggr_init_1): Handle list-initialization from {}.

From-SVN: r238688
2016-07-23 22:56:22 -04:00
Jason Merrill d1dfa20d80 PR c++/70824 - initializer_list in template
* init.c (constant_value_1): Don't instantiated DECL_INITIAL of
	artificial variables.

From-SVN: r238386
2016-07-15 14:37:48 -04:00
Jason Merrill 72b3e20335 Use lvalue_p instead of real_lvalue_p.
* cp-tree.h: Unpoison lvalue_p.
	* call.c, class.c, constexpr.c, cvt.c, init.c, lambda.c, pt.c,
	tree.c, typeck.c, typeck2.c: Use lvalue_p instead of
	real_lvalue_p.

From-SVN: r238183
2016-07-08 17:32:18 -04:00
Jason Merrill bb19d4af73 Rename lvalue_p to obvalue_p.
* tree.c (obvalue_p): Rename from lvalue_p.
	(lvalue_p): Define for c-common.
	* call.c, cp-tree.h, cvt.c, init.c: Adjust.
	* typeck.c: Adjust.
	(cp_build_addr_expr_1): Remove obsolete code.

From-SVN: r238182
2016-07-08 17:32:12 -04:00
Martin Sebor 265149a6ae PR c++/71306 - bogus -Wplacement-new with an array element
gcc/cp/ChangeLog:
2016-05-27  Martin Sebor  <msebor@redhat.com>

	PR c++/71306
	* init.c (warn_placement_new_too_small): Handle placement new arguments
	that are elements of arrays more carefully.  Remove a pointless loop.

gcc/testsuite/ChangeLog:
2016-05-27  Martin Sebor  <msebor@redhat.com>

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

From-SVN: r236902
2016-05-30 16:56:43 -06:00
Marek Polacek 4f2e1536a3 re PR c/70756 (Wrong column number shown for "error: invalid use of flexible array member")
PR c/70756
	* c-common.c (pointer_int_sum): Call size_in_bytes_loc instead of
	size_in_bytes and pass LOC to it.

	* c-decl.c (build_compound_literal): Pass LOC down to
	c_incomplete_type_error.
	* c-tree.h (require_complete_type): Adjust declaration.
	(c_incomplete_type_error): Likewise.
	* c-typeck.c (require_complete_type): Add location parameter, pass it
	down to c_incomplete_type_error.
	(c_incomplete_type_error): Add location parameter, pass it down to
	error_at.
	(build_component_ref): Pass location down to c_incomplete_type_error.
	(default_conversion): Pass location down to require_complete_type.
	(build_array_ref): Likewise.
	(build_function_call_vec): Likewise.
	(convert_arguments): Likewise.
	(build_unary_op): Likewise.
	(build_c_cast): Likewise.
	(build_modify_expr): Likewise.
	(convert_for_assignment): Likewise.
	(c_finish_omp_clauses): Likewise.

	* call.c (build_new_op_1): Pass LOC to cp_build_modify_expr.
	* cp-tree.h (cp_build_modify_expr): Update declaration.
	(cxx_incomplete_type_error, cxx_incomplete_type_diagnostic): New inline
	overloads.
	* cp-ubsan.c (cp_ubsan_dfs_initialize_vtbl_ptrs): Pass INPUT_LOCATION to
	cp_build_modify_expr.
	* decl2.c (set_guard): Likewise.
	(handle_tls_init): Likewise.
	* init.c (perform_member_init): Likewise.
	(expand_virtual_init): Likewise.
	(build_new_1): Likewise.
	(build_vec_delete_1): Likewise.
	(get_temp_regvar): Likewise.
	(build_vec_init): Likewise.
	* method.c (do_build_copy_assign): Likewise.
	(assignable_expr): Likewise.
	* semantics.c (finish_omp_for): Likewise.
	* typeck.c (cp_build_binary_op): Pass LOCATION to pointer_diff and
	cp_pointer_int_sum.
	(cp_pointer_int_sum): Add location parameter.  Pass it down to
	pointer_int_sum.
	(pointer_diff): Add location parameter.  Use it.
	(build_modify_expr): Pass location down to cp_build_modify_expr.
	(cp_build_modify_expr): Add location parameter.  Use it.
	(build_x_modify_expr): Pass location down to cp_build_modify_expr.
	* typeck2.c (cxx_incomplete_type_diagnostic,
	cxx_incomplete_type_error): Add location parameter.

	* langhooks-def.h (lhd_incomplete_type_error): Adjust declaration.
	* langhooks.c (lhd_incomplete_type_error): Add location parameter.
	* langhooks.h (incomplete_type_error): Likewise.
	* tree.c (size_in_bytes_loc): Renamed from size_in_bytes.  Add location
	parameter, pass it down to incomplete_type_error.
	* tree.h (size_in_bytes): New inline overload.
	(size_in_bytes_loc): Renamed from size_in_bytes.

	* c-c++-common/pr70756-2.c: New test.
	* c-c++-common/pr70756.c: New test.

From-SVN: r236180
2016-05-12 15:28:08 +00:00
Richard Sandiford 8de73453a4 Support << and >> for offset_int and widest_int
Following on from the comparison patch, I think it makes sense to
support << and >> for offset_int (int128_t) and widest_int (intNNN_t),
with >> being arithmetic shift.  It doesn't make sense to use
logical right shift on a potentially negative offset_int, since
the precision of 128 bits has no meaning on the target.

Tested on x86_64-linux-gnu and aarch64-linux-gnu.

gcc/
	* wide-int.h: Update offset_int and widest_int documentation.
	(WI_SIGNED_SHIFT_RESULT): New macro.
	(wi::binary_shift): Define signed_shift_result_type for
	shifts on offset_int- and widest_int-like types.
	(generic_wide_int): Support <<= and >>= if << and >> are supported.
	* tree.h (int_bit_position): Use shift operators instead of wi::
	 shifts.
	* alias.c (adjust_offset_for_component_ref): Likewise.
	* expr.c (get_inner_reference): Likewise.
	* fold-const.c (fold_comparison): Likewise.
	* gimple-fold.c (fold_nonarray_ctor_reference): Likewise.
	* gimple-ssa-strength-reduction.c (restructure_reference): Likewise.
	* tree-dfa.c (get_ref_base_and_extent): Likewise.
	* tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Likewise.
	(stmt_kills_ref_p): Likewise.
	* tree-ssa-ccp.c (bit_value_binop_1): Likewise.
	* tree-ssa-math-opts.c (find_bswap_or_nop_load): Likewise.
	* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Likewise.
	(ao_ref_init_from_vn_reference): Likewise.

gcc/cp/
	* init.c (build_new_1): Use shift operators instead of wi:: shifts.

From-SVN: r235720
2016-05-02 09:39:38 +00:00
Nathan Sidwell ee392fc292 re PR c++/55635 (Deallocation function ("operator delete") not called when destructor throws exception)
cp/
	PR c++/55635
	* init.c (build_vec_delete_1): Protect operator delete call in try
	finally.
	(build_delete): Likewise.
	* optimize.c (build_delete_destructor_body): Likewise.

	testsuite/
	PR c++/55635
	* g++.dg/eh/delete1.C: New.

From-SVN: r235297
2016-04-20 19:59:56 +00:00
Martin Sebor d8747845fd PR c++/70652 - [6 Regression] r234966 causes bootstrap to fail
PR c++/70652 - [6 Regression] r234966 causes bootstrap to fail
  Revert patch for c++/69517, c++/70019, and c++/70588.

From-SVN: r234981
2016-04-14 11:35:23 -06:00
Martin Sebor 342fac9537 PR c++/69517 - [5/6 regression] SEGV on a VLA with excess initializer elements
PR c++/69517 - [5/6 regression] SEGV on a VLA with excess initializer elements
PR c++/70019 - VLA size overflow not detected
PR c++/70588 - SIGBUS on a VLA larger than SIZE_MAX / 2

gcc/testsuite/ChangeLog:
2016-04-13  Martin Sebor  <msebor@redhat.com>

        PR c++/69517
        PR c++/70019
        PR c++/70588
        * c-c++-common/ubsan/vla-1.c (main): Catch exceptions.
        * g++.dg/cpp1y/vla11.C: New test.
        * g++.dg/cpp1y/vla12.C: New test.
        * g++.dg/cpp1y/vla13.C: New test.
        * g++.dg/cpp1y/vla14.C: New test.
        * g++.dg/cpp1y/vla3.C: Restore deleted test.
        * gcc/testsuite/g++.dg/init/array24.C: Fully brace VLA initializer.
        * g++.dg/ubsan/vla-1.C: Disable exceptions.

gcc/cp/ChangeLog:
2016-04-13  Martin Sebor  <msebor@redhat.com>

        PR c++/69517
        PR c++/70019
        PR c++/70588
        * cp-tree.h (throw_bad_array_length, build_vla_check): Declare new
        functions.
        * decl.c (check_initializer, cp_finish_decl): Call them.
        (reshape_init_r): Reject incompletely braced intializer-lists
        for VLAs.
        * init.c (throw_bad_array_length, build_vla_check)
        (build_vla_size_check, build_vla_init_check): Define new functions.
        * typeck2.c (split_nonconstant_init_1): Use variably_modified_type_p()
        to detect a VLA.
        (store_init_value): Same.

gcc/doc/ChangeLog:
2016-04-13  Martin Sebor  <msebor@redhat.com>

        PR c++/69517
        PR c++/70019
        PR c++/70588
        * extend.texi (Variable Length): Document C++ specifics.

libstdc++-v3/ChangeLog:
2016-04-13  Martin Sebor  <msebor@redhat.com>

        PR c++/69517
        * testsuite/25_algorithms/rotate/moveable2.cc: Make sure VLA
       upper bound is positive.

From-SVN: r234966
2016-04-13 17:26:41 -06:00
Jakub Jelinek 0f87543524 re PR c++/70488 (ICE in tree.c:7345 triggered by warning of placement new too small on VLA)
PR c++/70488
	* init.c (warn_placement_new_too_small): Test whether
	DECL_SIZE_UNIT or TYPE_SIZE_UNIT are integers that fit into uhwi.

	* g++.dg/init/new47.C: New test.

Co-Authored-By: Marek Polacek <polacek@redhat.com>

From-SVN: r234676
2016-04-01 17:27:11 +02:00
Jason Merrill eb0dbdc723 class.c (build_if_in_charge): Split out from build_base_path.
* class.c (build_if_in_charge): Split out from build_base_path.

	* init.c (expand_virtual_init, expand_default_init): Use it.
	* call.c (build_special_member_call): Use it.

From-SVN: r234333
2016-03-18 11:31:24 -04:00
Jakub Jelinek dd12502693 re PR c++/70267 (ICE on invalid code at -O1 and above on x86_64-linux-gnu in propagate_necessity, at tree-ssa-dce.c:924)
PR c++/70267
	* init.c (build_new_1): Complain and return error_mark_node
	if alloc_fn is not _Jv_AllocObject function returning pointer.

	* g++.dg/ext/java-3.C: New test.

From-SVN: r234319
2016-03-18 08:59:36 +01:00
Jason Merrill d5bcd6d4d7 re PR c++/69203 (ICE in potential_constant_expression_1, at cp/constexpr.c:4754)
PR c++/69203

	* cp-tree.h (COND_EXPR_IS_VEC_DELETE): New.
	* init.c (build_vec_delete_1): Set it.
	* constexpr.c (potential_constant_expression_1) [COND_EXPR]: Check it.

From-SVN: r233987
2016-03-04 17:53:29 -05:00
Jakub Jelinek 03ca8fb3da re PR c++/69922 (Bogus -Wnonnull-compare for: ... ? static_cast<T*>(this) : nullptr)
PR c++/69922
	* class.c (build_base_path): Set TREE_NO_WARNING on the null_test.
	Avoid folding it.
	* init.c (build_vec_delete_1, build_delete): Don't fold the non-NULL
	tests.
	* cp-gimplify.c (cp_fold): For TREE_NO_WARNING comparisons with NULL,
	unless they are folded into INTEGER_CST, error_mark_node or some
	comparison with NULL, avoid folding them and use either the original
	comparison or non-folded comparison of folded arguments.
	* cp-ubsan.c (cp_ubsan_instrument_vptr): Set TREE_NO_WARNING on the
	comparison, don't fold the comparison right away.

	* g++.dg/warn/Wnonnull-compare-6.C: New test.
	* g++.dg/warn/Wnonnull-compare-7.C: New test.
	* g++.dg/ubsan/pr69922.C: New test.

From-SVN: r233684
2016-02-24 23:01:24 +01:00
Jakub Jelinek 03a616ac36 re PR c++/69850 (unnecessary -Wnonnull-compare warning)
PR c++/69850
	* init.c (build_vec_delete_1): Set TREE_NO_WARNING on the NE_EXPR
	condition.
	* cp-gimplify.c (cp_fold): Propagate TREE_NO_WARNING from binary
	operators if folding preserved the binop, just with different
	arguments.

	* g++.dg/warn/Wnonnull-compare-2.C: New test.
	* g++.dg/warn/Wnonnull-compare-3.C: New test.

From-SVN: r233561
2016-02-19 17:02:51 +01:00
Jakub Jelinek 932c0da42d re PR c++/69850 (unnecessary -Wnonnull-compare warning)
PR c++/69850
	* gimplify.c (gimplify_cond_expr): Call gimple_set_no_warning
	on the cond_stmt from TREE_NO_WARNING on COND_EXPR_COND.
	* gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Don't
	warn on gimple_no_warning_p statements.

	* init.c (build_delete): Set TREE_NO_WARNING on ifexp.

	* g++.dg/warn/Wnonnull-compare-1.C: New test.

From-SVN: r233508
2016-02-17 23:27:24 +01:00
Jakub Jelinek f0516ca404 re PR c++/69658 (Bogus "C99 designator outside aggregate initializer" error)
PR c++/69658
	* init.c (expand_default_init): Only call reshape_init
	in the direct-initialization from an initializer list case.

	* g++.dg/init/pr69658.C: New test.

From-SVN: r233435
2016-02-15 23:05:12 +01:00
Jakub Jelinek 9c58255170 cgraph.c: Spelling fixes - behaviour -> behavior and neighbour -> neighbor.
* cgraph.c: Spelling fixes - behaviour -> behavior and
	neighbour -> neighbor.
	* target.def: Likewise.
	* sel-sched.c: Likewise.
	* config/mips/mips.c: Likewise.
	* config/arc/arc.md: Likewise.
	* config/arm/cortex-a57.md: Likewise.
	* config/arm/arm.c: Likewise.
	* config/arm/neon.md: Likewise.
	* config/arm/arm-c.c: Likewise.
	* config/vms/vms-c.c: Likewise.
	* config/s390/s390.c: Likewise.
	* config/i386/znver1.md: Likewise.
	* config/i386/i386.c: Likewise.
	* config/ia64/hpux-unix2003.h: Likewise.
	* config/msp430/msp430.md: Likewise.
	* config/rx/rx.c: Likewise.
	* config/rx/rx.md: Likewise.
	* config/aarch64/aarch64-simd.md: Likewise.
	* config/aarch64/aarch64.c: Likewise.
	* config/nvptx/nvptx.c: Likewise.
	* config/bfin/bfin.c: Likewise.
	* config/cris/cris.opt: Likewise.
	* config/rs6000/rs6000.c: Likewise.
	* target.h: Likewise.
	* spellcheck.c: Likewise.
	* ira-build.c: Likewise.
	* tree-inline.c: Likewise.
	* builtins.c: Likewise.
	* lra-constraints.c: Likewise.
	* explow.c: Likewise.
	* hwint.h: Likewise.
	* targhooks.c: Likewise.
	* tree-vect-data-refs.c: Likewise.
	* expr.c: Likewise.
	* doc/tm.texi: Likewise.
	* doc/extend.texi: Likewise.
	* doc/install.texi: Likewise.
	* doc/md.texi: Likewise.
	* tree-ssa-tail-merge.c: Likewise.
	* sched-int.h: Likewise.
	* match.pd: Likewise.
	* sched-ebb.c: Likewise.
	* target.def (omit_struct_return_reg): Likewise.
	* gimple-ssa-isolate-paths.c: Likewise.
	(find_implicit_erroneous_behaviour): Renamed to...
	(find_implicit_erroneous_behavior): ... this.
	(find_explicit_erroneous_behaviour): Renamed to...
	(find_explicit_erroneous_behavior): ... this.
	(gimple_ssa_isolate_erroneous_paths): Adjust caller.
gcc/cp/
	* error.c: Spelling fixes - behaviour -> behavior and
	neighbour -> neighbor.
	* decl.c: Likewise.
	* typeck.c (cp_build_binary_op): Fix up behavior spelling in
	diagnostics.
	* init.c (build_delete): Likewise.
gcc/objc/
	* objc-act.c: Spelling fixes - behaviour -> behavior and
	neighbour -> neighbor.
	* objc-map.h: Likewise.
gcc/go/
	* gofrontend/lex.cc: Spelling fixes - behaviour -> behavior and
	neighbour -> neighbor.
	* gccgo.texi: Likewise.
gcc/ada/
	* prj-tree.ads: Spelling fixes - behaviour -> behavior and
	neighbour -> neighbor.
	* prep.adb: Likewise.
	* prj.ads: Likewise.
	* prepcomp.adb: Likewise.
	* g-socket.ads: Likewise.
	* s-imgrea.adb: Likewise.
	* a-calend.adb: Likewise.
	* exp_disp.adb: Likewise.
	* doc/gnat_ugn/gnat_utility_programs.rst: Likewise.
	* g-socket.adb: Likewise.
	* sem_ch12.adb: Likewise.
	* terminals.c: Likewise.
gcc/testsuite/
	* objc.dg/gnu-api-2-method.m: Spelling fixes - behaviour -> behavior
	and neighbour -> neighbor.
	* objc.dg/attributes/method-nonnull-1.m: Likewise.
	* objc.dg/gnu-api-2-class-meta.m: Likewise.
	* c-c++-common/Wvarargs.c: Likewise.
	* c-c++-common/goacc/host_data-5.c: Likewise.
	* obj-c++.dg/gnu-api-2-class-meta.mm: Likewise.
	* obj-c++.dg/attributes/method-nonnull-1.mm: Likewise.
	* obj-c++.dg/gnu-api-2-method.mm: Likewise.
	* gcc.target/aarch64/pr60697.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vldX_lane.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqshl.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vshuffle.inc: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vrshl.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vldX_dup.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vstX_lane.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrshl.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vldX.c: Likewise.
	* gcc.target/aarch64/aapcs64/ice_2.c: Likewise.
	* gcc.target/aarch64/aapcs64/test_23.c: Likewise.
	* gcc.target/aarch64/vrnd_f64_1.c: Likewise.
	* g++.dg/warn/Wconversion-real-integer-3.C: Likewise.
	* g++.dg/lookup/koenig5.C: Likewise.
	* g++.dg/ext/no-asm-2.C: Likewise.
	* gfortran.dg/bounds_check_array_ctor_3.f90: Likewise.
	* gfortran.dg/bounds_check_array_ctor_7.f90: Likewise.
	* gfortran.dg/used_types_16.f90: Likewise.
	* gfortran.dg/assumed_rank_bounds_1.f90: Likewise.
	* gfortran.dg/bounds_check_array_ctor_1.f90: Likewise.
	* gfortran.dg/assumed_rank_bounds_2.f90: Likewise.
	* gfortran.dg/bounds_check_array_ctor_4.f90: Likewise.
	* gfortran.dg/abstract_type_6.f03: Likewise.
	* gfortran.dg/bounds_check_array_ctor_5.f90: Likewise.
	* gfortran.dg/used_types_15.f90: Likewise.
	* gfortran.dg/bounds_check_array_ctor_8.f90: Likewise.
	* gfortran.dg/exit_3.f08: Likewise.
	* gfortran.dg/open_status_2.f90: Likewise.
	* gfortran.dg/derived_pointer_recursion_2.f90: Likewise.
	* gfortran.dg/intrinsic_std_1.f90: Likewise.
	* gfortran.dg/associate_1.f03: Likewise.
	* gfortran.dg/bounds_check_array_ctor_2.f90: Likewise.
	* gfortran.dg/intrinsic_std_6.f90: Likewise.
	* gfortran.dg/bounds_check_array_ctor_6.f90: Likewise.
	* gcc.dg/builtin-object-size-1.c: Likewise.
	* gcc.dg/noreturn-6.c: Likewise.
	* gcc.dg/builtin-stringop-chk-1.c: Likewise.
	* gcc.dg/globalalias.c: Likewise.
	* gcc.dg/builtins-config.h: Likewise.
	* gcc.dg/pr30457.c: Likewise.
	* gcc.c-torture/compile/volatile-1.c: Likewise.
	* gcc.c-torture/execute/20101011-1.c: Likewise.
	* c-c++-common/Waddress-1.c: Likewise.

From-SVN: r233358
2016-02-12 00:53:54 +01:00
Jason Merrill 46f0d909aa re PR c++/68926 (decltype and sfinae to check for template instance availability fails to compile)
PR c++/68926

	* pt.c (resolve_nondeduced_context): Add complain parm.
	(do_auto_deduction): Pass it.
	* cvt.c (convert_to_void): Likewise.
	* decl.c (cp_finish_decl): Likewise.
	* init.c (build_new): Likewise.
	* rtti.c (get_tinfo_decl_dynamic): Likewise.
	* semantics.c (finish_decltype_type): Likewise.
	* typeck.c (decay_conversion): Likewise.
	* cp-tree.h: Adjust declaration.
	* call.c (standard_conversion): Add complain parm, pass it along.
	(implicit_conversion): Pass it.

From-SVN: r233304
2016-02-10 14:12:32 -05:00
Martin Sebor 46cb933227 PR c++/69662 - -Wplacement-new on allocated one element array members
gcc/testsuite/ChangeLog:
	PR c++/69662
	* g++.dg/warn/Wplacement-new-size-1.C: New test.
	* g++.dg/warn/Wplacement-new-size-2.C: New test.

gcc/cp/ChangeLog:
	PR c++/69662
	* init.c (find_field_init): New function.
	(warn_placement_new_too_small): Call it.  Handle one-element arrays
        at ends of structures special.

gcc/c-family/ChangeLog:
	PR c++/69662
	* c.opt (Warning options): Update -Wplacement-new to take
        an optional argument.

gcc/ChangeLog:
	PR c++/69662
	* doc/invoke.texi: Update -Wplacement-new to take an optional
        argument.

From-SVN: r233190
2016-02-05 15:27:37 -07:00
Marek Polacek 5453bfed48 re PR c++/69509 (infinite loop compiling a VLA in a recursive constexpr function)
PR c++/69509
	PR c++/69516
	* constexpr.c (cxx_eval_array_reference): Give the "array subscript
	out of bound" error earlier.
	* init.c (build_vec_init): Change NE_EXPR into GT_EXPR.  Update the
	commentary.

	* g++.dg/ext/constexpr-vla2.C: New test.
	* g++.dg/ext/constexpr-vla3.C: New test.
	* g++.dg/ubsan/vla-1.C: Remove dg-shouldfail.

From-SVN: r232969
2016-01-29 09:25:14 +00:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Jason Merrill 72013ec51a re PR c++/67411 (internal compiler error: in tsubst_copy, at cp/pt.c:13473)
PR c++/67411

	* lambda.c (generic_lambda_fn_p): Split out from...
	(maybe_add_lambda_conv_op): ...here.
	* semantics.c (process_outer_var_ref): Don't defer maybe-constant
	variables in a generic lambda.
	* pt.c (instantiate_non_dependent_or_null): New.
	* init.c (constant_value_1): Use it.
	* cp-tree.h: Declare it and generic_lambda_fn_p.

From-SVN: r231863
2015-12-20 13:38:37 -05:00
Patrick Palka 458cd4c394 Fix PR c++/68831 (superfluous -Waddress warning for C++ delete)
gcc/cp/ChangeLog:

	PR c++/68831
	* init.c (build_delete): Use a warning sentinel to disable
	-Waddress warnings when building the conditional that tests
	if the operand is NULL.

gcc/testsuite/ChangeLog:

	PR c++/68831
	* g++.dg/pr68831.C: New test.

From-SVN: r231798
2015-12-18 02:25:39 +00:00
Jason Merrill 62f9ab0d43 re PR c++/67550 (Initialization of local struct array with elements of global array yields zeros instead of initializer values)
PR c++/67550

	* init.c (constant_value_1): Don't return a CONSTRUCTOR missing
	non-constant elements.

From-SVN: r231777
2015-12-17 11:51:58 -05:00
Martin Sebor 7e9a3ad300 struct-layout-1_generate.c: Avoid generating further fields after the first flexible array member.
gcc/testsuite/ChangeLog:
2015-12-15  Martin Sebor  <msebor@redhat.com>

	c++/42121
	c++/68478
	c++/68613
	c++/68689
	c++/68710
	* g++.dg/compat/struct-layout-1_generate.c: Avoid generating
	further fields after the first flexible array member.
	* g++.dg/ext/flexary2.C: Expect a sole flexible array member
	to be rejected.  Add a test case exercising zero-length array.
	* g++.dg/ext/flexary3.C: Expect a sole flexible array member
	to be rejected.
	* g++.dg/ext/flexary.h: New file.
	* g++.dg/ext/flexary4.C: New file.
	* g++.dg/ext/flexary5.C: New file.
	* g++.dg/ext/flexary6.C: New file.
	* g++.dg/ext/flexary7.C: New file.
	* g++.dg/ext/flexary8.C: New file.
	* g++.dg/other/dump-ada-spec-2.C: Adjust to reflect flexible
	array members.
	* g++.dg/parse/pr43765.C: Add a member to make a struct with
	a flexible array member valid.  Adjust expected error message.
	* g++.dg/torture/pr64280.C: Expect a sole flexible array member
	to be rejected.
	* g++.dg/torture/pr64312.C: Add a member to make a struct with
	a flexible array member valid.
	* g++.dg/ubsan/object-size-1.C: Adjust expected diagnostic.

gcc/cp/ChangeLog:
2015-12-15  Martin Sebor  <msebor@redhat.com>

	c++/42121
	c++/68478
	c++/68613
	c++/68689
	c++/68710
	* class.c (walk_subobject_offsets): Avoid assuming type domain
	is non-null or has an upper bound.
	(layout_class_type): Include type size in error message.
	(flexmems_t): New type.
	(field_nonempty_p, find_flexarrays, diagnose_flexarrays)
	(check_flexarrays): New	functions.
	(finish_struct_1): Call check_flexarrays.
	* decl.c (compute_array_index_type): Distinguish flexible array
	members from zero-length arrays.
	(grokdeclarator): Reject flexible array members in unions.  Avoid
	rejecting members of incomplete types that are flexible array members.
	* error.c (dump_type_suffix): Handle flexible array members with null
	upper bound.
	* init.c (perform_member_init): Same.
	* pt.c (instantiate_class_template_1): Allow flexible array members.
	(tsubst): Handle flexible array members with null upper bound.
	* typeck2.c (digest_init_r): Warn for initialization of flexible
	array members.
	(process_init_constructor_record): Handle flexible array members.

gcc/ChangeLog:
2015-12-15  Martin Sebor  <msebor@redhat.com>

	c++/42121
	* tree-chkp.c (chkp_find_bound_slots_1): Handle flexible array
	members.
	* tree.c (type_contains_placeholder_1): Avoid assuming type has
	a non-null domain or an upper bound to handle flexible array
	members.
	* varasm.c (output_constructor_regular_field):  Same.
	(output_constructor): Set min_index to integer_zero_node rather
	than null when a type has no domain to avoid crashing later.

From-SVN: r231665
2015-12-15 14:04:08 -07:00
Martin Sebor f091ee191c PR c++/68308 - [6 Regression] ICE: tree check: expected integer_cst,
have var_decl in decompose, at tree.h:5105

gcc/
    * cp/init.c (build_new_1): Check for expression constness
    the right way.

testsuite/
    * g++.dg/init/new46.C: New test.

From-SVN: r230468
2015-11-17 11:09:36 -07:00
Jason Merrill cda0a029f4 Merge C++ delayed folding branch.
* call.c (build_conditional_expr_1, convert_like_real)
	(convert_arg_to_ellipsis, convert_for_arg_passing): Don't fold.
	(build_new_op_1, build_over_call, build_cxx_call): Fold for warnings.
	* class.c (build_base_path, determine_primary_bases)
	(update_vtable_entry_for_fn, check_bitfield_decl)
	(layout_nonempty_base_or_field, layout_empty_base)
	(propagate_binfo_offsets, include_empty_classes)
	(layout_class_type, build_vbase_offset_vtbl_entries): Use
	fold_convert.
	* constexpr.c (cxx_eval_builtin_function_call): Fold away the NOP_EXPR.
	(cxx_eval_call_expression): Handle MEM_REF.
	(cxx_eval_pointer_plus_expression): Fold the second operand.
	(cxx_eval_constant_expression): Handle MEM_REF, UNARY_PLUS_EXPR.
	(fold_simple_1, fold_simple): New.
	(maybe_constant_value_1): Factor out from maybe_constant_value.
	(cv_cache, maybe_constant_value): Cache results.
	(maybe_constant_init): Handle null input.
	(potential_constant_expression_1): Handle RESULT_DECL, EMPTY_CLASS_EXPR.
	* cp-array-notation.c (build_array_notation_ref): Fold operands.
	* cp-gimplify.c (cp_fold_r, cp_fold): New.
	(cp_genericize_r): Use fold_convert.  Don't fold SIZEOF_EXPR.
	(cp_genericize): Fold everything.
	(contains_label_1, contains_label_p): New.
	(cp_fold, cp_fully_fold): New.
	* cp-tree.h (class cache_map): New.
	* cvt.c (cp_convert_to_pointer, ocp_convert): Use convert_to_*_nofold.
	(cp_convert_and_check): Use cp_fully_fold.
	(convert, convert_force): Don't fold.
	* decl.c (fold_sizeof_expr): Change from fold_sizeof_expr_r.
	(compute_array_index_type): Use cp_fully_fold.
	(build_enumerator): Use fold_convert.
	* decl2.c (get_guard_cond, set_guard): Use fold_convert.
	* init.c (build_zero_init_1): Fold zero-initializers.
	(build_new_1): Fold nelts calculations.
	(build_vec_delete_1): Fold conversions.
	(build_vec_init): Fold maxindex.
	* parser.c (cp_parser_binary_expression): Fold LHS of || and &&.
	(cp_parser_question_colon_clause): Fold LHS.
	* pt.c (convert_nontype_argument): Fold nullptr conversion.
	* semantics.c (finish_unary_op_expr): Fold for warnings.
	(handle_omp_array_sections_1): Fold length and low bound.
	(handle_omp_for_class_iterator): Fold various things.
	* tree.c (builtin_valid_in_constant_expr_p): Add
	BUILT_IN_ATOMIC_ALWAYS_LOCK_FREE.
	(convert_bitfield_to_declared_type): Don't fold.
	(handle_init_priority_attribute): Fold.
	(fold_if_not_in_template): Remove.
	* typeck.c (decay_conversion, build_class_member_access_expr)
	(build_simple_component_ref, cp_build_array_ref, build_vec_cmp)
	(cp_pointer_int_sum, pointer_diff): Don't fold.
	(cp_build_binary_op): Fold for warnings and PMF ops.
	(cp_build_unary_op): Fold negation of a constant, nothing else.
	(expand_ptrmemfunc_cst): Fold operations.
	* typeck2.c (split_nonconstant_init): Fold initializer.
	(store_init_value): Likewise.
	(check_narrowing): Try folding.
	* config-lang.in (gtfiles): Add cp-gimplify.c.

From-SVN: r230365
2015-11-13 19:08:05 -05:00