<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - clang -fms-extensions considers an unqualified friend decl to be a forward decl in the enclosing namespace"
   href="http://llvm.org/bugs/show_bug.cgi?id=16032">16032</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang -fms-extensions considers an unqualified friend decl to be a forward decl in the enclosing namespace
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>reid.kleckner@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=10523" name="attach_10523" title="reduced test case">attachment 10523</a> <a href="attachment.cgi?id=10523&action=edit" title="reduced test case">[details]</a></span>
reduced test case

$ cat menu_button.ii
namespace views {
class Widget;
namespace internal {
class RootView {
// This friend decl creates a bad forward decl of ::views::internal::Widget
  friend class Widget;
};
class NativeWidgetDelegate {
  virtual Widget *AsWidget() = 0;
};
}
class Widget : public internal::NativeWidgetDelegate {
  virtual Widget *AsWidget() override;
};
}

$ clang -w ./menu_button.ii -fsyntax-only
# No errors

$ clang -fms-extensions -w ./menu_button.ii -fsyntax-only
./menu_button.ii:12:19: error: return type of virtual function 'AsWidget' is
not covariant with the return type of the function it overrides
      ('views::Widget *' is not derived from 'views::internal::Widget *')
  virtual Widget *AsWidget() override;
                  ^
./menu_button.ii:8:19: note: overridden virtual function is here
  virtual Widget *AsWidget() = 0;
                  ^
1 error generated.

If I qualify the class name in the friend decl (::views::Widget), I can avoid
the error.  Am I required to do that?  Is the friend decl actually incorrect,
and -fms-extensions just happens to look at friend decls to find names?

The -ast-dump both with and without -fms-extensions show this node:
  `-FriendDecl 0x2b0f390 <line:7:3, col:16> 'class Widget':'class
views::internal::Widget'

In any case, MSVC accepts this code, so we should consider adding compatibility
for it.  I think I can fix this code easily enough by qualifying the friend
decl, so adding compatibility would be low priority for me, but would be worth
documenting.

The compatibility fix would probably be a modification to the way that clang
apparently searches friend decls in -fms-extensions.  Since there is a real
forward decl in the right namespace, clang should look for that before falling
back to friend decls.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>