Skip to content

Commit 3f1e95a

Browse files
committed
[clang][Interp] consider "MS constexpr" functions as well
This implements the minimum amout of support for this feature to get the test/AST/ms-constexpr.cpp test working. More has to be added to get SemaCXX tests to work.
1 parent 4607f38 commit 3f1e95a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

clang/lib/AST/Interp/ByteCodeEmitter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "Opcode.h"
1515
#include "Program.h"
1616
#include "clang/AST/ASTLambda.h"
17+
#include "clang/AST/Attr.h"
1718
#include "clang/AST/DeclCXX.h"
1819
#include "clang/Basic/Builtins.h"
1920
#include <type_traits>
@@ -116,7 +117,8 @@ Function *ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
116117
if (const auto *MD = dyn_cast<CXXMethodDecl>(FuncDecl))
117118
IsEligibleForCompilation = MD->isLambdaStaticInvoker();
118119
if (!IsEligibleForCompilation)
119-
IsEligibleForCompilation = FuncDecl->isConstexpr();
120+
IsEligibleForCompilation =
121+
FuncDecl->isConstexpr() || FuncDecl->hasAttr<MSConstexprAttr>();
120122

121123
// Compile the function body.
122124
if (!IsEligibleForCompilation || !visitFunc(FuncDecl)) {

clang/test/AST/ms-constexpr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 -std=c++20 -ast-dump -verify %s | FileCheck %s
2+
// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 -std=c++20 -ast-dump -verify %s -fexperimental-new-constant-interpreter | FileCheck %s
23
// expected-no-diagnostics
34

45
// CHECK: used f1 'bool ()'

0 commit comments

Comments
 (0)