From 7eda336814b5c8d3ed37b4f9055889c6651eb1bb Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 25 Mar 2011 12:16:53 -0400 Subject: re PR c++/48289 (-pedantic breaks std::move) PR c++/48289 * pt.c (build_non_dependent_expr): Keep dereferences outside the NON_DEPENDENT_EXPR. From-SVN: r171461 --- gcc/cp/pt.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'gcc/cp/pt.c') diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c8c1010..9032dd9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -18846,24 +18846,17 @@ build_non_dependent_expr (tree expr) TREE_OPERAND (expr, 0), build_non_dependent_expr (TREE_OPERAND (expr, 1))); + /* Keep dereferences outside the NON_DEPENDENT_EXPR so lvalue_kind + doesn't need to look inside. */ + if (TREE_CODE (expr) == INDIRECT_REF && REFERENCE_REF_P (expr)) + return convert_from_reference (build_non_dependent_expr + (TREE_OPERAND (expr, 0))); + /* If the type is unknown, it can't really be non-dependent */ gcc_assert (TREE_TYPE (expr) != unknown_type_node); - /* Otherwise, build a NON_DEPENDENT_EXPR. - - REFERENCE_TYPEs are not stripped for expressions in templates - because doing so would play havoc with mangling. Consider, for - example: - - template void f() { g(); } - - In the body of "f", the expression for "g" will have - REFERENCE_TYPE, even though the standard says that it should - not. The reason is that we must preserve the syntactic form of - the expression so that mangling (say) "f" inside the body of - "f" works out correctly. Therefore, the REFERENCE_TYPE is - stripped here. */ - return build1 (NON_DEPENDENT_EXPR, non_reference (TREE_TYPE (expr)), expr); + /* Otherwise, build a NON_DEPENDENT_EXPR. */ + return build1 (NON_DEPENDENT_EXPR, TREE_TYPE (expr), expr); } /* ARGS is a vector of expressions as arguments to a function call. -- cgit v1.1