From b788d659bb840088b06fd6c8e29830daefd121d7 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 28 Mar 2011 11:06:28 -0400 Subject: [PATCH] revert: re PR c++/48289 (-pedantic breaks std::move) Revert: PR c++/48289 * pt.c (build_non_dependent_expr): Keep dereferences outside the NON_DEPENDENT_EXPR. From-SVN: r171607 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/pt.c | 23 +++++++++++++++-------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/move1.C | 15 --------------- 4 files changed, 27 insertions(+), 23 deletions(-) delete mode 100644 gcc/testsuite/g++.dg/cpp0x/move1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a6b681f878e7..7a4d367ce555 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2011-03-28 Jason Merrill + + Revert: + PR c++/48289 + * pt.c (build_non_dependent_expr): Keep dereferences outside the + NON_DEPENDENT_EXPR. + 2011-03-25 Jason Merrill PR c++/48289 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bb93667b82df..f458f38a8c36 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -18273,17 +18273,24 @@ 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. */ - return build1 (NON_DEPENDENT_EXPR, TREE_TYPE (expr), expr); + /* 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); } /* ARGS is a vector of expressions as arguments to a function call. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c51ab21dc45e..88ab1cdc3cd1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-03-28 Jason Merrill + + Revert: + * g++.dg/cpp0x/move1.C: New. + 2011-03-28 Richard Sandiford PR target/47553 diff --git a/gcc/testsuite/g++.dg/cpp0x/move1.C b/gcc/testsuite/g++.dg/cpp0x/move1.C deleted file mode 100644 index 12e363a8cabe..000000000000 --- a/gcc/testsuite/g++.dg/cpp0x/move1.C +++ /dev/null @@ -1,15 +0,0 @@ -// { dg-options "-std=c++0x -pedantic-errors" } - -#include - -class A { }; - -static void g ( A && ) { } - -template < class T > class B { -public: - void f ( ) { - A a; - g ( std :: move ( a ) ); - } -}; -- 2.47.2