DR 1207 PR c++/49589
DR 1207 PR c++/49589 * mangle.c (write_expression): Handle 'this'. * parser.c (cp_parser_postfix_dot_deref_expression): Allow incomplete *this. * semantics.c (potential_constant_expression_1): Check that DECL_CONTEXT is set on 'this'. From-SVN: r175835
This commit is contained in:
parent
21d69a5bb0
commit
f2fe30af83
6 changed files with 45 additions and 2 deletions
|
@ -1,5 +1,13 @@
|
|||
2011-07-04 Jason Merrill <jason@redhat.com>
|
||||
|
||||
DR 1207
|
||||
PR c++/49589
|
||||
* mangle.c (write_expression): Handle 'this'.
|
||||
* parser.c (cp_parser_postfix_dot_deref_expression): Allow
|
||||
incomplete *this.
|
||||
* semantics.c (potential_constant_expression_1): Check that
|
||||
DECL_CONTEXT is set on 'this'.
|
||||
|
||||
* error.c (dump_template_bindings): Don't print typenames
|
||||
for a partial instantiation.
|
||||
(dump_function_decl): If we aren't printing function arguments,
|
||||
|
|
|
@ -2495,6 +2495,11 @@ write_expression (tree expr)
|
|||
else if (TREE_CODE_CLASS (code) == tcc_constant
|
||||
|| (abi_version_at_least (2) && code == CONST_DECL))
|
||||
write_template_arg_literal (expr);
|
||||
else if (code == PARM_DECL && DECL_ARTIFICIAL (expr))
|
||||
{
|
||||
gcc_assert (!strcmp ("this", IDENTIFIER_POINTER (DECL_NAME (expr))));
|
||||
write_string ("fpT");
|
||||
}
|
||||
else if (code == PARM_DECL)
|
||||
{
|
||||
/* A function parameter used in a late-specified return type. */
|
||||
|
|
|
@ -5281,7 +5281,11 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser,
|
|||
postfix_expression);
|
||||
scope = NULL_TREE;
|
||||
}
|
||||
else
|
||||
/* Unlike the object expression in other contexts, *this is not
|
||||
required to be of complete type for purposes of class member
|
||||
access (5.2.5) outside the member function body. */
|
||||
else if (scope != current_class_ref
|
||||
&& !(processing_template_decl && scope == current_class_type))
|
||||
scope = complete_type_or_else (scope, NULL_TREE);
|
||||
/* Let the name lookup machinery know that we are processing a
|
||||
class member access expression. */
|
||||
|
|
|
@ -7791,7 +7791,8 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
|
|||
STRIP_NOPS (x);
|
||||
if (is_this_parameter (x))
|
||||
{
|
||||
if (DECL_CONSTRUCTOR_P (DECL_CONTEXT (x)) && want_rval)
|
||||
if (want_rval && DECL_CONTEXT (x)
|
||||
&& DECL_CONSTRUCTOR_P (DECL_CONTEXT (x)))
|
||||
{
|
||||
if (flags & tf_error)
|
||||
sorry ("use of the value of the object being constructed "
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
2011-07-04 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* g++.dg/abi/mangle48.C: New.
|
||||
|
||||
* g++.dg/cpp0x/diag1.C: New.
|
||||
|
||||
* g++.dg/diagnostic/aka1.C: New.
|
||||
|
|
23
gcc/testsuite/g++.dg/abi/mangle48.C
Normal file
23
gcc/testsuite/g++.dg/abi/mangle48.C
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Testcase for 'this' mangling
|
||||
// { dg-options -std=c++0x }
|
||||
|
||||
struct B
|
||||
{
|
||||
template <class U> U f();
|
||||
};
|
||||
|
||||
struct A
|
||||
{
|
||||
B b;
|
||||
// { dg-final { scan-assembler "_ZN1A1fIiEEDTcldtdtdefpT1b1fIT_EEEv" } }
|
||||
template <class U> auto f() -> decltype (b.f<U>());
|
||||
// { dg-final { scan-assembler "_ZN1A1gIiEEDTcldtptfpT1b1fIT_EEEv" } }
|
||||
template <class U> auto g() -> decltype (this->b.f<U>());
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
a.f<int>();
|
||||
a.g<int>();
|
||||
}
|
Loading…
Add table
Reference in a new issue