Commit 31e292c7 by Jason Merrill Committed by Jason Merrill

cp-tree.h (REFERENCE_REF_P): Just check the type.

	* cp-tree.h (REFERENCE_REF_P): Just check the type.
	* cvt.c (convert_from_reference): Adjust.
	* pt.c (build_non_dependent_expr): Adjust.
	* semantics.c (finish_offsetof): Adjust.
	* tree.c (lvalue_kind): Use it.

From-SVN: r173449
parent 013c0411
2011-05-05 Jason Merrill <jason@redhat.com> 2011-05-05 Jason Merrill <jason@redhat.com>
* cp-tree.h (REFERENCE_REF_P): Just check the type.
* cvt.c (convert_from_reference): Adjust.
* pt.c (build_non_dependent_expr): Adjust.
* semantics.c (finish_offsetof): Adjust.
* tree.c (lvalue_kind): Use it.
PR c++/48873 PR c++/48873
* tree.c (stabilize_expr): Don't make gratuitous copies of classes. * tree.c (stabilize_expr): Don't make gratuitous copies of classes.
......
...@@ -62,7 +62,6 @@ c-common.h, not after. ...@@ -62,7 +62,6 @@ c-common.h, not after.
STMT_EXPR_NO_SCOPE (in STMT_EXPR) STMT_EXPR_NO_SCOPE (in STMT_EXPR)
BIND_EXPR_TRY_BLOCK (in BIND_EXPR) BIND_EXPR_TRY_BLOCK (in BIND_EXPR)
TYPENAME_IS_ENUM_P (in TYPENAME_TYPE) TYPENAME_IS_ENUM_P (in TYPENAME_TYPE)
REFERENCE_REF_P (in INDIRECT_EXPR)
QUALIFIED_NAME_IS_TEMPLATE (in SCOPE_REF) QUALIFIED_NAME_IS_TEMPLATE (in SCOPE_REF)
OMP_FOR_GIMPLIFYING_P (in OMP_FOR) OMP_FOR_GIMPLIFYING_P (in OMP_FOR)
BASELINK_QUALIFIED_P (in BASELINK) BASELINK_QUALIFIED_P (in BASELINK)
...@@ -2781,9 +2780,12 @@ extern void decl_shadowed_for_var_insert (tree, tree); ...@@ -2781,9 +2780,12 @@ extern void decl_shadowed_for_var_insert (tree, tree);
(LANG_DECL_FN_CHECK (FUNCTION_DECL_CHECK (NODE)) \ (LANG_DECL_FN_CHECK (FUNCTION_DECL_CHECK (NODE)) \
->u.saved_language_function) ->u.saved_language_function)
/* Indicates an indirect_expr is for converting a reference. */ /* True if NODE is an implicit INDIRECT_EXPR from convert_from_reference. */
#define REFERENCE_REF_P(NODE) \ #define REFERENCE_REF_P(NODE) \
TREE_LANG_FLAG_0 (INDIRECT_REF_CHECK (NODE)) (TREE_CODE (NODE) == INDIRECT_REF \
&& TREE_TYPE (TREE_OPERAND (NODE, 0)) \
&& (TREE_CODE (TREE_TYPE (TREE_OPERAND ((NODE), 0))) \
== REFERENCE_TYPE))
#define NEW_EXPR_USE_GLOBAL(NODE) \ #define NEW_EXPR_USE_GLOBAL(NODE) \
TREE_LANG_FLAG_0 (NEW_EXPR_CHECK (NODE)) TREE_LANG_FLAG_0 (NEW_EXPR_CHECK (NODE))
......
...@@ -520,7 +520,6 @@ convert_from_reference (tree val) ...@@ -520,7 +520,6 @@ convert_from_reference (tree val)
TREE_THIS_VOLATILE (ref) = CP_TYPE_VOLATILE_P (t); TREE_THIS_VOLATILE (ref) = CP_TYPE_VOLATILE_P (t);
TREE_SIDE_EFFECTS (ref) TREE_SIDE_EFFECTS (ref)
= (TREE_THIS_VOLATILE (ref) || TREE_SIDE_EFFECTS (val)); = (TREE_THIS_VOLATILE (ref) || TREE_SIDE_EFFECTS (val));
REFERENCE_REF_P (ref) = 1;
val = ref; val = ref;
} }
......
...@@ -18918,7 +18918,7 @@ build_non_dependent_expr (tree expr) ...@@ -18918,7 +18918,7 @@ build_non_dependent_expr (tree expr)
/* Keep dereferences outside the NON_DEPENDENT_EXPR so lvalue_kind /* Keep dereferences outside the NON_DEPENDENT_EXPR so lvalue_kind
doesn't need to look inside. */ doesn't need to look inside. */
if (TREE_CODE (expr) == INDIRECT_REF && REFERENCE_REF_P (expr)) if (REFERENCE_REF_P (expr))
return convert_from_reference (build_non_dependent_expr return convert_from_reference (build_non_dependent_expr
(TREE_OPERAND (expr, 0))); (TREE_OPERAND (expr, 0)));
......
...@@ -3428,7 +3428,7 @@ finish_offsetof (tree expr) ...@@ -3428,7 +3428,7 @@ finish_offsetof (tree expr)
error ("cannot apply %<offsetof%> to member function %qD", expr); error ("cannot apply %<offsetof%> to member function %qD", expr);
return error_mark_node; return error_mark_node;
} }
if (TREE_CODE (expr) == INDIRECT_REF && REFERENCE_REF_P (expr)) if (REFERENCE_REF_P (expr))
expr = TREE_OPERAND (expr, 0); expr = TREE_OPERAND (expr, 0);
return fold_offsetof (expr, NULL_TREE); return fold_offsetof (expr, NULL_TREE);
} }
......
...@@ -61,9 +61,7 @@ lvalue_kind (const_tree ref) ...@@ -61,9 +61,7 @@ lvalue_kind (const_tree ref)
INDIRECT_REFs. INDIRECT_REFs are just internal compiler INDIRECT_REFs. INDIRECT_REFs are just internal compiler
representation, not part of the language, so we have to look representation, not part of the language, so we have to look
through them. */ through them. */
if (TREE_CODE (ref) == INDIRECT_REF if (REFERENCE_REF_P (ref))
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 0)))
== REFERENCE_TYPE)
return lvalue_kind (TREE_OPERAND (ref, 0)); return lvalue_kind (TREE_OPERAND (ref, 0));
if (TREE_TYPE (ref) if (TREE_TYPE (ref)
......
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