mirror of git://gcc.gnu.org/git/gcc.git
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
This commit is contained in:
parent
c7dc8804a8
commit
7eda336814
|
@ -1,3 +1,9 @@
|
||||||
|
2011-03-25 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/48289
|
||||||
|
* pt.c (build_non_dependent_expr): Keep dereferences outside the
|
||||||
|
NON_DEPENDENT_EXPR.
|
||||||
|
|
||||||
2011-03-25 Kai Tietz <ktietz@redhat.com>
|
2011-03-25 Kai Tietz <ktietz@redhat.com>
|
||||||
|
|
||||||
* decl.c (decls_match): Replace target hook
|
* decl.c (decls_match): Replace target hook
|
||||||
|
|
23
gcc/cp/pt.c
23
gcc/cp/pt.c
|
@ -18846,24 +18846,17 @@ build_non_dependent_expr (tree expr)
|
||||||
TREE_OPERAND (expr, 0),
|
TREE_OPERAND (expr, 0),
|
||||||
build_non_dependent_expr (TREE_OPERAND (expr, 1)));
|
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 */
|
/* If the type is unknown, it can't really be non-dependent */
|
||||||
gcc_assert (TREE_TYPE (expr) != unknown_type_node);
|
gcc_assert (TREE_TYPE (expr) != unknown_type_node);
|
||||||
|
|
||||||
/* Otherwise, build a NON_DEPENDENT_EXPR.
|
/* Otherwise, build a NON_DEPENDENT_EXPR. */
|
||||||
|
return build1 (NON_DEPENDENT_EXPR, TREE_TYPE (expr), expr);
|
||||||
REFERENCE_TYPEs are not stripped for expressions in templates
|
|
||||||
because doing so would play havoc with mangling. Consider, for
|
|
||||||
example:
|
|
||||||
|
|
||||||
template <typename T> void f<T& g>() { 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<g>" 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.
|
/* ARGS is a vector of expressions as arguments to a function call.
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2011-03-25 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
* g++.dg/cpp0x/move1.C: New.
|
||||||
|
|
||||||
2011-03-25 Ira Rosen <ira.rosen@linaro.org>
|
2011-03-25 Ira Rosen <ira.rosen@linaro.org>
|
||||||
|
|
||||||
PR target/48287
|
PR target/48287
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
// { dg-options "-std=c++0x -pedantic-errors" }
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
class A { };
|
||||||
|
|
||||||
|
static void g ( A && ) { }
|
||||||
|
|
||||||
|
template < class T > class B {
|
||||||
|
public:
|
||||||
|
void f ( ) {
|
||||||
|
A a;
|
||||||
|
g ( std :: move ( a ) );
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue