Commit Graph

30 Commits

Author SHA1 Message Date
Paolo Carlini 04e4997a56 decl2.c (delete_sanity): Add location_t parameter and use it throughout.
/gcc/cp
2019-12-30  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl2.c (delete_sanity): Add location_t parameter and use
	it throughout.
	* init.c (build_vec_delete_1): Likewise.
	(build_delete): Likewise.
	(build_vec_delete): Likewise.
	(perform_target_ctor): Adjust call.
	(perform_member_init): Likewise.
	(build_vec_init): Likewise.
	* decl.c (cxx_maybe_build_cleanup): Likewise.
	* pt.c (tsubst_copy_and_build): Likewise.
	* parser.c (cp_parser_delete_expression): Likewise, pass the
	combined_loc.
	* cp-tree.h: Update declarations.

/libcc1
2019-12-30  Paolo Carlini  <paolo.carlini@oracle.com>

	* libcp1plugin.cc (plugin_build_unary_expr): Update delete_sanity
	call.

/gcc/testsuite
2019-12-30  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/init/delete1.C: Check locations too.
	* g++.dg/ipa/pr85607.C: Likewise.
	* g++.dg/warn/Wdelete-incomplete-1.C: Likewise.
	* g++.dg/warn/delete-non-virtual-dtor.C: Likewise.
	* g++.dg/warn/incomplete1.C: Likewise.

From-SVN: r279768
2019-12-30 13:23:40 +00:00
Paolo Carlini d3769410c6 typeck.c (cxx_sizeof_or_alignof_type): Add location_t parameter and use it throughout.
/gcc/cp
2019-12-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* typeck.c (cxx_sizeof_or_alignof_type): Add location_t parameter
	and use it throughout.
	(cxx_sizeof_expr): Likewise.
	(cxx_alignof_expr): Likewise.
	(cxx_sizeof_or_alignof_expr): Likewise.
	(cxx_alignas_expr): Update call.
	* decl.c (fold_sizeof_expr): Likewise.
	* pt.c (tsubst_copy): Likewise.
	(tsubst_copy_and_build): Likewise.
	* except.c (build_throw): Add location_t parameter and use it.
	(expand_end_catch_block): Update call.
	* parser.c (cp_parser_unary_expression): Update
	cxx_sizeof_or_alignof_type and cxx_sizeof_or_alignof_expr calls,
	pass the compound location.
	(cp_parser_throw_expression): Likewise pass the combined location
	to build_throw.
	* cp-tree.h: Update declarations.

	* semantics.c (finish_handler_parms): Use DECL_SOURCE_LOCATION.
	* decl2.c (check_classfn): Likewise.

	* except.c (is_admissible_throw_operand_or_catch_parameter):
	Exploit cp_expr_loc_or_input_loc in one place.

	* except.c (create_try_catch_expr): Remove, unused.

/libcc1
2019-12-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* libcp1plugin.cc (plugin_build_unary_expr): Update build_throw
	and cxx_sizeof_or_alignof_expr calls.
	(plugin_build_unary_type_expr): Likewise for
	cxx_sizeof_or_alignof_type.

/gcc/testsuite
2019-12-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/diagnostic/alignof2.C: New.
	* g++.dg/diagnostic/alignof3.C: Likewise.
	* g++.dg/diagnostic/incomplete-type-1.C: Likewise.
	* g++.dg/warn/Wcatch-value-3b.C: Likewise.
	* g++.dg/cpp0x/alignof3.C: Check location(s) too.
	* g++.dg/cpp1z/decomp-bitfield1.C: Likewise.
	* g++.dg/cpp1z/has-unique-obj-representations2.C: Likewise.
	* g++.dg/expr/sizeof3.C: Likewise.
	* g++.dg/ext/flexary6.C: Likewise.
	* g++.dg/ext/vla4.C: Likewise.
	* g++.dg/template/sizeof11.C: Likewise.
	* g++.dg/warn/Wcatch-value-1.C: Likewise.
	* g++.dg/warn/Wcatch-value-2.C: Likewise.
	* g++.dg/warn/Wcatch-value-3.C: Likewise.
	* g++.old-deja/g++.brendan/sizeof1.C: Likewise.
	* g++.old-deja/g++.brendan/sizeof3.C: Likewise.
	* g++.old-deja/g++.brendan/sizeof4.C: Likewise.
	* g++.old-deja/g++.eh/ctor1.C: Likewise.
	* g++.old-deja/g++.jason/ambig1.C: Likewise.
	* g++.old-deja/g++.other/sizeof4.C: Likewise.

From-SVN: r279543
2019-12-18 19:23:01 +00:00
Paolo Carlini ca6932ad0c typeck.c (check_for_casting_away_constness): Add location_t parameter and use it.
gcc/cp
2019-12-09  Paolo Carlini  <paolo.carlini@oracle.com>

	* typeck.c (check_for_casting_away_constness): Add location_t
	parameter and use it.
	(maybe_warn_about_useless_cast): Likewise.
	(maybe_warn_about_cast_ignoring_quals): Likewise.
	(build_static_cast_1): Likewise.
	(build_static_cast): Likewise; sets the location of the returned tree.
	(build_reinterpret_cast_1): Likewise.
	(build_reinterpret_cast): Likewise; sets the location of the returned
	tree.
	(build_const_cast_1): Likewise.
	(build_const_cast): Likewise; sets the location of the returned tree.
	(cp_build_c_cast): Likewise.
	(build_c_cast): Adjust.
	(build_ptrmemfunc): Adjust calls.
	(cp_build_unary_op): Pass the location to invert_truthvalue_loc.
	* rtti.c (build_dynamic_cast_1): Add location_t parameter and
	use it.
	(build_dynamic_cast): Likewise.
	* cp-tree.h: Adjust declarations.
	* parser.c (cp_parser_postfix_expression): Pass cp_cast_loc to
	the various build_*_cast functions.
	(get_cast_suggestion): Adjust calls.
	(cp_parser_builtin_offsetof): Likewise.
	* decl.c (reshape_init): Adjust call.
	* method.c (forward_parm): Likewise.
	(build_comparison_op): Likewise.
	* pt.c (tsubst_copy_and_build): Likewise.
	* semantics.c (finish_omp_reduction_clause): Likewise.
	(cp_omp_finish_iterators): Likewise.
	* tree.c (cp_stabilize_reference): Likewise.
	(move): Likewise.
	* typeck2.c (build_functional_cast): Likewise.

	* typeck2.c (build_functional_cast_1): New.
	(build_functional_cast_1): Calls the latter and sets the location
	of the returned tree.

/libcc1
2019-12-09  Paolo Carlini  <paolo.carlini@oracle.com>

	* libcp1plugin.cc (plugin_build_cast_expr): Adjust build_cast
	declaration.

gcc/testsuite
2019-12-09  Paolo Carlini  <paolo.carlini@oracle.com>

	* c-c++-common/Wcast-align.c: Check location(s) too.
	* c-c++-common/Wcast-function-type.c: Likewise.
	* c-c++-common/Wint-to-pointer-cast-1.c: Likewise.
	* c-c++-common/Wint-to-pointer-cast-2.c: Likewise.
	* c-c++-common/Wint-to-pointer-cast-3.c: Likewise.
	* g++.dg/Wcast-function-type.C: Likewise.
	* g++.dg/addr_builtin-1.C: Likewise.
	* g++.dg/conversion/const2.C: Likewise.
	* g++.dg/conversion/dynamic1.C: Likewise.
	* g++.dg/conversion/ptrmem2.C: Likewise.
	* g++.dg/conversion/ptrmem3.C: Likewise.
	* g++.dg/conversion/qual3.C: Likewise.
	* g++.dg/conversion/reinterpret3.C: Likewise.
	* g++.dg/cpp0x/constexpr-cast.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-conv11.C: Likewise.
	* g++.dg/cpp0x/nullptr04.C: Likewise.
	* g++.dg/cpp0x/reinterpret_cast2.C: Likewise.
	* g++.dg/cpp0x/rv-cast2.C: Likewise.
	* g++.dg/cpp1y/lambda-conv1.C: Likewise.
	* g++.dg/cpp1z/noexcept-type7.C: Likewise.
	* g++.dg/cpp2a/array-conv9.C: Likewise.
	* g++.dg/expr/cast11.C: Likewise.
	* g++.dg/expr/static_cast8.C: Likewise.
	* g++.dg/ext/vector6.C: Likewise.
	* g++.dg/other/conversion1.C: Likewise.
	* g++.dg/parse/pr26997.C: Likewise.
	* g++.dg/rtti/no-rtti.C: Likewise.
	* g++.dg/tc1/dr137.C: Likewise.
	* g++.dg/template/cast4.C: Likewise.
	* g++.dg/warn/Wcast-qual1.C: Likewise.
	* g++.dg/warn/Wcast-qual2.C: Likewise.
	* g++.dg/warn/Wconditionally-supported-1.C: Likewise.
	* g++.dg/warn/Wuseless-cast.C: Likewise.
	* g++.dg/warn/pr35711.C: Likewise.
	* g++.old-deja/g++.bugs/900227_01.C: Likewise.
	* g++.old-deja/g++.bugs/900404_07.C: Likewise.
	* g++.old-deja/g++.jason/overload1.C: Likewise.
	* g++.old-deja/g++.jason/rfg26.C: Likewise.
	* g++.old-deja/g++.jason/rvalue3.C: Likewise.
	* g++.old-deja/g++.jason/warning2.C: Likewise.
	* g++.old-deja/g++.mike/dyncast4.C: Likewise.
	* g++.old-deja/g++.mike/dyncast6.C: Likewise.
	* g++.old-deja/g++.mike/p11482.C: Likewise.
	* g++.old-deja/g++.mike/p2573.C: Likewise.
	* g++.old-deja/g++.mike/p2855.C: Likewise.
	* g++.old-deja/g++.mike/p7476.C: Likewise.
	* g++.old-deja/g++.mike/p8039.C: Likewise.
	* g++.old-deja/g++.other/cast2.C: Likewise.
	* g++.old-deja/g++.other/cast3.C: Likewise.
	* g++.old-deja/g++.other/dcast1.C: Likewise.
	* g++.old-deja/g++.other/dcast2.C: Likewise.

From-SVN: r279138
2019-12-09 20:28:39 +00:00
Paolo Carlini ad774d0d63 typeck2.c (build_functional_cast): Add location_t parameter and use it.
/gcc/cp
2019-12-05  Paolo Carlini  <paolo.carlini@oracle.com>

	* typeck2.c (build_functional_cast): Add location_t parameter
	and use it.
	* cp-tree.h: Update declaration.
	* parser.c (cp_parser_functional_cast): Adjust call.
	* call.c (build_op_delete_call): Likewise.
	(build_new_method_call_1): Likewise.
	* decl.c (check_initializer): Likewise.
	* pt.c (tsubst_copy_and_build): Likewise.
	* semantics.c (finish_compound_literal): Likewise.

/libcc1
2019-12-05  Paolo Carlini  <paolo.carlini@oracle.com>

	* libcp1plugin.cc (plugin_build_expression_list_expr): Adjust
	build_functional_cast call.

/testsuite
2019-12-05  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/diagnostic/functional-cast-to-array-type-1.C: New.
	* g++.dg/cpp0x/auto25.C: Check location(s) too.
	* g++.dg/cpp0x/auto28.C: Likewise.
	* g++.dg/init/reference2.C: Likewise.
	* g++.dg/parse/template2.C: Likewise.
	* g++.dg/template/error8.C: Likewise.
	* g++.old-deja/g++.ns/crash3.C: Likewise.
	* g++.old-deja/g++.ns/template7.C: Likewise.
	* g++.old-deja/g++.pt/crash8.C: Likewise.

From-SVN: r278987
2019-12-05 08:59:24 +00:00
Paolo Carlini 3554d8ffc5 typeck.c (cp_build_indirect_ref_1): Add location_t parameter and use it in error messages.
/gcc
2019-11-25  Paolo Carlini  <paolo.carlini@oracle.com>

	* typeck.c (cp_build_indirect_ref_1): Add location_t parameter
	and use it in error messages.
	(build_x_indirect_ref): Adjust call.
	(build_indirect_ref): Likewise.
	(cp_build_fold_indirect_ref): Likewise.
	(cp_build_array_ref): Likewise.
	* call.c (build_new_op_1): Likewise.
	* semantics.c (finish_omp_clauses): Likewise.
	(finish_omp_depobj): Likewise.
	* typeck2.c (build_x_arrow): Likewise.
	* cp-tree.h (cp_build_indirect_ref): Update declaration.

	* call.c (build_new_op_1): Use location argument in warning_at.

	* typeck.c (cp_build_modify_expr): Consistently use the
	location_t argument.

/libcc1
2019-11-25  Paolo Carlini  <paolo.carlini@oracle.com>

	* libcp1plugin.cc (plugin_pragma_push_user_expression): Update
	cp_build_indirect_ref call.

/gcc/testsuite
2019-11-25  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/diagnostic/base-operand-non-pointer-1.C: New.
	* g++.dg/pr53055.C: Check location too.
	* g++.old-deja/g++.bugs/900213_02.C: Likewise.
	* g++.old-deja/g++.bugs/900215_02.C: Likewise.
	* g++.old-deja/g++.other/badarrow.C: Likewise.
	* g++.old-deja/g++.other/deref1.C: Likewise.

	* g++.dg/warn/Wenum-compare.C: Check location too.

	* g++.dg/cpp0x/initlist26.C: Check location too.
	* g++.dg/cpp0x/initlist28.C: Likewise.
	* g++.dg/cpp0x/initlist29.C: Likewise.
	* g++.dg/cpp0x/initlist33.C: Likewise.
	* g++.dg/expr/string-2.C: Likewise.
	* g++.dg/other/ptrmem5.C: Likewise.
	* g++.old-deja/g++.benjamin/14664-1.C: Likewise.
	* g++.old-deja/g++.benjamin/14664-2.C: Likewise.
	* g++.old-deja/g++.brendan/init12.C: Likewise.
	* g++.old-deja/g++.bugs/900324_04.C: Likewise.
	* g++.old-deja/g++.ext/array1.C: Likewise.
	* g++.old-deja/g++.jason/rfg17.C: Likewise.

From-SVN: r278685
2019-11-25 13:49:50 +00:00
Nathan Sidwell 692af872fa [C++ PATCH] Using decls
https://gcc.gnu.org/ml/gcc-patches/2019-05/msg01396.html
	gcc/cp/
	* name-lookup.h (struct cp_binding_level): Drop usings field.
	(finish_namespace_using_decl, finish_local_using_decl): Replace with ...
	(finish_nonmember_using_decl): ... this.
	* name-lookup.c (push_using_decl_1, push_using_decl):
	(do_nonmember_using_decl): ... here.  Add INSERT_P arg.  Reimplement.
	(validate_nonmember_using_decl, finish_namespace_using_decl)
	(finish_local_using_decl): Replace with ...
	(finish_nonmember_using_decl): ... this.  Drop DECL parm.
	* parser.c (cp_parser_using_declaration): Don't do lookup here.
	* pt.c (tsubst_expr): Do not do using decl lookup here.

	gcc/testsuite/
	* g++.dg/lookup/using53.C: Adjust diagnostic.

	libcc1/
	* libcp1plugin.cc (plugin_add_using_decl): Use
	finish_nonmember_using_decl.

From-SVN: r271467
2019-05-21 14:33:24 +00:00
Nathan Sidwell 6db76e48c1 [C++ PATCH] Commonixe using directive finishing
https://gcc.gnu.org/ml/gcc-patches/2019-05/msg01251.html
	gcc/cp/
	* name-lookup.c (finish_namespace_using_directive)
	(finish_local_using_directive): Merge to ...
	(finish_using_directive): ... here.  Handle both contexts.
	* name-lookup.h (finish_namespace_using_directive)
	(finish_local_using_directive): Replace with ...
	(finish_using_directive): ... this.
	* parser.c (cp_parser_using_directive): Adjust.
	* pt.c (tsubst_expr): Likewise.

	libcc1/
	* libcp1plugin.cc (plugin_add_using_namespace): Call renamed
	finish_using_directive.

From-SVN: r271420
2019-05-20 13:49:53 +00:00
Jakub Jelinek a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00
David Malcolm 620e594be5 Eliminate source_location in favor of location_t
Historically GCC used location_t, while libcpp used source_location.

This inconsistency has been annoying me for a while, so this patch
removes source_location in favor of location_t throughout
(as the latter is shorter).

gcc/ChangeLog:
	* builtins.c: Replace "source_location" with "location_t".
	* diagnostic-show-locus.c: Likewise.
	* diagnostic.c: Likewise.
	* dumpfile.c: Likewise.
	* gcc-rich-location.h: Likewise.
	* genmatch.c: Likewise.
	* gimple.h: Likewise.
	* gimplify.c: Likewise.
	* input.c: Likewise.
	* input.h: Likewise.  Eliminate the typedef.
	* omp-expand.c: Likewise.
	* selftest.h: Likewise.
	* substring-locations.h (get_source_location_for_substring):
	Rename to..
	(get_location_within_string): ...this.
	* tree-cfg.c: Replace "source_location" with "location_t".
	* tree-cfgcleanup.c: Likewise.
	* tree-diagnostic.c: Likewise.
	* tree-into-ssa.c: Likewise.
	* tree-outof-ssa.c: Likewise.
	* tree-parloops.c: Likewise.
	* tree-phinodes.c: Likewise.
	* tree-phinodes.h: Likewise.
	* tree-ssa-loop-ivopts.c: Likewise.
	* tree-ssa-loop-manip.c: Likewise.
	* tree-ssa-phiopt.c: Likewise.
	* tree-ssa-phiprop.c: Likewise.
	* tree-ssa-threadupdate.c: Likewise.
	* tree-ssa.c: Likewise.
	* tree-ssa.h: Likewise.
	* tree-vect-loop-manip.c: Likewise.

gcc/c-family/ChangeLog:
	* c-common.c (c_get_substring_location): Update for renaming of
	get_source_location_for_substring to get_location_within_string.
	* c-lex.c: Replace "source_location" with "location_t".
	* c-opts.c: Likewise.
	* c-ppoutput.c: Likewise.

gcc/c/ChangeLog:
	* c-decl.c: Replace "source_location" with "location_t".
	* c-tree.h: Likewise.
	* c-typeck.c: Likewise.
	* gimple-parser.c: Likewise.

gcc/cp/ChangeLog:
	* call.c: Replace "source_location" with "location_t".
	* cp-tree.h: Likewise.
	* cvt.c: Likewise.
	* name-lookup.c: Likewise.
	* parser.c: Likewise.
	* typeck.c: Likewise.

gcc/fortran/ChangeLog:
	* cpp.c: Replace "source_location" with "location_t".
	* gfortran.h: Likewise.

gcc/go/ChangeLog:
	* go-gcc-diagnostics.cc: Replace "source_location" with "location_t".
	* go-gcc.cc: Likewise.
	* go-linemap.cc: Likewise.
	* go-location.h: Likewise.
	* gofrontend/README: Likewise.

gcc/jit/ChangeLog:
	* jit-playback.c: Replace "source_location" with "location_t".

gcc/testsuite/ChangeLog:
	* g++.dg/plugin/comment_plugin.c: Replace "source_location" with
	"location_t".
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Likewise.

libcc1/ChangeLog:
	* libcc1plugin.cc: Replace "source_location" with "location_t".
	(plugin_context::get_source_location): Rename to...
	(plugin_context::get_location_t): ...this.
	* libcp1plugin.cc: Likewise.

libcpp/ChangeLog:
	* charset.c: Replace "source_location" with "location_t".
	* directives-only.c: Likewise.
	* directives.c: Likewise.
	* errors.c: Likewise.
	* expr.c: Likewise.
	* files.c: Likewise.
	* include/cpplib.h: Likewise.  Rename MAX_SOURCE_LOCATION to
	MAX_LOCATION_T.
	* include/line-map.h: Likewise.
	* init.c: Likewise.
	* internal.h: Likewise.
	* lex.c: Likewise.
	* line-map.c: Likewise.
	* location-example.txt: Likewise.
	* macro.c: Likewise.
	* pch.c: Likewise.
	* traditional.c: Likewise.

From-SVN: r266085
2018-11-13 20:05:03 +00:00
Jason Merrill aa2b105511 PR c++/69560 - wrong alignof(double) on x86.
CWG 1879 - Inadequate definition of alignment requirement.
	* cp-tree.h (ALIGNOF_EXPR_STD_P): New.
	* typeck.c (cxx_sizeof_or_alignof_type): Add std_alignof parm.
	(cxx_sizeof_expr, cxx_sizeof_nowarn, cxx_alignas_expr)
	(cxx_alignof_expr): Pass it.
	* parser.c (cp_parser_unary_expression): Pass it.
	* pt.c (tsubst_copy): Copy it.
	(tsubst_copy_and_build): Pass it.
	* decl.c (fold_sizeof_expr): Pass it.

From-SVN: r259578
2018-04-23 16:49:38 -04:00
Jakub Jelinek 85ec4feb11 Update copyright years.
From-SVN: r256169
2018-01-03 11:03:58 +01:00
Nathan Sidwell ce12115844 [C++ PATCH] overloaded operator fns [6/N]
https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00019.html
	gcc/cp/
	* cp-tree.h (assign_op_identifier, call_op_identifier): Use
	compressed code.
	(struct lang_decl_fn): Use compressed operator code.
	(DECL_OVERLOADED_OPERATOR_CODE): Replace with ...
	(DECL_OVERLOADED_OPERATOR_CODE_RAW): ... this.
	(DECL_OVERLOADED_OPERATOR_CODE_IS): Use it.
	* decl.c (duplicate_decls): Use DECL_OVERLOADED_OPERATOR_CODE_RAW.
	(build_library_fn): Likewise.
	(grok_op_properties): Likewise.
	* mangle.c (write_unqualified_name): Likewise.
	* method.c (implicitly_declare_fn): Likewise.
	* typeck.c (check_return_expr): Use DECL_OVERLOADED_OPERATOR_IS.

	libcc1/
	* libcp1plugin.cc (plugin_build_decl): Use
	DECL_OVERLOADED_OPERATOR_CODE_RAW.

From-SVN: r254314
2017-11-01 15:46:42 +00:00
Nathan Sidwell 88a819bee1 [C++ PATCH] overloaded operator fns [2/N]
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg02326.html
	gcc/cp/
	* cp-tree.h (ovl_op_identifier): New.
	(assign_op_identifier, call_op_identifier): Adjust.
	(cp_operator_id, cp_assignment_operator_ide): Delete.
	(SET_OVERLOADED_OPERATOR_CODE): Delete.
	(OVL_OP_INFO): New.
	* call.c (op_error): Use OVL_OP_INFO.
	(build_conditional_expr_1): Use ovl_op_identifier.
	(build_new_op_1): Use OVL_OP_INFO & ovl_op_identifier.
	(build_op_delete_call): Likewise.
	* class.c (type_requires_array_cookie): Use ovl_op_identifier.
	* decl.c (duplicate_decls): Directly copy operator code.
	(builtin_function_1): Do not set operator code.
	(build_library_fn): Directly set operator code.
	(push_cp_library_fn): Use ovl_op_identifier.
	(grok_op_properties): Directly set operator code.
	* decl2.c (maybe_warn_sized_delete): Use ovl_op_identifier.
	* error.c (dump_expr): Use OVL_OP_INFO.
	(op_to_string): Add assop arg. Use OVL_OP_INFO.
	(assop_to_string): Delete.
	(args_to_string): Adjust.
	* init.c (build_new_1): Use ovl_op_identifier.
	* mangle.c (write_unqualified_name): Use OVL_OP_INFO.
	(write_expression): Likewise.
	* method.c (synthesized_method_walk): Use ovl_op_identifier.
	(implicitly_declare_fn): Use assign_op_identifier. Directly set
	operator code.
	* name-lookup.c (get_class_binding): Use assign_op_identifier.
	* parser.c (cp_parser_operator): Use ovl_op_identifier.
	(cp_parser_omp_clause_reduction): Likewise.
	* semantics.c (omp_reduction_id): Likewise.
	* typeck.c (cxx_sizeof_or_alignof_type): Use OVL_OP_INFO.

	libcc1/
	* libcp1plugin.cc (plugin_build_decl): Use ovl_op_identifier.
	Directly set operator code.
	(plugin_build_dependent_expr): Use ovl_op_identifier.

From-SVN: r254267
2017-10-31 14:39:44 +00:00
Nathan Sidwell b419102c12 [C++ PATCH] Move mangling alias out of ::
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00199.html
	gcc/cp/
	Move mangling aliases out of global namespace.
	* cp-tree.h (record_mangling): New.
	(maybe_remove_implicit_alias): Delete.
	* decl2.c (mangled_decls): New hash map.
	(generate_mangling_alias): Reimplement using mangled_decls.
	(record_mangling): New.
	* mangle.c (decl_implicit_alias_p,
	maybe_remove_implicit_alias): Delete.
	(mangle_decl): Use record_mangling.
	* name-lookup.c (supplement_binding_1): Remove
	maybe_remove_implicit_alias check.

	* call.c (convert_arg_to_ellipsis): Correct comment about passing
	by reference.

	gcc/testsuite/
	* g++.dg/abi/mangle41.C: Adjust diagnostics.

	libcc1/
	* libcp1plugin.cc (supplement_binding): Don't use
	maybe_remove_implicit_alias.

From-SVN: r253421
2017-10-04 16:55:54 +00:00
Nathan Sidwell 5aaa8fb406 Remove TYPE_METHODS.
gcc/
	Remove TYPE_METHODS.
	* tree.h (TYPE_METHODS): Delete.
	* dwarf2out.c (gen_member_die): Member fns are on TYPE_FIELDS.
	* dbxout.c (dbxout_type_fields): Ignore FUNCTION_DECLs.
	(dbxout_type_methods): Scan TYPE_FIELDS.
	(dbxout_type): Don't check TYPE_METHODS here.
	* function.c (use_register_for_decl): Always ignore register for
	class types when not optimizing.
	* ipa-devirt.c (odr_types_equivalent_p): Delete TYPE_METHODS scan.
	* tree.c (free_lang_data_in_type): Stitch out member functions and
	templates from TYPE_FIELDS.
	(build_distinct_type_copy, verify_type_variant,
	verify_type): Member fns are on TYPE_FIELDS.
	* tree-dump.c (dequeue_and_dump): No TYPE_METHODS.
	* tree-pretty-print.c (dump_generic_node): Likewise.

	gcc/cp/
	Remove TYPE_METHODS.
	* class.c (maybe_warn_about_overly_private_class,
	finish_struct_methods, one_inheriting_sig, count_fields,
	add_fields_to_record_type, check_field_decls, check_methods,
	clone_function_decl, set_method_tm_attributes,
	finalize_literal_type_property, check_bases_and_members,
	create_vtable_ptr, determine_key_method,
	unreverse_member_declarations, finish_struct,
	add_vcall_offset_vtbl_entries_1): Member fns are on TYPE_FIELDS.
	* decl.c (fixup_anonymous_aggr): Likewise.
	* decl2.c (reset_type_linkage_2): Likewise.
	* method.c (after_nsdmi_defaulted_late_checks,
	lazily_declare_fn): Likewise.
	* optimize.c (maybe_thunk_body, maybe_clone_body): Likewise.
	* pt.c (instantiate_class_template_1, tsubst_expr,
	do_type_instantiation, instantiate_pending_templates): Likewise.
	* search.c (lookup_field_1): Likewise.
	* semantics.c (finish_member_declaration,
	finish_omp_declare_simd_methods): Likewise.

	gcc/c-family/
	Remove TYPE_METHODS.
	* c-ada-spec.c (is_tagged_type, has_nontrivial_methods,
	dump_ada_template, print_ada_methods,
	print_ada_declaration): Member fns are on TYPE_FIELDS.

	gcc/objc/
	Remove TYPE_METHODS.
	* objc-runtime-shared-support.c (build_ivar_list_initializer):
	Don't presume first item is a FIELD_DECL.

	gcc/testsuite/
	* g++.dg/ext/anon-struct6.C: Adjust diag.
	* g++.old-deja/g++.other/anon4.C: Adjust diag.

	libcc1/
	Remove TYPE_METHODS.
	* libcp1plugin.cc (plugin_build_decl): Member fns are on TYPE_FIELDS.

From-SVN: r250413
2017-07-21 00:27:51 +00:00
Nathan Sidwell d2884ecafd revert previous premature commit
From-SVN: r250181
2017-07-13 12:38:32 +00:00
Nathan Sidwell de0e7b1fab libcp1plugin.cc (plugin_build_decl): Use DECL_CXX_{CON,DE}STRUCTOR directly.
* libcp1plugin.cc (plugin_build_decl): Use
	DECL_CXX_{CON,DE}STRUCTOR directly.

From-SVN: r250180
2017-07-13 12:35:52 +00:00
Nathan Sidwell 75f8b37892 libcp1plugin.cc (plugin_build_decl): Use DECL_CXX_{CON,DE}STRUCTOR directly.
* libcp1plugin.cc (plugin_build_decl): Use
	DECL_CXX_{CON,DE}STRUCTOR directly.

From-SVN: r250159
2017-07-12 19:46:33 +00:00
Richard Sandiford d8448c583e Use SET_DECL_MODE in libcc1
2017-07-05  Richard Sandiford  <richard.sandiford@linaro.org>

libcc1/
	* libcp1plugin.cc (plugin_build_field): Use SET_DECL_MODE.

From-SVN: r250004
2017-07-05 15:32:37 +00:00
Nathan Sidwell 08fb13163c config-lang.in (gtfiles): Add cp/lex.c.
* config-lang.in (gtfiles): Add cp/lex.c.
	* cp-tree.h (mangle_convop_name_for_type): Rename ...
	(make_conv_op_name): ... here.  Move to lex.
	* lambda.c (maybe_add_lambda_conv_op): Update.
	* parser.c (cp_parser_conversion_function_id): Update.
	* pt.c (tsubst_decl, tsubst_baselink, tsubst_copy,
	tsubst_copy_and_build): Update.
	* semantics.c (apply_deduced_return_type): Update.
	* mangle.c (conv_type_hasher, conv_type_names,
	mangle_conv_op_name_for_type): Move to ...
	* lex.c (conv_type_hasher, conv_type_names, make_convop_name):
	... here.  Rename.

	* libcp1plugin.cc (plugin_build_decl): Use make_conv_op_name.
	(plugin_build_dependent_expr): Likewise.

From-SVN: r249852
2017-06-30 18:46:01 +00:00
Nathan Sidwell d6ef53f241 cp-tree.h (lang_decl_fn): Remove assignment_operator_p field.
gcc/cp/
	* cp-tree.h (lang_decl_fn): Remove assignment_operator_p field.
	(DECL_COMPLETE_CONSTRUCTOR_P): Directly compare
	identifier.
	(DECL_BASE_CONSTRUCTOR_P, DECL_COMPLETE_DESTRUCTOR_P)
	DECL_BASE_DESTRUCTOR_P, DECL_DELETING_DESTRUCTOR_P): Likewise.
	(DECL_ASSIGNMENT_OPERATOR_P): Use IDENTIFIER_ASSIGN_OP_P.
	* decl.c (grok_op_properties): Adjust identifier checking.
	* init.c (expand_default_init): Adjust identifier descision.
	* method.c (implicitly_declare_fn): Don't use
	DECL_ASSIGNMENT_OPERATOR_P.
	* search.c (lookup_fnfields_1): Use IDENTIFIER_CTOR_P,
	IDENTIFIER_DTOR_P.
	* call.c (in_charge_arg_for_name): Reimplement.
	(build_special_member_call): Use IDENTIFIER_CDTOR_P,
	IDENTIFIER_DTOR_P.

	libcc1/
	* libcp1plugin.cc (plugin_build_decl): Don't set
	DECL_ASSIGNMENT_OPERATOR_P.
(--This line, and those below, will be ignored--

M    gcc/cp/init.c
M    gcc/cp/decl.c
M    gcc/cp/method.c
M    gcc/cp/cp-tree.h
M    gcc/cp/call.c
M    gcc/cp/search.c
M    gcc/cp/ChangeLog
M    libcc1/ChangeLog
M    libcc1/libcp1plugin.cc

From-SVN: r249657
2017-06-26 16:38:40 +00:00
Nathan Sidwell e249fcad3a cp-tree.h (build_this_parm, [...]): Add FN parm.
gcc/cp/
	* cp-tree.h (build_this_parm, cp_build_parm_decl)
	build_artificial_parm): Add FN parm.
	* decl.c (start_cleanup_fn): Adjust.
	(build_this_parm): Add FN parm, pass it through.
	(grokfndecl): Adjust parm building.
	* decl2.c (cp_build_parm_decl): Add FN parm, set context.
	(build_artificial_parm): Add FN parm, pass through.
	(maybe_retrofit_in_chrg): Adjust parm building.
	(start_static_storage_duration_function): Likwise.
	* lambda.c (maybe_aadd_lambda_conv_op): Likewise.
	* method.c (implicitly_declare_fn): Likewise.
	* parser.c (inject_this_parameter): Likewise.

	libcc1/
	* libcp1plugin.cc (plugin_build_decl): Adjust parm building.
(--This line, and those below, will be ignored--

M    gcc/cp/parser.c
M    gcc/cp/ChangeLog
M    gcc/cp/decl.c
M    gcc/cp/lambda.c
M    gcc/cp/cp-tree.h
M    gcc/cp/method.c
M    gcc/cp/decl2.c
M    libcc1/libcp1plugin.cc
M    libcc1/ChangeLog

From-SVN: r249268
2017-06-16 15:42:33 +00:00
Nathan Sidwell 3c9feefc8d Inline and using namespace representation change.
gcc/cp/
	Inline and using namespace representation change.
	* cp-tree.h (struct lang_decl_ns): Delete ns_using.  Add usings,
	inlinees as vector.
	(DECL_NAMESPACE_USING): Adjust.
	(DECL_NAMESPACE_INLINEES): New.
	* name-lookup.h (struct cp_binding_level): Change usings
	representation.
	* name-lookup.c (name_lookup::do_queue_usings)
	name_lookup::queue_usings): Adjust.
	(name_lookup::search_namespace, name_lookup::search_usings)
	name_lookup::queue_namespace): Adjust.
	(name_lookup::adl_namespace_only): Adjust.
	(add_using_namespace, push_namespace): Push onto vector.
	(pop_namespace): Add timing logic.

	libcc1/
	* libcp1plugin.cc (plugin_make_namespace_inline): Push onto linees.
((--This line, and those below, will be ignored--

M    gcc/cp/ChangeLog
M    gcc/cp/cp-tree.h
M    gcc/cp/name-lookup.c
M    gcc/cp/name-lookup.h
M    libcc1/libcp1plugin.cc
M    libcc1/ChangeLog

From-SVN: r248520
2017-05-26 17:19:46 +00:00
Nathan Sidwell e1cad93084 call.c (build_operator_new_call): Do namelookup and ADL here.
gcc/cp/
	* call.c (build_operator_new_call): Do namelookup and ADL here.
	(build_new_op_1): Likewise.
	* name-lookup.h (lookup_function_nonclass): Delete declaration.
	(do_using_directive): Likewise.
	* name-lookup.c (set_namespace_binding, push_local_binding): Don't
	declare early.
	(struct scope_binding): Delete.
	(EMPTY_SCOPE_BINDING): Delete.
	(set_decl_namespace): Use OVL_P.
	(finish_local_using_decl): Lose unnecesary checks.
	(lookup_function_nonclass): Delete.
	(cp_emit_debug_info_for_using): Use MAYBE_BASELINK_P.

	libcc1/
	* libcp1plugin.cc (plugin_add_using_namespace): Call
	finish_namespace_using_directive.

From-SVN: r248518
2017-05-26 16:34:40 +00:00
Nathan Sidwell 44e00a7a1b Kill DECL_NAMESPACE_USERS, DECL_NAMESPACE_ASSOCIATIONS.
gcc/cp/
	Kill DECL_NAMESPACE_USERS, DECL_NAMESPACE_ASSOCIATIONS.
	* cp-tree.h (lang_decl_ns): Remove ns_users field.
	(DECL_NAMESPACE_USERS, DECL_NAMESPACE_ASSOCIATIONS): Delete.
	(TREE_INDIRECT_USING): Delete.
	* name-lookup.h (is_associated_namespace): Delete.
	* name-lookup.c (name_lookup::search_usings
	name_lookup::do_queue_usings): Usings are always direct.
	(is_associated_namespace): Delete.
	(handle_namespace_attrs): Use DECL_NAMESPACE_INLINE_P.
	(namespace_ancestor_1, namespace_ancestor): Delete.
	(push_using_directive_1, push_using_directive): Delete.
	(add_using_namespace_1): Delete.
	(add_using_namespace): Reimplement.
	(emit_debug_info_using_namespace): New.
	(finish_namespace_using_directive, finish_local_using_directive
	push_namespace): Adjust.
	* tree.c (cp_free_lang_data): Remove DECL_NAMESPACE_USERS
	handling.

	libcc1/
	* libcp1plugin.cc (plugin_make_namespace_inline): Check and set
	DECL_NAMESPACE_INLINE_P.

	gcc/testsuite/
	* g++.dg/lookup/using56.C: New.
	* g++.dg/lookup/using57.C: New.
	* g++.dg/lookup/using58.C: New.
	* g++.dg/lookup/using59.C: New.

From-SVN: r248467
2017-05-25 18:52:47 +00:00
Nathan Sidwell 9d029ddfda cp-tree.h (OVL_P): New.
gcc/cp
	* cp-tree.h (OVL_P): New.
	* name-lookup.h (push_local_binding): Delete.
	(do_toplevel_using_decl, do_local_using_decl): Rename to ...
	(finish_namespace_using_decl, finish_local_using_decl): ... here
	* name-lookup.c (add_decl_to_level): Swap args.
	(pop_bindings_and_leave_scope): Look inside TREE_LIST.
	(diagnose_name_conflict): Check contexts are same for redecl.
	(update_local_overload): New.
	(compparms_for_decl_and_using): Rename to ...
	(matching_fn_p): ... here.
	(pushdecl_maybe_friend_1): Adjust add_decl_to_level,
	push_local_bindings call.
	(push_local_binding): Make static, replace FLAGS arg with
	IS_USING.
	(validate_nonmember_using_decl): Use OVL_FIRST.
	(do_nonmember_using_decl): Use in/out parameters.  Use
	lkp_iterator and simplify.
	(do_toplevel_using_decl, do_local_using_decl): Rename to ...
	(finish_namespace_using_decl, finish_local_using_decl): ... here.
	Adjust.
	(lookup_type_current_level): Delete.
	* parser.c (cp_parser_using_declaration): Adjust.
	* pt.c (tsubst_expr): Adjust.

	libcc1/
	* libcp1plugin.cc (plugin_add_using_decl): Call
	finish_namespace_using_decl.  Use assert not unreachable.

	gcc/testsuite/
	* g++.dg/lookup/using13.C: Adjust expected error.

From-SVN: r248364
2017-05-23 10:58:57 +00:00
Nathan Sidwell 430af3cf5a * libcp1plugin.cc (plugin_build_decl): Adjust add_method call.
From-SVN: r247922
2017-05-11 18:48:55 +00:00
Nathan Sidwell d5a2f455e6 cp-tree.h (add_method, [...]): Change last arg to bool.
gcc/cp/
	* cp-tree.h (add_method, clone_function_decl): Change last arg to
	bool.
	* class.c (add_method): Change third arg to bool.  Adjust.
	(one_inheriting_sig, one_inherited_ctor): Adjust.
	(clone_function_decl): Change 2nd arg to bool.  Adjust.
	(clone_constructors_and_destructors): Adjust.
	* lambda.c (maybe_add_lambda_conv_op): Adjust.
	* method.c (lazily_declare_fn): Adjust.
	* pt.c (tsubst_decl, instantiate_template_1): Adjust.
	* semantics.c (finish_member_declaration): Adjust.

	libcc1/
	* libcp1plugin.cc (plugin_build_decl): Adjust add_method call.

From-SVN: r247834
2017-05-10 13:12:57 +00:00
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
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