Files
clang-p2996/bolt/test/runtime/X86/Inputs/exception4.cpp
Amir Ayupov a80e1e493f [BOLT][TEST] Remove functions with dynamic exception specification
Clang has switched to gnu++17 by default with https://reviews.llvm.org/D131465.
C++17 removes dynamic exception specification. Remove its use as it wasn't
properly tested.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D133467
2022-09-07 20:45:41 -07:00

56 lines
891 B
C++

#include <stdio.h>
class ExcA {};
class ExcB {};
class ExcC {};
class ExcD {};
class ExcE {};
class ExcF {};
class ExcG {};
void foo(int a)
{
if (a > 1)
throw ExcG();
else
throw ExcC();
}
void never_throws() throw () {
printf("this statement is cold and should be outlined\n");
}
int main(int argc, char **argv)
{
for(unsigned i = 0; i < 1000000; ++i) {
try {
if (argc == 2) {
never_throws(); // should be cold
}
try {
if (argc == 2) {
never_throws(); // should be cold
}
throw ExcA();
} catch (ExcA) {
printf("catch 2\n");
throw new int();
}
} catch (...) {
printf("catch 1\n");
}
try {
try {
foo(argc);
} catch (ExcC) {
printf("caught ExcC\n");
}
} catch (ExcG) {
printf("caught ExcG\n");
}
}
return 0;
}