I was mucking about with typeof (discovered it looking at DeclSpecs various SourceLocation information trying to piece together SourceLocations/Ranges covering the entire return type both before & after the identifier) & I discovered this curious behavior:<div>
<br></div><div>Given this:</div><div><br></div><div>    int i = 3;</div><div>    typeof(i) (*foo())() {<br>    }</div><div><br></div><div>The following output is provided</div><div><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; "><pre>
<span class="terminalStyle1" style="font-weight: bold; ">  typeof.cpp:2:13: </span><span class="terminalStyle0"></span><span class="terminalStyle131" style="color: red; font-weight: bold; ">error: </span><span class="terminalStyle0"></span><span class="terminalStyle1" style="font-weight: bold; ">use of undeclared identifier 'foo'
</span><span class="terminalStyle0">  typeof(i) (*foo())()
</span><span class="terminalStyle132" style="color: green; font-weight: bold; ">              ^
</span><span class="terminalStyle0"></span><span class="terminalStyle1" style="font-weight: bold; ">  typeof.cc:4:2: </span><span class="terminalStyle0"></span><span class="terminalStyle131" style="color: red; font-weight: bold; ">error: </span><span class="terminalStyle0"></span><span class="terminalStyle1" style="font-weight: bold; ">expected unqualified-id
</span><span class="terminalStyle0">  }
</span><span class="terminalStyle132" style="color: green; font-weight: bold; ">   ^</span></pre></span>If I use a simple function (typeof(i) foo() {}) it compiles fine. If I use gcc/g++ I get a very similar error to the one clang provides. So it's at least bug-for-bug compatible, but I'm wondering what the desired behavior is here & why this case would be failing in the way it is.</div>
<div><br></div><div>Interestingly, C++0x's decltype works totally fine here (ie: compiles without error). So I'm wondering: in what way is typeof not just an alias for decltype? Should it be? (could we remove some redundant code in clang by coalescing these two cases together) Or is there some legitimate reason for these errors.</div>
<div><br></div><div>- David</div>