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,
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. */
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. */
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 "
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.
--- /dev/null
+// 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>();
+}