Let me see if I can rephrase this problem... <br>At this point, instantiation is no longer an issue. The issue is managing new DeclContext's.<br><br>Take the following definition of a concept:<br><br>concept A<typename T> {<br>
    void f(int) { }<br>}<br><br>This definition is parsed into a ConceptDecl  object <b>ContextA</b> where ConceptDecl is a DeclContext as well as a TemplateDecl.<br>When the concept is used on a generic function such as:<br>
<br>template<typename T><br>requires A<T><br>void func(T a) {<br>    f(a);<br>}<br><br>at the call f(a),  the lookup process finds the definition of f() in the DeclContext <b>ContextA</b>.  <br>Hence, the definition of func() is accepted. <br>
Let's refer to the found definition as <b>Fn</b>.<br><br>Now, when func() is used in the main, the lookup and instantiation-related processes are still finding and using that same definition of f(): Fn.<br><br>However, when compilation is over, and things are being linked together, Fn (of f()) is lost, and can't be found?<br>
It seems like a fatal assumption is being made about the way that the various lookup* methods in SemaLookup.cpp work and should be used. I just don't know what those assumptions are... <br>For one thing, could the use of LookupQualifiedName(...) perhaps entail something else that would affect link time resolution?<br>
<br><br><div class="gmail_quote">On Mon, Jan 31, 2011 at 6:19 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="word-wrap: break-word;"><div><div></div><div class="h5"><br><div><div>On Jan 31, 2011, at 3:18 PM, Larisse Voufo wrote:</div><br><blockquote type="cite"><br><br><div class="gmail_quote">On Mon, Jan 31, 2011 at 5:50 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="word-wrap: break-word;"><br><div><div><div>On Jan 31, 2011, at 1:43 PM, Larisse Voufo wrote:</div><br><blockquote type="cite">Thanks. That was a lot helpful. However, I do have another question. Consider the following two case scenari: <br>

<br>Case 1:<br>------------<br>The previous one, with<br>(1) f() defined as a concept member, and<br>(2) func() a restricted template<br>
<br><br>Case 2:<br>------------<br>(1) f() is a global function, and<br>(2) func() is a simple template, as in<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">void f() { }<br>


<br>template<typename T></span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">void func(T a) {</span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    f(0);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">


<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">int main(int argc, char **argv) </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{ </span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">    int i=0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    func<int>(i); </span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">}</span><br><br><br>Observation:<br>----------------------<br>In both cases, f() never seems to be "marked for instantiation", at least not through Sema::<div>MarkDeclarationReferenced. However, f() does seem to eventually get instantiated in the "Case 2" somehow, whereas it never does in "Case 1". Any idea?<br>


<br>1) When does f() get instantiated in "Case 2"?<br></div></blockquote><div><br></div></div><div>Case 2 is ill-formed, but the general rule is that MarkDeclarationReferenced will get called when we use that function in a potentially evaluated context, either in non-template code or during template instantiation.</div>

<div><br></div></div></div></blockquote><div>Sorry about this. I meant for the definition of f() to take an integer in as argument...  <br></div><div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div style="word-wrap: break-word;"><div><div><blockquote type="cite"><div>2) is this connected to lookup somehow?<br>     I have made some very minor changes in Sema::CppLookupName(), and I'm not sure how this could affect instantiation...<br>


</div></blockquote></div></div><div><br></div><div>It's more likely that you haven't added any logic to permit the instantiation of functions defined within concept maps.</div></div></blockquote><div><br>Any rule of thumb on how to add such logic? Say, for example how is this currently setup for  "(corrected) Case 2"?<br>
</div></div></blockquote></div><br></div></div><div>Please see the handling of function templates in Sema::MarkDeclarationReferenced and the actual instantiation in Sema::InstantiateFunctionDefinition. It probably needs a small tweak for concept maps, but there's no more advice anyone can give without looking specifically at your representation of concept maps.</div>
<div><br></div><div><span style="white-space: pre-wrap;">       </span>- Doug</div></div></blockquote></div><br>