Commit 1f0ed17c by Nathan Sidwell Committed by Nathan Sidwell

pt.c (tsubst_copy_and_build): Remove unnecessary COMPONENT_REF peeking.

	* pt.c (tsubst_copy_and_build): Remove unnecessary COMPONENT_REF
	peeking.
	* semantics.c (finish_id_expression): Directly init local var.
	(finish_omp_reduction_clause): Use really_overloaded_fn.
	* tree.c (get_fns): Document.  Assert we got an overload.
	(get_first_fn) Document.
	* typeck.c (cp_build_addr_expr_1): Pass arg directly to
	really_overloaded_fn.
	* typeck2.c (cxx_inomplete_type_diagnostic): Use get_first_fn directly.

From-SVN: r248106
parent 2c27a627
2017-05-16 Nathan Sidwell <nathan@acm.org> 2017-05-16 Nathan Sidwell <nathan@acm.org>
* pt.c (tsubst_copy_and_build): Remove unnecessary COMPONENT_REF
peeking.
* semantics.c (finish_id_expression): Directly init local var.
(finish_omp_reduction_clause): Use really_overloaded_fn.
* tree.c (get_fns): Document. Assert we got an overload.
(get_first_fn) Document.
* typeck.c (cp_build_addr_expr_1): Pass arg directly to
really_overloaded_fn.
* typeck2.c (cxx_inomplete_type_diagnostic): Use get_first_fn directly.
* cp-tree.h (SCOPE_DEPTH): New. * cp-tree.h (SCOPE_DEPTH): New.
* name-lookup.h (is_nested_namespace): Declare. * name-lookup.h (is_nested_namespace): Declare.
* name-lookup.c (is_nested_namespace): New. * name-lookup.c (is_nested_namespace): New.
......
...@@ -17187,10 +17187,9 @@ tsubst_copy_and_build (tree t, ...@@ -17187,10 +17187,9 @@ tsubst_copy_and_build (tree t,
if (diag) if (diag)
{ {
tree fn = unq; tree fn = unq;
if (INDIRECT_REF_P (fn)) if (INDIRECT_REF_P (fn))
fn = TREE_OPERAND (fn, 0); fn = TREE_OPERAND (fn, 0);
if (TREE_CODE (fn) == COMPONENT_REF)
fn = TREE_OPERAND (fn, 1);
if (is_overloaded_fn (fn)) if (is_overloaded_fn (fn))
fn = get_first_fn (fn); fn = get_first_fn (fn);
......
...@@ -3749,9 +3749,8 @@ finish_id_expression (tree id_expression, ...@@ -3749,9 +3749,8 @@ finish_id_expression (tree id_expression,
} }
else if (is_overloaded_fn (decl)) else if (is_overloaded_fn (decl))
{ {
tree first_fn; tree first_fn = get_first_fn (decl);
first_fn = get_first_fn (decl);
if (TREE_CODE (first_fn) == TEMPLATE_DECL) if (TREE_CODE (first_fn) == TEMPLATE_DECL)
first_fn = DECL_TEMPLATE_RESULT (first_fn); first_fn = DECL_TEMPLATE_RESULT (first_fn);
...@@ -5615,7 +5614,6 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor) ...@@ -5615,7 +5614,6 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
{ {
if (id == error_mark_node) if (id == error_mark_node)
return true; return true;
id = OVL_CURRENT (id);
mark_used (id); mark_used (id);
tree body = DECL_SAVED_TREE (id); tree body = DECL_SAVED_TREE (id);
if (!body) if (!body)
...@@ -6924,13 +6922,13 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) ...@@ -6924,13 +6922,13 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
{ {
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO_DECLARE) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO_DECLARE)
{ {
if (TREE_CODE (t) == OVERLOAD && OVL_CHAIN (t)) if (TREE_CODE (t) == TEMPLATE_ID_EXPR)
error_at (OMP_CLAUSE_LOCATION (c), error_at (OMP_CLAUSE_LOCATION (c),
"overloaded function name %qE in clause %qs", t, "template %qE in clause %qs", t,
omp_clause_code_name[OMP_CLAUSE_CODE (c)]); omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
else if (TREE_CODE (t) == TEMPLATE_ID_EXPR) else if (really_overloaded_fn (t))
error_at (OMP_CLAUSE_LOCATION (c), error_at (OMP_CLAUSE_LOCATION (c),
"template %qE in clause %qs", t, "overloaded function name %qE in clause %qs", t,
omp_clause_code_name[OMP_CLAUSE_CODE (c)]); omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
else else
error_at (OMP_CLAUSE_LOCATION (c), error_at (OMP_CLAUSE_LOCATION (c),
......
...@@ -2146,10 +2146,11 @@ really_overloaded_fn (tree x) ...@@ -2146,10 +2146,11 @@ really_overloaded_fn (tree x)
return is_overloaded_fn (x) == 2; return is_overloaded_fn (x) == 2;
} }
/* Get the overload set FROM refers to. */
tree tree
get_fns (tree from) get_fns (tree from)
{ {
gcc_assert (is_overloaded_fn (from));
/* A baselink is also considered an overloaded function. */ /* A baselink is also considered an overloaded function. */
if (TREE_CODE (from) == OFFSET_REF if (TREE_CODE (from) == OFFSET_REF
|| TREE_CODE (from) == COMPONENT_REF) || TREE_CODE (from) == COMPONENT_REF)
...@@ -2158,9 +2159,13 @@ get_fns (tree from) ...@@ -2158,9 +2159,13 @@ get_fns (tree from)
from = BASELINK_FUNCTIONS (from); from = BASELINK_FUNCTIONS (from);
if (TREE_CODE (from) == TEMPLATE_ID_EXPR) if (TREE_CODE (from) == TEMPLATE_ID_EXPR)
from = TREE_OPERAND (from, 0); from = TREE_OPERAND (from, 0);
gcc_assert (TREE_CODE (from) == OVERLOAD
|| TREE_CODE (from) == FUNCTION_DECL);
return from; return from;
} }
/* Return the first function of the overload set FROM refers to. */
tree tree
get_first_fn (tree from) get_first_fn (tree from)
{ {
......
...@@ -5603,7 +5603,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain) ...@@ -5603,7 +5603,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
gcc_assert (!identifier_p (arg) || !IDENTIFIER_OPNAME_P (arg)); gcc_assert (!identifier_p (arg) || !IDENTIFIER_OPNAME_P (arg));
if (TREE_CODE (arg) == COMPONENT_REF && type_unknown_p (arg) if (TREE_CODE (arg) == COMPONENT_REF && type_unknown_p (arg)
&& !really_overloaded_fn (TREE_OPERAND (arg, 1))) && !really_overloaded_fn (arg))
{ {
/* They're trying to take the address of a unique non-static /* They're trying to take the address of a unique non-static
member function. This is ill-formed (except in MS-land), member function. This is ill-formed (except in MS-land),
......
...@@ -506,9 +506,8 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value, ...@@ -506,9 +506,8 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
case OFFSET_TYPE: case OFFSET_TYPE:
bad_member: bad_member:
{ {
tree member = TREE_OPERAND (value, 1); tree member = get_first_fn (TREE_OPERAND (value, 1));
if (is_overloaded_fn (member))
member = get_first_fn (member);
if (DECL_FUNCTION_MEMBER_P (member) if (DECL_FUNCTION_MEMBER_P (member)
&& ! flag_ms_extensions) && ! flag_ms_extensions)
emit_diagnostic (diag_kind, loc, 0, emit_diagnostic (diag_kind, loc, 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment