aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r--gcc/cp/pt.c61
1 files changed, 21 insertions, 40 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 8a447ec157d..e4b57dbfeaf 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4968,7 +4968,10 @@ convert_nontype_argument (tree type, tree expr)
if (error_operand_p (expr))
return error_mark_node;
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
NOP_EXPR<REFERENCE_TYPE>(ADDR_EXPR<POINTER_TYPE> (arg)) here,
@@ -17517,40 +17520,6 @@ dependent_scope_p (tree 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
[temp.dep.constexpr]. EXPRESSION is already known to be a constant
expression. */
@@ -17640,7 +17609,10 @@ value_dependent_expression_p (tree expression)
|| value_dependent_expression_p (expression));
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:
return (value_dependent_expression_p (TREE_OPERAND (expression, 0))
@@ -17783,10 +17755,19 @@ type_dependent_expression_p (tree expression)
return dependent_type_p (type);
}
- if (TREE_CODE (expression) == SCOPE_REF
- && dependent_scope_ref_p (expression,
- type_dependent_expression_p))
- return true;
+ if (TREE_CODE (expression) == SCOPE_REF)
+ {
+ tree scope = TREE_OPERAND (expression, 0);
+ 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
&& DECL_LANG_SPECIFIC (expression)