aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-06-29 19:29:14 +0000
committerJason Merrill <jason@redhat.com>2010-06-29 19:29:14 +0000
commit4618756d6895eb42dddd581ba81fbbe51d7b9e6a (patch)
tree1cee90d7adcb1a68d03b6523fff76da550dcac0e
parenta59ed750963fffe0cfde92e08fa078b0be52d884 (diff)
* 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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@161560 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/init.c13
-rw-r--r--gcc/cp/pt.c61
3 files changed, 41 insertions, 42 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index da75d0498b6..0f88f2b6781 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,14 @@
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
* pt.c (has_value_dependent_address): New.
(value_dependent_expression_p): Check it.
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 30808b233ce..7df57ab9e98 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1508,8 +1508,17 @@ build_offset_ref (tree type, tree member, bool address_p)
return 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));
if (! is_class_type (type, 1))
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)