[cfe-commits] r127401 - /cfe/trunk/lib/Sema/SemaType.cpp

Douglas Gregor dgregor at apple.com
Thu Mar 10 08:18:40 PST 2011


On Mar 10, 2011, at 8:13 AM, Abramo Bagnara wrote:

> Il 10/03/2011 16:39, Douglas Gregor ha scritto:
>>> -          // Note: if NNS is dependent, then its prefix (if any) is already
>>>> -          // included in ClsType; this does not hold if the NNS is
>>>> -          // nondependent: in this case (if there is indeed a prefix)
>>>> -          // ClsType needs to be wrapped into an elaborated type.
>>>> -          if (NNSPrefix && !NNS->isDependent())
>>>> +          // Note: if the NNS has a prefix and ClsType is a nondependent
>>>> +          // TemplateSpecializationType, then the NNS prefix is NOT included
>>>> +          // in ClsType; hence we wrap ClsType into an ElaboratedType.
>>>> +          // NOTE: in particular, no wrap occurs if ClsType already is an
>>>> +          // Elaborated, DependentName, or DependentTemplateSpecialization.
>>>> +          if (NNSPrefix && isa<TemplateSpecializationType>(NNS->getAsType()))
>>>>            ClsType = Context.getElaboratedType(ETK_None, NNSPrefix, ClsType);
>>>>          break;
>>>>        }
>> Do you have a test case for this?
> 
> Apart some tests in the huge testsuite of our application (not useable
> with clang), the output of clang -cc1 -ast-dump showed the omitted NNS.
> 
> Taken in account that this was a pure syntactical issue, there is a way
> to add a testcase for that?

The ideal way to test this would be to test the output of

	c-index-test -test-annotate-tokens

and make sure we get proper annotations for the "ns::". It's a great end-to-end test.

If that's not working for some reason, but the ASTs are still correct, just tell me and I'll deal with the libclang-specific aspect of it.

	- Doug


> This is the source:
> 
> namespace ns {
> 
> template <typename T>
> struct s {
> };
> 
> }
> 
> template <typename T>
> void *(ns::s<T>::*f());
> 
> This was the former output (r127282):
> 
> $ clang -cc1 -ast-dump ~/p.cc
> typedef __int128_t __int128_t;
> typedef __uint128_t __uint128_t;
> struct __va_list_tag {
>    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;
> typedef __va_list_tag __builtin_va_list[1];
> namespace ns {
>    template <typename T> struct s {
>        struct s;
>    };
> }
> template <typename T> void *(s<T>::*f());
> 
> This is the current output (r127404):
> 
> $ clang -cc1 -ast-dump p.cc
> typedef char *__builtin_va_list;
> namespace ns {
>    template <typename T> struct s {
>        struct s;
>    };
> }
> template <typename T> void *(ns::s<T>::*f());





More information about the cfe-commits mailing list