mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-18 09:50:33 +08:00
* pt.c (tsubst_copy) [PARM_DECL]: Handle 'this' in NSDMI.
From-SVN: r179201
This commit is contained in:
parent
8fb3401bdc
commit
fcb7afc20f
@ -1,3 +1,7 @@
|
||||
2011-09-26 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* pt.c (tsubst_copy) [PARM_DECL]: Handle 'this' in NSDMI.
|
||||
|
||||
2011-09-26 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* pt.c (convert_nontype_argument): Handle NULLPTR_TYPE.
|
||||
|
@ -11750,6 +11750,13 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
|
||||
if (r == NULL)
|
||||
{
|
||||
tree c;
|
||||
|
||||
/* We get here for a use of 'this' in an NSDMI. */
|
||||
if (DECL_NAME (t) == this_identifier
|
||||
&& at_function_scope_p ()
|
||||
&& DECL_CONSTRUCTOR_P (current_function_decl))
|
||||
return current_class_ptr;
|
||||
|
||||
/* This can happen for a parameter name used later in a function
|
||||
declaration (such as in a late-specified return type). Just
|
||||
make a dummy decl, since it's only used for its type. */
|
||||
|
@ -1,3 +1,7 @@
|
||||
2011-09-26 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* g++.dg/cpp0x/nsdmi-template1.C: New.
|
||||
|
||||
2011-09-26 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* g++.dg/cpp0x/nullptr25.C: New.
|
||||
|
@ -1,4 +1,5 @@
|
||||
// { dg-options -std=c++0x }
|
||||
// { dg-do run }
|
||||
|
||||
struct A
|
||||
{
|
||||
|
21
gcc/testsuite/g++.dg/cpp0x/nsdmi-template1.C
Normal file
21
gcc/testsuite/g++.dg/cpp0x/nsdmi-template1.C
Normal file
@ -0,0 +1,21 @@
|
||||
// { dg-do run }
|
||||
// { dg-options -std=c++0x }
|
||||
|
||||
struct base
|
||||
{
|
||||
int calc_avg() { return 42; }
|
||||
};
|
||||
|
||||
template <class T> struct nsdmi : T
|
||||
{
|
||||
nsdmi() {}
|
||||
int avg() { return avg_; }
|
||||
int avg_ = this->calc_avg();
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
nsdmi<base> x;
|
||||
if (x.avg() != 42)
|
||||
__builtin_abort();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user