Skip to content

Commit

Permalink
[C++20] [Modules] Treat constexpr/consteval member function as implic…
Browse files Browse the repository at this point in the history
…itly inline

Close #107673
  • Loading branch information
ChuanqiXu9 committed Sep 9, 2024
1 parent 0f50330 commit 74ac96a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9766,6 +9766,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
// the function decl is created above).
// FIXME: We need a better way to separate C++ standard and clang modules.
bool ImplicitInlineCXX20 = !getLangOpts().CPlusPlusModules ||
NewFD->isConstexpr() || NewFD->isConsteval() ||
!NewFD->getOwningModule() ||
NewFD->isFromExplicitGlobalModule() ||
NewFD->getOwningModule()->isHeaderLikeModule();
Expand Down
12 changes: 12 additions & 0 deletions clang/test/Modules/pr107673.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %clang_cc1 -std=c++20 %s -ast-dump | FileCheck %s
export module a;
export class f {
public:
void non_inline_func() {}
constexpr void constexpr_func() {}
consteval void consteval_func() {}
};

// CHECK-NOT: non_inline_func {{.*}}implicit-inline
// CHECK: constexpr_func {{.*}}implicit-inline
// CHECK: consteval_func {{.*}}implicit-inline

0 comments on commit 74ac96a

Please sign in to comment.