Commit Graph

10874 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
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