[cfe-commits] [Request for approval] Redundant NNS and missing template keyword
Abramo Bagnara
abramo.bagnara at gmail.com
Sun Aug 1 07:45:38 PDT 2010
Ping.
Il 27/07/2010 12:01, Abramo Bagnara ha scritto:
> Please find attached a couple of patches that are meant to fix the
> problems shown by the following examples.
>
> ==============
> $ cat bug1.cc
> template <typename T>
> struct Outer {
> template <typename U>
> struct Inner {
> Inner& foo();
> };
> };
>
>
> template <typename T>
> template <typename U>
> typename Outer<T> ::template Inner<U>&
> Outer<T>::Inner<U>::foo() {}
> ==============
>
> If this is pretty printed using clang, we obtain the following:
>
> ==============
> $ llvm/Debug+Asserts/bin/clang -cc1 -ast-print bug1.cc
> struct __va_list_tag {
> unsigned int gp_offset;
> unsigned int fp_offset;
> void *overflow_arg_area;
> void *reg_save_area;
> };
> typedef struct __va_list_tag __va_list_tag;
> template <typename T> struct Outer {
> template <typename U> struct Inner {
> Inner<U> &foo();
> };
> };
> typename Outer<T>::Outer<T>::Inner<U> &foo() {
> }
> ==============
>
> The printed return type in the out-of-line definition of method foo has
> two problems: the name qualification Outer<T>:: is repeated and the name
> qualification Inner<U> is missing the "template" keyword.
>
> The first problem is due to the fact that the NNS is encoded *both* in
> the ElaboratedType and in the underlying (dependent)
> TemplateSpecializationType: this should be corrected in redundant-nns.patch
>
> The second problem is caused by method Sema::isTemplateName(), which
> sometimes builds a QualifiedTemplateName disregarding whether or not the
> "template" keyword was specified: this should be corrected in
> template-keyword.patch
>
> After applying both patches we obtain:
> ===============
> $ llvm/Debug+Asserts/bin/clang -cc1 -ast-print bug1.cc
> [...]
> typename Outer<T>::template Inner<U> &foo() {
> }
> ===============
>
More information about the cfe-commits
mailing list