This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Patch for PR c++/39754


Hello,

When we build the type of a template instantiation (e.g. A<Foo>), if
the argument(s) of the template is a typedef, that typedef is stripped.

For instance, if Foo is "typedef const int Foo", then stripping the
typedef Foo yields "const int". The internal representation of A<Foo>
would then be A<const inst>. So at template instantiation time, it's the
const int argument that will be used. Not the Foo typedef.

In this PR, the problem is that the typedef stripping process doesn't
strip typedefs recursively. For instance, stripping "Foo*" yields
"Foo*", whereas we would like it to yield "const int*".

The net effect of this issue is that at some point, when we are
tsubst'ing the arguments of the template, we end up tyring to tsubst the
un-stripped typedef that might have been defined in a context that is
now meaningless.

We were not having this issue before the patch for PR c++/PR26693 went
in because we were not creating typedef types systematically
back then. Well, at least not when those typedefs types where template
members.

This patch re-writes the canonical_type_variant function
that was used to perform typedef stripping so that it does recursive
typedef stripping, renames it to strip_typedefs and revisits the places
where canonical_type_variant was being used to try to just avoid using
strip_typedefs when not necessary.

It bootstraps and passes regtests on trunk.

OK to commit to trunk ?

Thanks.

-- 
Dodji Seketeli
Red Hat, Inc.

Attachment: gcc-PR39754-patch-7.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]