Commit Graph

57 Commits

Author SHA1 Message Date
Sergei Trofimovich
3b21c21f3f c++: avoid <memory> poisoning on musl [PR106102]
On musl <pthread.h> uses calloc() (via <sched.h>). <memory> includes
it indirectly and exposes use of poisoned calloc() when module code
is built:

    /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc
        In file included from /<<NIX>>/musl-1.2.3-dev/include/pthread.h:30,
                 from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35,
                 ....
                 from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77,
                 from ../../gcc-13-20220626/gcc/../libcody/cody.hh:24,
                 from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.h:25,
                 from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.cc:23,
                 from ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc:32:
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc"
       84 | void *calloc(size_t, size_t);
          |       ^
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc"
      124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
          |                                    ^

gcc/cp/

	PR c++/106102
	* mapper-client.cc: Include <memory> via "system.h".
	* mapper-resolver.cc: Ditto.
	* module.cc: Ditto.

libcc1/

	PR c++/106102
	* libcc1plugin.cc: Include <memory> via "system.h".
	* libcp1plugin.cc: Ditto.
2022-06-27 23:22:02 +01:00
Jakub Jelinek
7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00
Patrick Palka
bb2a7f80a9 c++: two-stage name lookup for overloaded operators [PR51577]
In order to properly implement two-stage name lookup for dependent
operator expressions, we need to remember the result of unqualified
lookup of the operator at template definition time, and reuse that
result rather than performing another unqualified lookup at
instantiation time.

Ideally we could just store the lookup in the expression directly, but
as pointed out in r9-6405 this isn't really possible since we use the
standard tree codes to represent most dependent operator expressions.

We could perhaps create a new tree code to represent dependent operator
expressions, with enough operands to store the lookup along with
everything else, but that'd require a lot of careful work to make sure
we handle this new tree code properly across the frontend.

But currently type-dependent operator (and call) expressions are given
an empty TREE_TYPE, which dependent_type_p treats as dependent, so this
field is effectively unused except to signal that the expression is
type-dependent.  It'd be convenient if we could store the lookup there
while preserving the dependent-ness of the expression.

To that end, this patch creates a new kind of type, called
DEPENDENT_OPERATOR_TYPE, which we give to dependent operator expressions
and into which we can store the result of operator lookup at template
definition time (DEPENDENT_OPERATOR_TYPE_SAVED_LOOKUPS).  Since this
type is always dependent (by definition), and since the frontend doesn't
seem to care much about the exact type of a type-dependent expression,
using this type in place of a NULL_TREE type seems to "just work"; only
dependent_type_p and WILDCARD_TYPE_P need to be adjusted to return true
for this new type.

The rest of the patch mostly consists of adding the necessary plumbing
to pass DEPENDENT_OPERATOR_TYPE_SAVED_LOOKUPS to add_operator_candidates,
adjusting all callers of build_x_* appropriately, and removing the now
unnecessary push_operator_bindings mechanism.

In passing, this patch simplifies finish_constraint_binary_op to avoid
using build_x_binary_op for building a binary constraint-expr; we don't
need to consider operator overloads here, as the &&/|| inside a
constraint effectively always has the built-in meaning (since atomic
constraints must have bool type).

This patch also makes FOLD_EXPR_OP yield a tree_code instead of a raw
INTEGER_CST.

Finally, this patch adds the XFAILed test operator-8.C which is about
broken two-stage name lookup for rewritten non-dependent operator
expressions, an existing bug that's otherwise only documented in
build_new_op.

	PR c++/51577
	PR c++/83035
	PR c++/100465

gcc/cp/ChangeLog:

	* call.c (add_operator_candidates): Add lookups parameter.
	Use it to avoid performing a second unqualified lookup when
	instantiating a dependent operator expression.
	(build_new_op): Add lookups parameter and pass it appropriately.
	* constraint.cc (finish_constraint_binary_op): Use
	build_min_nt_loc instead of build_x_binary_op.
	* coroutines.cc (build_co_await): Adjust call to build_new_op.
	* cp-objcp-common.c (cp_common_init_ts): Mark
	DEPENDENT_OPERATOR_TYPE appropriately.
	* cp-tree.def (DEPENDENT_OPERATOR_TYPE): Define.
	* cp-tree.h (WILDCARD_TYPE_P): Accept DEPENDENT_OPERATOR_TYPE.
	(FOLD_EXPR_OP_RAW): New, renamed from ...
	(FOLD_EXPR_OP): ... this.  Change this to return the tree_code directly.
	(DEPENDENT_OPERATOR_TYPE_SAVED_LOOKUPS): Define.
	(templated_operator_saved_lookups): Define.
	(build_new_op): Add lookups parameter.
	(build_dependent_operator_type): Declare.
	(build_x_indirect_ref): Add lookups parameter.
	(build_x_binary_op): Likewise.
	(build_x_unary_op): Likewise.
	(build_x_compound_expr): Likewise.
	(build_x_modify_expr): Likewise.
	* cxx-pretty-print.c (get_fold_operator): Adjust after
	FOLD_EXPR_OP change.
	* decl.c (start_preparsed_function): Don't call
	push_operator_bindings.
	* decl2.c (grok_array_decl): Adjust calls to build_new_op.
	* method.c (do_one_comp): Likewise.
	(build_comparison_op): Likewise.
	* module.cc (trees_out::type_node): Handle DEPENDENT_OPERATOR_TYPE.
	(trees_in::tree_node): Likewise.
	* name-lookup.c (lookup_name): Revert r11-2876 change.
	(op_unqualified_lookup): Remove.
	(maybe_save_operator_binding): Remove.
	(discard_operator_bindings): Remove.
	(push_operator_bindings): Remove.
	* name-lookup.h (maybe_save_operator_binding): Remove.
	(push_operator_bindings): Remove.
	(discard_operator_bindings): Remove.
	* parser.c (cp_parser_unary_expression): Adjust calls to build_x_*.
	(cp_parser_binary_expression): Likewise.
	(cp_parser_assignment_expression): Likewise.
	(cp_parser_expression): Likewise.
	(do_range_for_auto_deduction): Likewise.
	(cp_convert_range_for): Likewise.
	(cp_parser_perform_range_for_lookup): Likewise.
	(cp_parser_template_argument): Likewise.
	(cp_parser_omp_for_cond): Likewise.
	(cp_parser_omp_for_incr): Likewise.
	(cp_parser_omp_for_loop_init): Likewise.
	(cp_convert_omp_range_for): Likewise.
	(cp_finish_omp_range_for): Likewise.
	* pt.c (fold_expression): Adjust after FOLD_EXPR_OP change. Pass
	templated_operator_saved_lookups to build_x_*.
	(tsubst_omp_for_iterator): Adjust call to build_x_modify_expr.
	(tsubst_expr) <case COMPOUND_EXPR>: Pass
	templated_operator_saved_lookups to build_x_*.
	(tsubst_copy_and_build) <case INDIRECT_REF>: Likewise.
	<case tcc_unary>: Likewise.
	<case tcc_binary>: Likewise.
	<case MODOP_EXPR>: Likewise.
	<case COMPOUND_EXPR>: Likewise.
	(dependent_type_p_r): Return true for DEPENDENT_OPERATOR_TYPE.
	* ptree.c (cxx_print_type): Handle DEPENDENT_OPERATOR_TYPE.
	* semantics.c (finish_increment_expr): Adjust call to
	build_x_unary_op.
	(finish_unary_op_expr): Likewise.
	(handle_omp_for_class_iterator): Adjust calls to build_x_*.
	(finish_omp_cancel): Likewise.
	(finish_unary_fold_expr): Use build_dependent_operator_type.
	(finish_binary_fold_expr): Likewise.
	* tree.c (cp_free_lang_data): Don't call discard_operator_bindings.
	* typeck.c (rationalize_conditional_expr): Adjust call to
	build_x_binary_op.
	(op_unqualified_lookup): Define.
	(build_dependent_operator_type): Define.
	(build_x_indirect_ref): Add lookups parameter and use
	build_dependent_operator_type.
	(build_x_binary_op): Likewise.
	(build_x_array_ref): Likewise.
	(build_x_unary_op): Likewise.
	(build_x_compound_expr_from_list): Adjust call to
	build_x_compound_expr.
	(build_x_compound_expr_from_vec): Likewise.
	(build_x_compound_expr): Add lookups parameter and use
	build_dependent_operator_type.
	(cp_build_modify_expr): Adjust call to build_new_op.
	(build_x_modify_expr): Add lookups parameter and use
	build_dependent_operator_type.
	* typeck2.c (build_x_arrow): Adjust call to build_new_op.

libcc1/ChangeLog:

	* libcp1plugin.cc (plugin_build_unary_expr): Adjust call to
	build_x_unary_op.
	(plugin_build_binary_expr): Adjust call to build_x_binary_op.

gcc/testsuite/ChangeLog:

	* g++.dg/lookup/operator-3.C: Split out operator overload
	declarations into ...
	* g++.dg/lookup/operator-3-ops.h: ... here.
	* g++.dg/lookup/operator-3a.C: New test.
	* g++.dg/lookup/operator-4.C: New test.
	* g++.dg/lookup/operator-4a.C: New test.
	* g++.dg/lookup/operator-5.C: New test.
	* g++.dg/lookup/operator-5a.C: New test.
	* g++.dg/lookup/operator-6.C: New test.
	* g++.dg/lookup/operator-7.C: New test.
	* g++.dg/lookup/operator-8.C: New test.
2021-12-16 13:40:42 -05:00
Martin Sebor
3f44889076 libcc1: Add support for per-location warning groups.
libcc1/ChangeLog:

	* libcp1plugin.cc (record_decl_address): Replace a direct use
	of TREE_NO_WARNING with suppress_warning.
2021-06-28 15:09:46 -06:00
Tom Tromey
8fdffa48c5 libcc1: use variadic templates for callbacks
This patch completes the transition of libcc1 from the use of separate
template functions for different arities to the use of variadic
functions.  This is how I had wanted it to work from the very
beginning, and is possible now with C++11.

I had thought that variadic callbacks required C++17, but it turns out
that the approach taken here is basically equivalent to std::apply --
just a bit wordier.

libcc1

	* rpc.hh (argument_wrapper) <get>: Replace cast operator.
	(argument_wrapper<T *>) <get>: Likewise.
	(unmarshall): Add std::tuple overloads.
	(callback): Remove.
	(class invoker): New.
	* libcp1plugin.cc (plugin_init): Update.
	* libcp1.cc (libcp1::add_callbacks): Update.
	* libcc1plugin.cc (plugin_init): Update.
	* libcc1.cc (libcc1::add_callbacks): Update.
	* connection.cc (cc1_plugin::connection::do_wait): Update.
2021-05-05 00:06:18 -06:00
Tom Tromey
0624823260 libcc1: share basic context code
Both plugins in libcc1 share a fair amount of boilerplate.  They both
share error-emission code, context management code, and tree GC code.
This patch unifies these two bodies of code, avoiding needless
duplication.

libcc1

	* libcc1plugin.cc: Move code to context.cc.
	* libcp1plugin.cc: Move code to context.cc.
	* context.hh: New file.
	* context.cc: New file.
	* Makefile.in: Rebuild.
	* Makefile.am (AM_CPPFLAGS): Add more gcc flags.
	(CPPFLAGS_FOR_C, CPPFLAGS_FOR_CXX): Update.
	(libcc1plugin_la_SOURCES): Add context.hh, context.cc.
	(libcp1plugin_la_SOURCES): Likewise.
2021-05-05 00:06:17 -06:00
Tom Tromey
0ed83e1d03 libcc1: use static_assert
This changes one spot in libcc1 to use static_assert rather than the
old-style array declaration.

libcc1

	* libcp1plugin.cc: Use static assert.
2021-05-05 00:06:17 -06:00
Tom Tromey
7c4e5d5eaa libcc1: use foreach
This changes libcc1 to ues foreach in a couple of spots.

libcc1

	* libcp1plugin.cc (plugin_context::mark): Use foreach.
	* libcc1plugin.cc (plugin_context::mark): Use foreach.
2021-05-05 00:06:17 -06:00
Tom Tromey
e702c60e65 libcc1: use std::vector when building function types
This changes libcc1 to use std::vector in the code that builds
function types.  This avoids some explicit memory management.

libcc1

	* libcp1plugin.cc (plugin_build_function_type): Use std::vector.
	* libcc1plugin.cc (plugin_build_function_type): Use std::vector.
2021-05-05 00:06:16 -06:00
Jakub Jelinek
99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
Patrick Palka
61827d5d9a c++: Correct the handling of alignof(expr) [PR88115]
We're currently neglecting to set the ALIGNOF_EXPR_STD_P flag on an
ALIGNOF_EXPR when its operand is an expression.  This leads to us
handling alignof(expr) as if it were written __alignof__(expr), and
returning the preferred alignment instead of the ABI alignment.  In the
testcase below, this causes the first and third static_assert to fail on
x86.

gcc/cp/ChangeLog:

	PR c++/88115
	* cp-tree.h (cxx_sizeof_or_alignof_expr): Add bool parameter.
	* decl.c (fold_sizeof_expr): Pass false to
	cxx_sizeof_or_alignof_expr.
	* parser.c (cp_parser_unary_expression): Pass std_alignof to
	cxx_sizeof_or_alignof_expr.
	* pt.c (tsubst_copy): Pass false to cxx_sizeof_or_alignof_expr.
	(tsubst_copy_and_build): Pass std_alignof to
	cxx_sizeof_or_alignof_expr.
	* typeck.c (cxx_alignof_expr): Add std_alignof bool parameter
	and pass it to cxx_sizeof_or_alignof_type.  Set ALIGNOF_EXPR_STD_P
	appropriately.
	(cxx_sizeof_or_alignof_expr): Add std_alignof bool parameter
	and pass it to cxx_alignof_expr.  Assert op is either
	SIZEOF_EXPR or ALIGNOF_EXPR.

libcc1/ChangeLog:

	PR c++/88115
	* libcp1plugin.cc (plugin_build_unary_expr): Pass true to
	cxx_sizeof_or_alignof_expr.

gcc/testsuite/ChangeLog:

	PR c++/88115
	* g++.dg/cpp0x/alignof6.C: New test.
2020-11-11 14:43:38 -05:00
Marek Polacek
8c0c83feb0 c++: Improve static_assert diagnostic [PR97518]
Currently, when a static_assert fails, we only say "static assertion failed".
It would be more useful if we could also print the expression that
evaluated to false; this is especially useful when the condition uses
template parameters.  Consider the motivating example, in which we have
this line:

  static_assert(is_same<X, Y>::value);

if this fails, the user has to play dirty games to get the compiler to
print the template arguments.  With this patch, we say:

  error: static assertion failed
  note: 'is_same<int*, int>::value' evaluates to false

which I think is much better.  However, always printing the condition that
evaluated to 'false' wouldn't be very useful: e.g. noexcept(fn) is
always parsed to true/false, so we would say "'false' evaluates to false"
which doesn't help.  So I wound up only printing the condition when it was
instantiation-dependent, that is, we called finish_static_assert from
tsubst_expr.

Moreover, this patch also improves the diagnostic when the condition
consists of a logical AND.  Say you have something like this:

  static_assert(fn1() && fn2() && fn3() && fn4() && fn5());

where fn4() evaluates to false and the other ones to true.  Highlighting
the whole thing is not that helpful because it won't say which clause
evaluated to false.  With the find_failing_clause tweak in this patch
we emit:

  error: static assertion failed
    6 | static_assert(fn1() && fn2() && fn3() && fn4() && fn5());
      |                                          ~~~^~

so you know right away what's going on.  Unfortunately, when you combine
both things, that is, have an instantiation-dependent expr and && in
a static_assert, we can't yet quite point to the clause that failed.  It
is because when we tsubstitute something like is_same<X, Y>::value, we
generate a VAR_DECL that doesn't have any location.  It would be awesome
if we could wrap it with a location wrapper, but I didn't see anything
obvious.

In passing, I've cleaned up some things:
* use iloc_sentinel when appropriate,
* it's nicer to call contextual_conv_bool instead of the rather verbose
  perform_implicit_conversion_flags,
* no need to check for INTEGER_CST before calling integer_zerop.

gcc/cp/ChangeLog:

	PR c++/97518
	* cp-tree.h (finish_static_assert): Adjust declaration.
	* parser.c (cp_parser_static_assert): Pass false to
	finish_static_assert.
	* pt.c (tsubst_expr): Pass true to finish_static_assert.
	* semantics.c (find_failing_clause_r): New function.
	(find_failing_clause): New function.
	(finish_static_assert): Add a bool parameter.  Use
	iloc_sentinel.  Call contextual_conv_bool instead of
	perform_implicit_conversion_flags.  Don't check for INTEGER_CST before
	calling integer_zerop.  Call find_failing_clause and maybe use its
	location.  Print the original condition or the failing clause if
	SHOW_EXPR_P.

gcc/testsuite/ChangeLog:

	PR c++/97518
	* g++.dg/diagnostic/pr87386.C: Adjust expected output.
	* g++.dg/diagnostic/static_assert1.C: New test.
	* g++.dg/diagnostic/static_assert2.C: New test.

libcc1/ChangeLog:

	PR c++/97518
	* libcp1plugin.cc (plugin_add_static_assert): Pass false to
	finish_static_assert.
2020-11-10 15:08:06 -05:00
Nathan Sidwell
ba6498124c core: Rename DECL_IS_BUILTIN -> DECL_IS_UNDECLARED_BUILTIN
In cleaning up C++'s handling of hidden decls, I renamed its
DECL_BUILTIN_P, which checks for loc == BUILTINS_LOCATION to
DECL_UNDECLARED_BUILTIN_P, because the location gets updated, if user
source declares the builtin, and the predicate no longer holds.  The
original name was confusing me.  (The builtin may still retain builtin
properties in the redeclaration, and other predicates can still detect
that.)

I discovered that tree.h had its own variant 'DECL_IS_BUILTIN', which
behaves in (almost) the same manner.  And therefore has the same
mutating behaviour.

This patch deletes the C++ one, and renames tree.h's to
DECL_IS_UNDECLARED_BUILTIN, to emphasize its non-constantness.  I
guess _IS_ wins over _P

	gcc/
	* tree.h (DECL_IS_BUILTIN): Rename to ...
	(DECL_IS_UNDECLARED_BUILTIN): ... here.  No need to use SOURCE_LOCUS.
	* calls.c (maybe_warn_alloc_args_overflow): Adjust for rename.
	* cfgexpand.c (pass_expand::execute): Likewise.
	* dwarf2out.c (base_type_die, is_naming_typedef_decl): Likewise.
	* godump.c (go_decl, go_type_decl): Likewise.
	* print-tree.c (print_decl_identifier): Likewise.
	* tree-pretty-print.c (dump_generic_node): Likewise.
	* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Likewise.
	* xcoffout.c (xcoff_assign_fundamental_type_number): Likewise.
	gcc/c-family/
	* c-ada-spec.c (collect_ada_nodes): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	(collect_ada_node): Likewise.
	(dump_forward_type): Likewise.
	* c-common.c (set_underlying_type): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	(user_facing_original_type, c_common_finalize_early_debug): Likewise.
	gcc/c/
	* c-decl.c (diagnose_mismatched_decls): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	(warn_if_shadowing, implicitly_declare, names_builtin_p)
	(collect_source_refs): Likewise.
	* c-typeck.c (inform_declaration, inform_for_arg)
	(convert_for_assignment): Likewise.
	gcc/cp/
	* cp-tree.h (DECL_UNDECLARED_BUILTIN_P): Delete.
	* cp-objcp-common.c (names_bultin_p): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	* decl.c (decls_match): Likewise.  Replace
	DECL_UNDECLARED_BUILTIN_P with DECL_IS_UNDECLARED_BUILTIN.
	(duplicate_decls): Likewise.
	* decl2.c (collect_source_refs): Likewise.
	* name-lookup.c (anticipated_builtin_p, print_binding_level)
	(do_nonmember_using_decl): Likewise.
	* pt.c (builtin_pack_fn_p): Likewise.
	* typeck.c (error_args_num): Likewise.
	gcc/lto/
	* lto-symtab.c (lto_symtab_merge_decls_1): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	gcc/go/
	* go-gcc.cc (Gcc_backend::call_expression): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	libcc1/
	* libcc1plugin.cc (address_rewriter): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	* libcp1plugin.cc (supplement_binding): Likewise.
2020-11-06 10:50:51 -08:00
Nathan Sidwell
068644a149 c++: DECL_FRIEND_P cleanup
DECL_FRIEND_P's meaning has changed over time.  It now (almost) means
the the friend function decl has not been met via an explicit decl.
This completes that transition, renaming it to DECL_UNIQUE_FRIEND_P,
so one doesn't think it is the sole indicator of friendliness (plenty
of friends do not have the flag set).  This allows reduction in the
complexity of managing the field -- all in duplicate_decls now.

	gcc/cp/
	* cp-tree.h (struct lang_decl_fn): Adjust context comment.
	(DECL_FRIEND_P): Replace with ...
	(DECL_UNIQUE_FRIEND_P): ... this.  Only for FUNCTION_DECLs.
	(DECL_FRIEND_CONTEXT): Adjust.
	* class.c (add_implicitly_declared_members): Detect friendly
	spaceship from context.
	* constraint.cc (remove_constraints): Use a checking assert.
	(maybe_substitute_reqs_for): Use DECL_UNIQUE_FRIEND_P.
	* decl.c (check_no_redeclaration_friend_default_args):
	DECL_UNIQUE_FRIEND_P is signficant, not hiddenness.
	(duplicate_decls): Adjust DECL_UNIQUE_FRIEND_P clearing.
	(redeclaration_error_message): Use DECL_UNIQUE_FRIEND_P.
	(start_preparsed_function): Correct in-class friend processing.
	Refactor some initializers.
	(grokmethod): Directly check friend decl-spec.
	* decl2.c (grokfield): Check DECL_UNIQUE_FRIEND_P.
	* friend.c (do_friend): Set DECL_UNIQUE_FRIEND_P first, remove
	extraneous conditions.  Don't re set it afterwards.
	* name-lookup.c (lookup_elaborated_type_1): Simplify revealing
	code.
	(do_pushtag): Likewise.
	* pt.c (optimize_specialization_lookup_p): Check
	DECL_UNIQUE_FRIEND_P.
	(push_template_decl): Likewise.  Drop unneeded friend setting.
	(type_dependent_expression_p): Check DECL_UNIQUE_FRIEND_P.
	libcc1/
	* libcp1plugin.cc (plugin_add_friend): Set DECL_UNIQUE_FRIEND_P.
2020-10-14 10:04:18 -07:00
Nathan Sidwell
99e9b54313 c++: Rename DECL_BUILTIN_P to DECL_UNDECLARED_BUILTIN_P
I realized I'd misnamed DECL_BUILTIN_P, it's only true of compiler
builtins unless and until the user declares them -- at that point
they're real decls, and will have a location in the user's source.
(BUILT_IN_FN and friends still work though).  This renames them so
future-me is not confused as to why the predicate becomes false.

	gcc/cp/
	* cp-tree.h (DECL_BUILTIN_P): Rename to ...
	(DECL_UNDECLARED_BUILTIN_P): ... here.
	* decl.c (duplicate_decls): Adjust.
	* name-lookup.c (anticipated_builtin_p): Adjust.
	(do_nonmember_using_decl): Likewise.
	libcc1/
	* libcp1plugin.cc (supplement_binding): Rename
	DECL_BUILTIN_P.
2020-10-07 05:06:52 -07:00
Nathan Sidwell
679dbc9dce c++: Kill DECL_ANTICIPATED
Here's the patch to remove DECL_ANTICIPATED, and with it hiddenness is
managed entirely in the symbol table.  Sadly I couldn't get rid of the
actual field without more investigation -- it's repurposed for
OMP_PRIVATIZED_MEMBER.  It looks like a the VAR-related flags in
lang_decl_base are not completely orthogonal, so perhaps some can be
turned into an enumeration or something.  But that's more than I want
to do right now.

DECL_FRIEND_P Is still slightly suspect as it appears to mean more
than just in-class definition.  However, I'm leaving that for now.

	gcc/cp/
	* cp-tree.h (lang_decl_base): anticipated_p is not used for
	anticipatedness.
	(DECL_ANTICIPATED): Delete.
	* decl.c (duplicate_decls): Delete DECL_ANTICIPATED_management,
	use was_hidden.
	(cxx_builtin_function): Drop DECL_ANTICIPATED setting.
	(xref_tag_1): Drop DECL_ANTICIPATED assert.
	* name-lookup.c (name_lookup::adl_class_only): Drop
	DECL_ANTICIPATED check.
	(name_lookup::search_adl): Always dedup.
	(anticipated_builtin_p): Reimplement.
	(do_pushdecl): Drop DECL_ANTICIPATED asserts & update.
	(lookup_elaborated_type_1): Drop DECL_ANTICIPATED update.
	(do_pushtag): Drop DECL_ANTICIPATED setting.
	* pt.c (push_template_decl): Likewise.
	(tsubst_friend_class): Likewise.
	libcc1/
	* libcp1plugin.cc (libcp1plugin.cc): Drop DECL_ANTICIPATED test.
2020-10-02 12:21:08 -07:00
Nathan Sidwell
a28542df4d c++: DECL_BUILTIN_P for builtins
We currently detect builtin decls via DECL_ARTIFICIAL &&
!DECL_HIDDEN_FUNCTION_P, which, besides being clunky, is a problem as
hiddenness is a property of the symbol table -- not the decl being
hidden.  This adds DECL_BUILTIN_P, which just looks at the
SOURCE_LOCATION -- we have a magic one for builtins.

One of the consequential changes is to make function-scope omp udrs
have function context (needed because otherwise duplicate-decls thinks
the types don't match at the point we check).  This is also morally
better, because that's what they are -- nested functions, stop lying.

(That's actually my plan for all DECL_LOCAL_DECL_P decls, as they are
distinct decls to the namespace-scope decl they alias.)

	gcc/cp/
	* cp-tree.h (DECL_BUILTIN_P): New.
	* decl.c (duplicate_decls): Use it.  Do not treat omp-udr as a
	builtin.
	* name-lookup.c (anticipated_builtin): Use it.
	(set_decl_context_in_fn): Function-scope OMP UDRs have function context.
	(do_nonmember_using_decl): Use DECL_BUILTIN_P.
	* parser.c (cp_parser_omp_declare_reduction): Function-scope OMP
	UDRs have function context.  Assert we never find a valid duplicate.
	* pt.c (tsubst_expr): Function-scope OMP UDRs have function context.
	libcc1/
	* libcp1plugin.cc (supplement_binding): Use DECL_BULTIN_P.
2020-09-25 06:58:07 -07:00
Nathan Sidwell
d13c0ae859 c++: Cleanup some decl pushing apis
In cleaning up local decl handling, here's an initial patch that takes
advantage of C++'s default args for the is_friend parm of pushdecl,
duplicate_decls and push_template_decl_real and the scope & tpl_header
parms of xref_tag.  Then many of the calls simply not mention these.
I also rename push_template_decl_real to push_template_decl, deleting
the original forwarding function.  This'll make my later patches
changing their types less intrusive.  There are 2 functional changes:

1) push_template_decl requires is_friend to be correct, it doesn't go
checking for a friend function (an assert is added).

2) debug_overload prints out Hidden and Using markers for the overload set.

	gcc/cp/
	* cp-tree.h (duplicate_decls): Default is_friend to false.
	(xref_tag): Default tag_scope & tpl_header_p to ts_current & false.
	(push_template_decl_real): Default is_friend to false.  Rename to
	...
	(push_template_decl): ... here.  Delete original decl.
	* name-lookup.h (pushdecl_namespace_level): Default is_friend to
	false.
	(pushtag): Default tag_scope to ts_current.
	* coroutines.cc (morph_fn_to_coro): Drop default args to xref_tag.
	* decl.c (start_decl): Drop default args to duplicate_decls.
	(start_enum): Drop default arg to pushtag & xref_tag.
	(start_preparsed_function): Pass DECL_FRIEND_P to
	push_template_decl.
	(grokmethod): Likewise.
	* friend.c (do_friend): Rename push_template_decl_real calls.
	* lambda.c (begin_lamnbda_type): Drop default args to xref_tag.
	(vla_capture_type): Likewise.
	* name-lookup.c (maybe_process_template_type_declaration): Rename
	push_template_decl_real call.
	(pushdecl_top_level_and_finish): Drop default arg to
	pushdecl_namespace_level.
	* pt.c (push_template_decl_real): Assert no surprising friend
	functions.  Rename to ...
	(push_template_decl): ... here.  Delete original function.
	(lookup_template_class_1): Drop default args from pushtag.
	(instantiate_class_template_1): Likewise.
	* ptree.c (debug_overload): Print hidden and using markers.
	* rtti.c (init_rtti_processing): Drop refault args from xref_tag.
	(build_dynamic_cast_1, tinfo_base_init): Likewise.
	* semantics.c (begin_class_definition): Drop default args to
	pushtag.
	gcc/objcp/
	* objcp-decl.c (objcp_start_struct): Drop default args to
	xref_tag.
	(objcp_xref_tag): Likewise.
	libcc1/
	* libcp1plugin.cc (supplement_binding): Drop default args to
	duplicate_decls.
	(safe_pushtag): Drop scope parm.  Drop default args to pushtag.
	(safe_pushdecl_maybe_friend): Rename to ...
	(safe_pushdecl): ... here. Drop is_friend parm.  Drop default args
	to pushdecl.
	(plugin_build_decl): Adjust safe_pushdecl & safe_pushtag calls.
	(plugin_build_constant): Adjust safe_pushdecl call.
2020-09-24 12:56:59 -07:00
Nathan Sidwell
f40866967d c++: DECL_LOCAL_FUNCTION_P -> DECL_LOCAL_DECL_P
Our handling of block-scope extern decls is insufficient for modern
C++, in particular modules, (but also constexprs).  We mark such local
function decls, and this patch extends that to marking local var decls
too, so mainly a macro rename.  Also, we set this flag earlier, rather
than learning about it when pushing the decl.  This is a step towards
handling these properly.

	gcc/cp/
	* cp-tree.h (DECL_LOCAL_FUNCTION_P): Rename to ...
	(DECL_LOCAL_DECL_P): ... here.  Accept both fns and vars.
	* decl.c (start_decl): Set DECL_LOCAL_DECL_P for local externs.
	(omp_declare_variant_finalize_one): Use DECL_LOCAL_DECL_P.
	(local_variable_p): Simplify.
	* name-lookup.c (set_decl_context_in_fn): Assert DECL_LOCAL_DECL_P
	is as expected.  Simplify.
	(do_pushdecl): Don't set decl_context_in_fn for friends.
	(is_local_extern): Simplify.
	* call.c (equal_functions): Use DECL_LOCAL_DECL_P.
	* parser.c (cp_parser_postfix_expression): Likewise.
	(cp_parser_omp_declare_reduction): Likewise.
	* pt.c (check_default_tmpl_args): Likewise.
	(tsubst_expr): Assert nested reduction function is local.
	(type_dependent_expression_p): Use DECL_LOCAL_DECL_P.
	* semantics.c (finish_call_expr): Likewise.
	libcc1/
	* libcp1plugin.cc (plugin_build_call_expr): Use DECL_LOCAL_DECL_P.
2020-09-10 05:45:46 -07:00
Nathan Sidwell
f00008b45a c++: Final bit of name-lookup api simplification
We no longer need to give name_lookup_real not name_lookup_nonclass
different names to the name_lookup functions.  This renames the lookup
functions thusly.

	gcc/cp/
	* name-lookup.h (lookup_name_real, lookup_name_nonclass): Rename
	to ...
	(lookup_name): ... these new overloads.
	* name-lookup.c (identifier_type_value_1): Rename lookup_name_real
	call.
	(lookup_name_real_1): Rename to ...
	(lookup_name_1): ... here.
	(lookup_name_real): Rename to ...
	(lookup_name): ... here.  Rename lookup_name_real_1 call.
	(lookup_name_nonclass): Delete.
	* call.c (build_operator_new_call): Rename lookup_name_real call.
	(add_operator_candidates): Likewise.
	(build_op_delete_call): Rename lookup_name_nonclass call.
	* parser.c (cp_parser_lookup_name): Likewise.
	* pt.c (tsubst_friend_class, lookup_init_capture_pack): Likewise.
	(tsubst_expr): Likewise.
	* semantics.c (capture_decltype): Likewise.
	libcc1/
	* libcp1plugin.cc (plugin_build_dependent_expr): Rename
	lookup_name_real call.
2020-08-14 16:55:35 -07:00
Nathan Sidwell
db1c2a89db c++: Yet more name-lookup api simplification
This patch deals with LOOKUP_HIDDEN, which originally meant 'find
hidden friends', but it's being pressed into service for not ignoring
lambda-relevant internals.  However these two functions are different.
(a) hidden friends can occur in block scope (very uncommon) and (b) it
had the semantics of stopping after the innermost enclosing
namepspace.  That's really suspect for the lambda case, but not
relevant there because we never get to namespace scope (I think).
Anyway, I've split the flag into two and adjusted the lambda callers
to just search block scope.  These two flags are added to the
LOOK_want enum class, which allows dropping another parameter from the
name lookup routines.

The remaining LOOKUP_$FOO flags in cp-tree.h are, I think, now all
related to features of overload resolution, conversion operators and
reference binding.  Nothing to do with /name/ lookup.

	gcc/cp/
	* cp-tree.h (LOOKUP_HIDDEN): Delete.
	(LOOKUP_PREFER_RVALUE): Adjust initializer.
	* name-lookup.h (enum class LOOK_want): Add HIDDEN_FRIEND and
	HIDDEN_LAMBDA flags.
	(lookup_name_real): Drop flags parm.
	(lookup_qualified_name): Drop find_hidden parm.
	* name-lookup.c (class name_lookup): Drop hidden field, adjust
	ctors.
	(name_lookup::add_overload): Check want for hiddenness.
	(name_lookup::process_binding): Likewise.
	(name_lookup::search_unqualified): Likewise.
	(identifier_type_value_1): Adjust lookup_name_real call.
	(set_decl_namespace): Adjust name_lookup ctor.
	(qualify_lookup): Drop flags parm, use want for hiddenness.
	(lookup_qualified_name): Drop find_hidden parm.
	(lookup_name_real_1): Drop flags parm, adjust qualify_lookup
	calls.
	(lookup_name_real): Drop flags parm.
	(lookup_name_nonclass, lookup_name): Adjust lookup_name_real
	calls.
	(lookup_type_scope_1): Adjust qualify_lookup calls.
	* call.c (build_operator_new_call): Adjust lookup_name_real call.
	(add_operator_candidates): Likewise.
	* coroutines.cc (morph_fn_to_coro): Adjust lookup_qualified_name
	call.
	* parser.c (cp_parser_lookup_name): Adjust lookup_name_real calls.
	* pt.c (check_explicit_specialization): Adjust
	lookup_qualified_name call.
	(deduction_guides_for): Likewise.
	(tsubst_friend_class): Adjust lookup_name_real call.
	(lookup_init_capture_pack): Likewise.
	(tsubst_expr): Likewise, don't look in namespaces.
	* semantics.c (capture_decltype): Adjust lookup_name_real.  Don't
	look in namespaces.
	libcc1/
	* libcp1plugin.cc (plugin_build_dependent_exp): Adjust
	lookup_name_real call.
2020-08-14 10:54:53 -07:00
Nathan Sidwell
4c58a32f47 c++: More simplification of name_lookup api
Continuing fixing name lookup's API we have two parameters saying what
we'd like to find 'prefer_type', which is a tri-valued boolan with
meaning 'don't care', 'type or namespace', 'type or death'.  And we
have a second parameter 'namespaces_only', which means 'namespace or
death'.  There are only 4 states, because the latter one has priority.
Firstly 'prefer_type' isn't really the right name -- it's not a preference,
it's a requirement.  Name lookup maps those two parameters into 2 LOOKUP_
bits.  We can simply have callers express that desire directly.

So this adds another enum class, LOOK_want, which expresses all
those options in 2 bits.  Most of this patch is then the expected fallout
from such a change.  The parser was mapping its internal state into
a prefer_type value, which was then mapped into the LOOKUP_ bits. So this
saves a conversion there.  Also the parser's conversion routine had an
'is_template' flag, which was only ever true in one place, where the parser
also had to deal with other nuances of the flags to pass.  So just drop
that parm and deal with it at the call site too.

I've left LOOKUP_HIDDEN alone for the moment.  That'll be next.

	gcc/cp/
	* cp-tree.h (LOOKUP_PREFER_TYPES, LOOKUP_PREFER_NAMESPACES)
	(LOOKUP_NAMESPACES_ONLY, LOOKUP_TYPES_ONLY)
	(LOOKUP_QUALIFIERS_ONL): Delete.
	(LOOKUP_HIDDEN): Adjust.
	* name-lookup.h (enum class LOOK_want): New.
	(operator|, operator&): Overloads for it.
	(lookup_name_real): Replace prefer_type & namespaces_only with
	LOOK_want parm.
	(lookup_qualified_name): Replace prefer_type with LOOK_want.
	(lookup_name_prefer_type): Replace with ...
	(lookup_name): ... this.  New overload with LOOK_want parm.
	* name-lookup.c (struct name_lookup): Replace flags with want and
	hidden fields.  Adjust constructors.
	(name_lookyp::add_overload): Correct hidden stripping test.  Update
	for new LOOK_want type.
	(name_lookup::process_binding): Likewise.
	(name_lookup::search_unqualified): Use hidden flag.
	(identifier_type_value_1): Adjust lookup_name_real call.
	(set_decl_namespace): Adjust name_lookup ctor.
	(lookup_flags): Delete.
	(qualify_lookup): Add LOOK_want parm, adjust.
	(lookup_qualified_name): Replace prefer_type parm with LOOK_want.
	(lookup_name_real_1): Replace prefer_type and namespaces_only with
	LOOK_want parm.
	(lookup_name_real): Likewise.
	(lookup_name_nonclass, lookup_name): Adjust lookup_name_real call.
	(lookup_name_prefer_type): Rename to ...
	(lookup_name): ... here.  New overload with LOOK_want parm.
	(lookup_type_scope_1): Adjust qualify_lookup calls.
	* call.c (build_operator_new_call)
	(add_operator_candidates): Adjust lookup_name_real calls.
	* coroutines.cc (find_coro_traits_template_decl)
	(find_coro_handle_template_decl, morph_fn_to_coro): Adjust
	lookup_qualified_name calls.
	* cp-objcp-common.c (identifier_global_tag): Likewise.
	* decl.c (get_tuple_size, get_tuple_decomp_init): Likewise.
	(lookup_and_check_tag): Use lookup_name overload.
	* parser.c (cp_parser_userdef_numeric_literal): Adjust
	lookup_qualified_name call.
	(prefer_arg_type): Drop template_mem_access parm, return LOOK_want
	value.
	(cp_parser_lookup_name): Adjust lookup_member, lookup_name_real
	calls.
	* pt.c (check_explicit_specialization): Adjust lookup_qualified_name
	call.
	(tsubst_copy_and_build, tsubst_qualified_name): Likewise
	(deduction_guides_for): Likewise.
	(tsubst_friend_class): Adjust lookup_name_real call.
	(lookup_init_capture, tsubst_expr): Likewise.
	* rtti.c (emit_support_tinfos): Adjust lookup_qualified_name call.
	* semantics.c (omp_reduction_lookup): Likewise.
	(capture_decltype): Adjust lookup_name_real call.
	libcc1/
	* libcp1plugin.cc (plugin_build_dependent_expr): Adjust
	lookup_name_real & lookup_qualified_name calls.
2020-08-14 07:44:46 -07:00
Nathan Sidwell
0c5f6bbfe2 [c++]: Unconfuse lookup_name_real API a bit
The API for lookup_name_real is really confusing.  This addresses the part
where we have NONCLASS to say DON'T search class scopes, and BLOCK_P to say
DO search block scopes.  I've added a single bitmask to explicitly say which
scopes to search.  I used an enum class so one can't accidentally misorder
it.  It's also reordered so we don't mix it up with the parameters that say
what kind of thing we're looking for.

	gcc/cp/
	* name-lookup.h (enum class LOOK_where): New.
	(operator|, operator&): Overloads for it.
	(lookup_name_real): Replace NONCLASS & BLOCK_P parms with WHERE.
	* name-lookup.c (identifier_type_value_w): Adjust
	lookup_name_real call.
	(lookup_name_real_1): Replace NONCLASS and BLOCK_P parameters
	with WHERE bitmask. Don't search namespaces if not asked to.
	(lookup_name_real): Adjust lookup_name_real_1 call.
	(lookup_name_nonclass, lookup_name)
	(lookup_name_prefer_type): Likewise.
	* call.c (build_operator_new_call)
	(add_operator_candidates): Adjust lookup_name_real calls.
	* parser.c (cp_parser_lookup_name): Likewise.
	* pt.c (tsubst_friend_class, lookup_init_capture_pack)
	(tsubst_expr): Likewise.
	* semantics.c (capture_decltype): Likewise.
	libcc1/
	* libcp1plugin.cc (plugin_build_dependent_expr): Likewise.
2020-08-13 11:16:42 -07:00
Nathan Sidwell
cc3ae9f5c4 c++: Tweak function cloning names
On the modules branch I need to expose an intermediate step of the
function cloning, but before that it'd be nice to rationalize the
names somewhat, now that we also use that API for copying the equality
operator.  Jason's recent patch caused me some pain by altering the
same code.  I can only blame myself for not pushing some bits sooner.
Anyway, this patch makes the newly renamed copy_fndecl_with_name
static, and adds a wrapper copy_operator_fn, that takes an operator
code.  The cdtor cloning functions are renamed to explicitly note they
expect cdtors.  A followup patch will move some of the logic from
copy_fndecl_with_name to build_cdtor_clones.

gcc/cp/
	* cp-tree.h (copy_fndecl_with_name): Rename to ...
	(copy_operatorn_fn): ... this.  Change arg type.
	(clone_function_decl): Rename to ...
	(clone_cdtor): ... this.
	* class.c (copy_fndecl_with_name): Make static.
	(copy_operator_fn): New wrapper.
	(build_clones): Rename to ...
	(build_cdtor_clones): ... this.
	(clone_function_decl): Rename to ...
	(clone_cdtor): ... this.  Adjust build_clones calls.
	(clone_constructors_and_destructors): Adjust clone_function_decl
	calls.
	* method.c (implicitly_declare_fn): Adjust copy_fndecl_with_name
	call.
	(lazily_declare_fn): Adjust clone_function_decl call.
	* pt.c (tsubst_function_decl): Likewise.
	(instantiate_template_1): Likewise.

libcc1/
	* libcp1plugin.cc (plugin_build_decl): Adjust clone_function_decl
	call.
2020-06-30 10:50:05 -07:00
Patrick Palka
a6ee556c76 c++: Fix return type deduction with an abbreviated function template
This patch fixes two issues with return type deduction in the presence of an
abbreviated function template.

The first issue (PR 69448) is that if a placeholder auto return type contains
any modifiers such as & or *, then the abbreviated function template
compensation in splice_late_return_type does not get performed for the
underlying auto node, leading to incorrect return type deduction.  This happens
because splice_late_return_type does not consider that a placeholder auto return
type might have modifiers.  To fix this it seems we need to look through
modifiers in the return type to obtain the location of the underlying auto node
in order to replace it with the adjusted auto node.  To that end this patch
refactors the utility function find_type_usage to return a pointer to the
matched tree, and uses it to find and replace the underlying auto node.

The second issue (PR 80471) is that the AUTO_IS_DECLTYPE flag is not being
preserved in splice_late_return_type when compensating for an abbreviated
function template, leading to us treating a decltype(auto) return type as if it
was an auto return type.  Fixed by making make_auto_1 set the AUTO_IS_DECLTYPE
flag whenever we're building a decltype(auto) node and adjusting callers
appropriately.  The test for PR 80471 is adjusted to expect the correct
behavior.

gcc/cp/ChangeLog:

	PR c++/69448
	PR c++/80471
	* type-utils.h (find_type_usage): Refactor to take a tree * and to
	return a tree *, and update documentation accordingly.
	* pt.c (make_auto_1): Set AUTO_IS_DECLTYPE when building a
	decltype(auto) node.
	(make_constrained_decltype_auto): No need to explicitly set
	AUTO_IS_DECLTYPE anymore.
	(splice_late_return_type): Use find_type_usage to find and
	replace a possibly nested auto node instead of using is_auto.
	Check test for is_auto into an assert when deciding whether
	to late_return_type.
	(type_uses_auto): Adjust the call to find_type_usage.
	* parser.c (cp_parser_decltype): No need to explicitly set
	AUTO_IS_DECLTYPE anymore.

libcc1/ChangeLog:

	PR c++/69448
	PR c++/80471
	* libcp1plugin.cc (plugin_get_expr_type): No need to explicitly set
	AUTO_IS_DECLTYPE anymore.

gcc/testsuite/ChangeLog:

	PR c++/69448
	PR c++/80471
	* g++.dg/concepts/abbrev3.C: New test.
	* g++.dg/cpp2a/concepts-pr80471.C: Adjust a static_assert to expect the
	correct behavior.
	* g++.dg/cpp0x/auto9.C: Adjust a dg-error directive.
2020-02-10 20:43:53 -05:00
Paolo Carlini
87d3f828de init.c (build_new): Add location_t parameter and use it throughout.
/gcc/cp
2020-01-07  Paolo Carlini  <paolo.carlini@oracle.com>

	* init.c (build_new): Add location_t parameter and use it throughout.
	(build_raw_new_expr): Likewise.
	* parser.c (cp_parser_new_expression): Pass the combined_loc.
	* pt.c (tsubst_copy_and_build): Adjust call.
	* cp-tree.h: Update declarations.

/libcc1
2020-01-07  Paolo Carlini  <paolo.carlini@oracle.com>

	* libcp1plugin.cc (plugin_build_new_expr): Update build_new call.

/gcc/testsuite
2020-01-07  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.old-deja/g++.bugs/900208_03.C: Check locations too.
	* g++.old-deja/g++.bugs/900519_06.C: Likewise.

From-SVN: r279963
2020-01-07 17:58:18 +00:00
Jakub Jelinek
8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
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