Commit Graph

2646 Commits

Author SHA1 Message Date
Alexandre Oliva e072b0c410 [libcp1] handle anon aggregates linkage-named by typedefs
Arrange for the first typedef to an anonymous type in the same context
to be used as the linkage name for the type.

for  gcc/cp/ChangeLog

	* decl.c (name_unnamed_type): Split out of...
	(grokdeclarator): ... this.
	* decl.h (name_unnamed_type): Declare.

for  libcc1/ChangeLog

	* libcp1plugin.cc (plugin_build_decl): Call name_unnamed_type.

From-SVN: r246938
2017-04-15 03:28:31 +00:00
Jakub Jelinek 347e1f7769 re PR c++/80370 (ICE when using structured bindings and nested generic lambdas (tsubst_decomp_names))
PR c++/80370
	* decl.c (cp_finish_decomp): If processing_template_decl on
	non-dependent decl, only set TREE_TYPE on the v[i] decls, but don't
	change their DECL_VALUE_EXPR nor cp_finish_decl them.  Instead make
	sure DECL_VALUE_EXPR is the canonical NULL type ARRAY_REF for tsubst
	processing.
	* pt.c (value_dependent_expression_p) <case VAR_DECL>: For variables
	with DECL_VALUE_EXPR, return true if DECL_VALUE_EXPR is type
	dependent.

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

From-SVN: r246857
2017-04-11 22:51:16 +02:00
Jason Merrill 18f73c5f24 PR c++/79519 - ICE with deleted template friend.
* decl.c (grokdeclarator): Complain about misplaced function
	definition using =, as well.

From-SVN: r246291
2017-03-20 16:36:46 -04:00
Jason Merrill a4dfaae105 PR c++/80084 - wrong C++17 decomposition by reference of parameter.
* decl.c (cp_finish_decomp): Don't pull out the DECL_INITIAL of a
	reference decomposition.

From-SVN: r246273
2017-03-19 22:22:43 -04:00
Jason Merrill c7ec585d78 PR c++/80073 - C++17 ICE with virtual base.
* decl.c (xref_basetypes): Also check for indirect vbases.

From-SVN: r246242
2017-03-17 14:42:09 -04:00
Jason Merrill 2e92d7ada9 * decl.c (start_enum): std::byte aliases anything.
From-SVN: r246212
2017-03-16 17:16:45 -04:00
David Malcolm 2f6f187a86 Simplify uses of "%<%s%>" to "%qs" (PR translation/79848)
gcc/c-family/ChangeLog:
	PR translation/79848
	* c-format.c (check_format_string): Simplify uses of "%<%s%>" to
	"%qs".

gcc/c/ChangeLog:
	PR translation/79848
	* c-decl.c (declspecs_add_type): Simplify uses of "%<%s%>" to
	"%qs".
	* c-parser.c (c_parser_oacc_shape_clause): Likewise.

gcc/cp/ChangeLog:
	PR translation/79848
	* decl.c (grokfndecl): Simplify uses of "%<%s%>" to "%qs".

gcc/ChangeLog:
	PR translation/79848
	* ipa-devirt.c (warn_types_mismatch): Simplify uses of "%<%s%>" to
	"%qs".
	* ipa-pure-const.c (suggest_attribute): Likewise.  Convert _
	to G_ to avoid double translation.

From-SVN: r246068
2017-03-11 01:57:11 +00:00
Marek Polacek 455d833cd8 re PR c++/79967 (ICE on non-type template argument declared noreturn)
PR c++/79967
	* decl.c (grokdeclarator): Check ATTRLIST before dereferencing it.

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

From-SVN: r246039
2017-03-10 15:36:00 +00:00
Jakub Jelinek cdd669f9fc re PR c++/79896 (ICE in gimplify_expr, at gimplify.c:11950 on non-int128 target)
PR c++/79896
	* decl.c (finish_enum_value_list): If value is error_mark_node,
	don't copy it and change its type.
	* init.c (constant_value_1): Return error_mark_node if DECL_INITIAL
	of CONST_DECL is error_mark_node.

	* g++.dg/ext/int128-5.C: New test.

From-SVN: r246034
2017-03-10 16:28:26 +01:00
Jason Merrill 853ef4e563 Class template argument deduction refinements
* call.c (joust): Move deduction guide tiebreaker down.
	* decl.c (start_decl_1, cp_finish_decl, grokdeclarator): Allow class
	deduction with no initializer.
	* pt.c (build_deduction_guide): Handle implicit default/copy ctor.
	(do_class_deduction): Use that rather than special case.
	(do_auto_deduction): Handle null initializer.

From-SVN: r245796
2017-02-28 18:57:09 -05:00
Jakub Jelinek 324ff1a07f i386.c: Include intl.h.
* config/i386/i386.c: Include intl.h.
	(ix86_option_override_internal): Use cond ? G_("...") : G_("...")
	instead of just cond ? "..." : "...".
	* config/nvptx/nvptx.c (nvptx_goacc_validate_dims): Likewise.
	* coverage.c (read_counts_file): Likewise.
	* omp-offload.c: Include intl.h.
	(oacc_loop_fixed_partitions): Use cond ? G_("...") : G_("...") instead
	of just cond ? "..." : "...".
	* gcov.c (read_count_file): Use cond ? N_("...") : N_("...") instead
	of just cond ? "..." : "...".
c/
	* c-parser.c (c_parser_asm_statement): Use cond ? G_("...") : G_("...")
	instead of just cond ? "..." : "...".
	(c_parser_oacc_enter_exit_data): Use %s and ternary operator only
	for "enter"/"exit" keyword.
	(c_finish_oacc_routine): Don't use %s to supply portions of the
	message.
cp/
	* decl.c (find_decomp_class_base): Use cond ? G_("...") : G_("...")
	instead of just cond ? "..." : "...".
	(grokdeclarator): Likewise.
	(build_enumerator): Likewise.
	* init.c (build_new_1): Likewise.
	* call.c (build_new_method_call_1): Likewise.
	* parser.c: Include intl.h.
	(cp_parser_oacc_enter_exit_data): Use %s and ternary operator only for
	"enter"/"exit" keyword.
	(cp_finalize_oacc_routine): Don't use %s to supply portions of the
	message.
fortran/
	* parse.c (parse_critical_block): Use cond ? G_("...") : G_("...")
	instead of just cond ? "..." : "...".
	* scanner.c (gfc_next_char_literal): Likewise.
	* match.c (match_exit_cycle): Likewise.

From-SVN: r245778
2017-02-28 16:25:19 +01:00
Marek Polacek d66d45909d * decl.c (expand_static_init): Add missing } in a comment.
From-SVN: r245758
2017-02-27 13:39:36 +00:00
Marek Polacek 5713d44853 re PR translation/79705 (cp/decl.c message not marked for translation)
PR translation/79705
	* decl.c (check_redeclaration_exception_specification): Mark a string
	for translation.  Make the pointer const.

From-SVN: r245717
2017-02-24 18:54:13 +00:00
Jakub Jelinek b7280ac270 re PR c++/79654 (ICE on invalid c++ code in register_dtor_fn in cp/decl.c:7877)
PR c++/79654
	* decl.c (cp_finish_decomp): Don't set decl's type to error_mark_node
	on error.
	* pt.c (tsubst_decomp_names): Return error_mark_node if the first
	decl after the decomposition artificial decl has error_mark_node.
	* decl2.c (prune_vars_needing_no_initialization): Use error_operand_p
	instead of just == error_mark_node comparison.

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

Co-Authored-By: Paolo Carlini <paolo.carlini@oracle.com>

From-SVN: r245639
2017-02-21 19:00:35 +01:00
Jakub Jelinek 5c3f1d7b10 re PR sanitizer/79589 (ICE in gimplify_compound_expr (gimplify.c:5712) with -fsanitize=undefined)
PR sanitizer/79589
	* decl.c: Include gimplify.h.
	(cp_finish_decomp): Make sure there is no sharing of trees
	in between DECL_VALUE_EXPR of decomposition decls.

	* g++.dg/ubsan/pr79589.C: New test.

From-SVN: r245638
2017-02-21 18:59:07 +01:00
Jason Merrill 736a933c00 PR c++/79607 - ICE with T{} initializer
* decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR.

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

From-SVN: r245510
2017-02-16 11:42:00 -05:00
Jakub Jelinek 4f5e5fcba8 re PR c++/79288 (TLS model wrong for static data members since r241137)
PR c++/79288
	* decl.c (grokdeclarator): For static data members, handle thread_p
	only after handling inline.

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

From-SVN: r245488
2017-02-15 18:09:18 +01:00
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 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 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
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
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
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
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
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 cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +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 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
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 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 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
Bernd Edlinger 48330c9355 re PR c++/71973 (c++ handles built-in functions inconsistently)
gcc:
2016-11-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	* lto.c (offload_handle_link_vars): Use SET_DECL_MODE.

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

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

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

	* plugin.cc (plugin_build_add_field): Use SET_DECL_MODE.

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

From-SVN: r242585
2016-11-18 10:03:12 +00:00
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 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 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 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
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 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
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