Skip to content

Commit f291980

Browse files
[Test] Enhanced cpp test
Added tests for: - Potentially throwing operation called in a `noexcept` function - Function returning a struct (generating a `sret` parameter) - static class, generating an `llvm.global_ctors`
1 parent d2fb6c2 commit f291980

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

examples/cpp-benchmarks/full_test.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,46 @@ void riskyFunction(bool throwException) {
9898
std::cout << "RiskyFunction executed successfully." << std::endl;
9999
}
100100

101+
// Sret
102+
struct State
103+
{
104+
double x0;
105+
float x1;
106+
float x2;
107+
float x3;
108+
};
109+
110+
class Class
111+
{
112+
public:
113+
Class() {
114+
std::cout << "Class constructor" << std::endl;
115+
state = {1.0, 2.f, 3.f, 4.f};
116+
}
117+
118+
State testSretDuplication(){
119+
return state;
120+
}
121+
122+
private:
123+
State state;
124+
};
125+
126+
127+
// noexcept
128+
void TestNoExcept() noexcept
129+
{
130+
volatile MyClass m_data(1,2);
131+
}
132+
133+
// testing unexpected special variable
134+
static Class staticClass;
135+
101136
int main() {
137+
std::cout << "Starting main" << std::endl;
138+
139+
std::cout << "staticClass: " << staticClass.testSretDuplication().x3 << std::endl;
140+
102141
// Call simple function
103142
simpleFunction();
104143

@@ -144,5 +183,11 @@ int main() {
144183
std::cerr << "Caught exception: " << e.what() << std::endl;
145184
}
146185

186+
TestNoExcept();
187+
188+
// Test sret
189+
Class sretTest;
190+
std::cout << "test sret: " << sretTest.testSretDuplication().x0 << std::endl;
191+
147192
return 0;
148193
}

0 commit comments

Comments
 (0)