aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-07-04 17:44:04 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-07-04 17:44:04 -0400
commitf2fe30af839aaa7d0ad617d739f22eae41181042 (patch)
treed5b50e32af7046054dd64b22084484f36bb8cbf9 /gcc
parent21d69a5bb0e06bd8876242c99001ad3b9c7946b1 (diff)
downloadgcc-f2fe30af839aaa7d0ad617d739f22eae41181042.zip
gcc-f2fe30af839aaa7d0ad617d739f22eae41181042.tar.gz
gcc-f2fe30af839aaa7d0ad617d739f22eae41181042.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/mangle.c5
-rw-r--r--gcc/cp/parser.c6
-rw-r--r--gcc/cp/semantics.c3
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/g++.dg/abi/mangle48.C23
6 files changed, 45 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7eb01d6..90a80ee 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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,
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 134c9ea..81b772f 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -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. */
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index d79326d..6bb15ed 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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. */
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index e29705c..619c058 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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 "
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bcf800a..d496dbc 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/abi/mangle48.C b/gcc/testsuite/g++.dg/abi/mangle48.C
new file mode 100644
index 0000000..dc9c492
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/mangle48.C
@@ -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>();
+}