<p dir="ltr">PR28422 is invalid. Giving better diagnostics in this case seems reasonable, but we should not accept the ill-formed code.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On 18 Aug 2016 11:41 a.m., "Serge Pavlov" <<a href="mailto:sepavloff@gmail.com">sepavloff@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">sepavloff created this revision.<br>
sepavloff added reviewers: rsmith, doug.gregor.<br>
sepavloff added a subscriber: cfe-commits.<br>
<br>
If a declaration references a function from global namespace by its<br>
qualified name and if that function return type is a class or enum, there<br>
is possible ambiguity. The declaration:<br>
```<br>
    friend A::B::C();<br>
```<br>
may be considered as a declaration of a function `::C()` that returns<br>
`A::B`, or a function `::B::C()` that returns `A`.<br>
<br>
With this change when the compiler sees 'A::B' while parsing decl-spec, it<br>
tries to find `B` within 'A'. If it finds, 'A::B' is treated as a part of<br>
qualified name. If it doesn't and the current declaration declares a<br>
function, '::B' is assumed to be a part of declarator. For non-function<br>
declarations 'B' can be searched for in the global namespace to improve<br>
diagnostics.<br>
<br>
This changes fixes <a href="https://llvm.org/bugs/show_bug.cgi?id=28422" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_<wbr>bug.cgi?id=28422</a>.<br>
<br>
<a href="https://reviews.llvm.org/D23684" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D23684</a><br>
<br>
Files:<br>
  include/clang/Parse/Parser.h<br>
  include/clang/Sema/Sema.h<br>
  lib/Parse/ParseDecl.cpp<br>
  lib/Parse/ParseDeclCXX.cpp<br>
  lib/Parse/ParseExprCXX.cpp<br>
  lib/Parse/Parser.cpp<br>
  lib/Parse/<wbr>RAIIObjectsForParser.h<br>
  lib/Sema/SemaCXXScopeSpec.cpp<br>
  lib/Sema/TreeTransform.h<br>
  test/CXX/drs/dr1xx.cpp<br>
  test/CXX/drs/dr2xx.cpp<br>
  test/Parser/cxx-decl.cpp<br>
  test/SemaCXX/nested-name-<wbr>spec2.cpp<br>
  test/SemaCXX/pr18284-crash-on-<wbr>invalid.cpp<br>
  test/SemaCXX/typo-correction.<wbr>cpp<br>
<br>
</blockquote></div></div>