[cfe-dev] A question about UnresolvedLookupExpr.

Enea Zaffanella zaffanella at cs.unipr.it
Tue Apr 30 02:15:12 PDT 2013


Hello.

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?

Enea.



More information about the cfe-dev mailing list