[cfe-dev] A question about UnresolvedLookupExpr.

John McCall rjmccall at apple.com
Tue Apr 30 13:49:31 PDT 2013


On Apr 30, 2013, at 2:15 AM, Enea Zaffanella <zaffanella at cs.unipr.it> wrote:
> I have a question on the occurrence of UnresolvedLookupExpr nodes in clang AST. Consider the following example:
> 
> void foo();
> void foo(int);
> 
> template<void (*)(int)> struct A {};
> 
> int main() {
>  void (*pf)(int) = foo;
>  A<foo> a;
> }
> 
> Here we have two references to name "foo", referring to the overloaded set of functions declared at the start of the example.
> 
> The first reference
>  void (*pf)(int) = foo;
> is resolved (exploiting the function pointer type provided by the declaration of `pf') to the second function, leading to the generation of a DeclRefExpr node, which is fine.
> 
> The second reference
>   A<foo> a;
> is instead encoded by (a template argument embedding) an UnresolvedLookupExpr node.
> 
> One may argue that even this second reference is resolved to the second function (exploiting the function pointer type provided by the non-type template parameter). So the question is: are there reasons for this seemingly different behavior? That is, are there reasons preventing the use of a DeclRefExpr node in the second case too?

No good reason;  we probably just don't bother to rewrite the argument-as-written expression.  I wouldn't expect fixing that to be a serious memory regression.

John.



More information about the cfe-dev mailing list