[all-commits] [llvm/llvm-project] ad4711: In MSVC compatibility mode, friend function declar...

Fred Tingaud via All-commits all-commits at lists.llvm.org
Tue May 3 02:32:03 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ad47114ad8500c78046161d492ac13a8e3e610eb
      https://github.com/llvm/llvm-project/commit/ad47114ad8500c78046161d492ac13a8e3e610eb
  Author: Fred Tingaud <frederic.tingaud at sonarsource.com>
  Date:   2022-05-03 (Tue, 03 May 2022)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp
    A clang/test/SemaCXX/ms-friend-function-decl.cpp
    M clang/unittests/AST/ASTImporterTest.cpp

  Log Message:
  -----------
  In MSVC compatibility mode, friend function declarations behave as function declarations

Before C++20, MSVC treated any friend function declaration as a function declaration, so the following code would compile despite funGlob being declared after its first call:

```
class Glob {
public:
  friend void funGlob();

  void test() {
    funGlob();
  }
};

void funGlob() {}
```
This proposed patch mimics the MSVC behavior when in MSVC compatibility mode

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D124613




More information about the All-commits mailing list