Commit 2d660b7f by Jason Merrill Committed by Jason Merrill

pt.c (dependent_scope_ref_p): Remove.

	* pt.c (dependent_scope_ref_p): Remove.
	(value_dependent_expression_p): Don't call it.
	(type_dependent_expression_p): Here either.
	* init.c (build_offset_ref): Set TREE_TYPE on a qualified-id
	if the scope isn't dependent.

	* pt.c (convert_nontype_argument): Use mark_lvalue_use if we want
	a reference.

From-SVN: r161560
parent d3a79fcc
2010-06-29 Jason Merrill <jason@redhat.com> 2010-06-29 Jason Merrill <jason@redhat.com>
* pt.c (dependent_scope_ref_p): Remove.
(value_dependent_expression_p): Don't call it.
(type_dependent_expression_p): Here either.
* init.c (build_offset_ref): Set TREE_TYPE on a qualified-id
if the scope isn't dependent.
* pt.c (convert_nontype_argument): Use mark_lvalue_use if we want
a reference.
PR c++/44587 PR c++/44587
* pt.c (has_value_dependent_address): New. * pt.c (has_value_dependent_address): New.
(value_dependent_expression_p): Check it. (value_dependent_expression_p): Check it.
......
...@@ -1508,8 +1508,17 @@ build_offset_ref (tree type, tree member, bool address_p) ...@@ -1508,8 +1508,17 @@ build_offset_ref (tree type, tree member, bool address_p)
return member; return member;
if (dependent_type_p (type) || type_dependent_expression_p (member)) if (dependent_type_p (type) || type_dependent_expression_p (member))
return build_qualified_name (NULL_TREE, type, member, {
/*template_p=*/false); tree ref, mem_type = NULL_TREE;
if (!dependent_scope_p (type))
mem_type = TREE_TYPE (member);
ref = build_qualified_name (mem_type, type, member,
/*template_p=*/false);
/* Undo convert_from_reference. */
if (TREE_CODE (ref) == INDIRECT_REF)
ref = TREE_OPERAND (ref, 0);
return ref;
}
gcc_assert (TYPE_P (type)); gcc_assert (TYPE_P (type));
if (! is_class_type (type, 1)) if (! is_class_type (type, 1))
......
...@@ -4968,7 +4968,10 @@ convert_nontype_argument (tree type, tree expr) ...@@ -4968,7 +4968,10 @@ convert_nontype_argument (tree type, tree expr)
if (error_operand_p (expr)) if (error_operand_p (expr))
return error_mark_node; return error_mark_node;
expr_type = TREE_TYPE (expr); expr_type = TREE_TYPE (expr);
expr = mark_rvalue_use (expr); if (TREE_CODE (type) == REFERENCE_TYPE)
expr = mark_lvalue_use (expr);
else
expr = mark_rvalue_use (expr);
/* HACK: Due to double coercion, we can get a /* HACK: Due to double coercion, we can get a
NOP_EXPR<REFERENCE_TYPE>(ADDR_EXPR<POINTER_TYPE> (arg)) here, NOP_EXPR<REFERENCE_TYPE>(ADDR_EXPR<POINTER_TYPE> (arg)) here,
...@@ -17517,40 +17520,6 @@ dependent_scope_p (tree scope) ...@@ -17517,40 +17520,6 @@ dependent_scope_p (tree scope)
&& !currently_open_class (scope)); && !currently_open_class (scope));
} }
/* Returns TRUE if EXPRESSION is dependent, according to CRITERION. */
static bool
dependent_scope_ref_p (tree expression, bool criterion (tree))
{
tree scope;
tree name;
gcc_assert (TREE_CODE (expression) == SCOPE_REF);
if (!TYPE_P (TREE_OPERAND (expression, 0)))
return true;
scope = TREE_OPERAND (expression, 0);
name = TREE_OPERAND (expression, 1);
/* [temp.dep.expr]
An id-expression is type-dependent if it contains a
nested-name-specifier that contains a class-name that names a
dependent type. */
/* The suggested resolution to Core Issue 224 implies that if the
qualifying type is the current class, then we must peek
inside it. */
if (DECL_P (name)
&& currently_open_class (scope)
&& !criterion (name))
return false;
if (dependent_type_p (scope))
return true;
return false;
}
/* Returns TRUE if the EXPRESSION is value-dependent, in the sense of /* Returns TRUE if the EXPRESSION is value-dependent, in the sense of
[temp.dep.constexpr]. EXPRESSION is already known to be a constant [temp.dep.constexpr]. EXPRESSION is already known to be a constant
expression. */ expression. */
...@@ -17640,7 +17609,10 @@ value_dependent_expression_p (tree expression) ...@@ -17640,7 +17609,10 @@ value_dependent_expression_p (tree expression)
|| value_dependent_expression_p (expression)); || value_dependent_expression_p (expression));
case SCOPE_REF: case SCOPE_REF:
return dependent_scope_ref_p (expression, value_dependent_expression_p); {
tree name = TREE_OPERAND (expression, 1);
return value_dependent_expression_p (name);
}
case COMPONENT_REF: case COMPONENT_REF:
return (value_dependent_expression_p (TREE_OPERAND (expression, 0)) return (value_dependent_expression_p (TREE_OPERAND (expression, 0))
...@@ -17783,10 +17755,19 @@ type_dependent_expression_p (tree expression) ...@@ -17783,10 +17755,19 @@ type_dependent_expression_p (tree expression)
return dependent_type_p (type); return dependent_type_p (type);
} }
if (TREE_CODE (expression) == SCOPE_REF if (TREE_CODE (expression) == SCOPE_REF)
&& dependent_scope_ref_p (expression, {
type_dependent_expression_p)) tree scope = TREE_OPERAND (expression, 0);
return true; tree name = TREE_OPERAND (expression, 1);
/* 14.6.2.2 [temp.dep.expr]: An id-expression is type-dependent if it
contains an identifier associated by name lookup with one or more
declarations declared with a dependent type, or...a
nested-name-specifier or qualified-id that names a member of an
unknown specialization. */
return (type_dependent_expression_p (name)
|| dependent_scope_p (scope));
}
if (TREE_CODE (expression) == FUNCTION_DECL if (TREE_CODE (expression) == FUNCTION_DECL
&& DECL_LANG_SPECIFIC (expression) && DECL_LANG_SPECIFIC (expression)
......
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