+2011-05-31 Jason Merrill <jason@redhat.com>
+
+ PR c++/44870
+ * tree.c (lvalue_kind): Recurse on NON_DEPENDENT_EXPR. Handle
+ ARROW_EXPR, TYPEID_EXPR, and arbitrary class-valued expressions.
+ (build_min_non_dep): Preserve reference refs.
+ (build_min_non_dep_call_vec): Likewise
+
2011-05-30 Jakub Jelinek <jakub@redhat.com>
PR c++/49223
&& DECL_IN_AGGR_P (ref))
return clk_none;
case INDIRECT_REF:
+ case ARROW_EXPR:
case ARRAY_REF:
case PARM_DECL:
case RESULT_DECL:
break;
case MODIFY_EXPR:
+ case TYPEID_EXPR:
return clk_ordinary;
case COMPOUND_EXPR:
return (CLASS_TYPE_P (TREE_TYPE (ref)) ? clk_class : clk_none);
case CALL_EXPR:
- /* Any class-valued call would be wrapped in a TARGET_EXPR. */
+ /* We can see calls outside of TARGET_EXPR in templates. */
+ if (CLASS_TYPE_P (TREE_TYPE (ref)))
+ return clk_class;
return clk_none;
case FUNCTION_DECL:
return lvalue_kind (BASELINK_FUNCTIONS (CONST_CAST_TREE (ref)));
case NON_DEPENDENT_EXPR:
- /* We must consider NON_DEPENDENT_EXPRs to be lvalues so that
- things like "&E" where "E" is an expression with a
- non-dependent type work. It is safe to be lenient because an
- error will be issued when the template is instantiated if "E"
- is not an lvalue. */
- return clk_ordinary;
+ /* We used to just return clk_ordinary for NON_DEPENDENT_EXPR because
+ it was safe enough for C++98, but in C++0x lvalues don't bind to
+ rvalue references, so we get bogus errors (c++/44870). */
+ return lvalue_kind (TREE_OPERAND (ref, 0));
default:
+ if (!TREE_TYPE (ref))
+ return clk_none;
+ if (CLASS_TYPE_P (TREE_TYPE (ref)))
+ return clk_class;
break;
}
va_start (p, non_dep);
+ if (REFERENCE_REF_P (non_dep))
+ non_dep = TREE_OPERAND (non_dep, 0);
+
t = make_node (code);
length = TREE_CODE_LENGTH (code);
TREE_TYPE (t) = TREE_TYPE (non_dep);
COMPOUND_EXPR_OVERLOADED (t) = 1;
va_end (p);
- return t;
+ return convert_from_reference (t);
}
/* Similar to `build_nt_call_vec', but for template definitions of
build_min_non_dep_call_vec (tree non_dep, tree fn, VEC(tree,gc) *argvec)
{
tree t = build_nt_call_vec (fn, argvec);
+ if (REFERENCE_REF_P (non_dep))
+ non_dep = TREE_OPERAND (non_dep, 0);
TREE_TYPE (t) = TREE_TYPE (non_dep);
TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (non_dep);
- return t;
+ return convert_from_reference (t);
}
tree