[cfe-dev] QualifiedNameType generated for a dependent type name.

Douglas Gregor dgregor at apple.com
Thu Apr 29 09:16:02 PDT 2010


On Apr 29, 2010, at 2:02 AM, Enea Zaffanella <zaffanella at cs.unipr.it> wrote:

> Hello.
> 
> It seems that clang (r102496) sometimes generates a QualifiedNameType 
> (which is meant to be a non-dependent type) when a DependentNameType 
> should be expected.
> 
> Consider the following program fragment:
> =================
> template <typename T>
> struct S {
>   class Inner {};
>   Inner a_method();
> };
> 
> template <typename T>
> typename S<T>::Inner a_function();
> 
> template <typename T>
> typename S<T>::Inner
> S<T>::a_method() {}
> =================
> 
> Both return types for a_function() and a_method() are type dependent, 
> hence they should be encoded by a DependentNameType. However, it seems 
> that a QualifiedNameType is generated for a_method().

The name DependentNameType is slightly misleading. It represents dependent types that refer to a member of an unknown specialization, meaning that we can't resolve them to an actual type until we instantiate. With the example you've given, we know that Inner is a member of the current instantiation, so it is correct to use QualifiedNameType. 

> I don't know how to obtain a detailed description of the AST produced by 
> clang ... since AST type nodes seems to be just printed rather than 
> dumped. Anyway, even with the -ast-print option, it can be seen that the 
> out-of-line definition of a_method() is missing the "typename" keyword.

Right. We don't keep track of whether typename was written in the QualifiedNameType, but we should. 

> $ llvm/Debug/bin/clang++ -cc1 -ast-print bug.cc
> [...]
> template <typename T> typename S<T>::Inner a_function();
> S<T>::Inner a_method() {
> }
> 
> 
> Regards,
> Enea Zaffanella.
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list