Skip to content

Commit 0ab2965

Browse files
note: non-constexpr function addTest cannot be used in a constant expression
1 parent 928e5c1 commit 0ab2965

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

libc/test/UnitTest/LibcTest.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,6 @@ char **envp = nullptr;
116116

117117
using internal::RunContext;
118118

119-
void Test::addTest(Test *T) {
120-
if (End == nullptr) {
121-
Start = T;
122-
End = T;
123-
return;
124-
}
125-
126-
End->Next = T;
127-
End = T;
128-
}
129-
130119
int Test::getNumTests() {
131120
int N = 0;
132121
for (Test *T = Start; T; T = T->Next, ++N)

libc/test/UnitTest/LibcTest.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,18 @@ class Test {
127127
static int runTests(const TestOptions &Options);
128128

129129
protected:
130-
static void addTest(Test *T);
130+
constexpr static void *addTest(Test *T) {
131+
if (End == nullptr) {
132+
Start = T;
133+
End = T;
134+
// read of constexpr
135+
return nullptr;
136+
}
137+
138+
End->Next = T;
139+
End = T;
140+
return nullptr;
141+
}
131142

132143
// We make use of a template function, with |LHS| and |RHS| as explicit
133144
// parameters, for enhanced type checking. Other gtest like unittest

0 commit comments

Comments
 (0)