<div dir="ltr">This is "injected-class-name", see C++ standard (clause 9p2):<div><br></div><div><div>A class-name is inserted into the scope in which it is declared immediately after the class-name is seen.</div>
<div>The class-name is also inserted into the scope of the class itself; this is known as the injected-class-name.</div></div><div><br></div><div>--Serge</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2013/7/16 Jonathan Sauer <span dir="ltr"><<a href="mailto:jonathan.sauer@gmx.de" target="_blank">jonathan.sauer@gmx.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
the following program compiles with clang r186311, and I'm not sure if this is a bug<br>
or correct behavior:<br>
<br>
struct Foo {<br>
void bar();<br>
};<br>
<br>
<br>
void Foo::Foo::Foo::Foo::Foo::Foo::bar()<br>
{<br>
}<br>
<br>
<br>
According to §3.3.7p1 bullet 5 (basic.scope.class), the potential scope of a class<br>
includes "the regions defined by its member definitions [...] including the member<br>
function body and any portion of the declarator part of such definitions which follows<br>
the declarator-id", and §3.4.3.1p1 (class.qual) states that "A class member can be<br>
referred to using a qualified-id at any point in its potential scope" while "the name<br>
[specified after the nested-name-specifier] shall represent one or more members of<br>
that class or of one of its base classes."<br>
<br>
However in the code above the member function "bar" is referred to using a qualified-id<br>
in its declarator-id, which is not part of the class' potential scope, and "Foo" isn't<br>
a base class of itself, so this shouldn't be allowed.<br>
<br>
Still, I'm not sure if I got all the subtleties of C++'s name lookup rules right, so<br>
I'd like to make sure if this is a bug in clang or merely the somewhat amusing result<br>
of the way names in C++ can be specified.<br>
<br>
<br>
With many thanks in advance,<br>
Jonathan<br>
<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Thanks,<br>--Serge<br>
</div>