class CompilerGeneratedConstructorTest {
int a, b, c, d, e, f, g, h, i, j;
public:
CompilerGeneratedConstructorTest() = default;
};
void fCompilerGeneratedConstructorTest() {
CompilerGeneratedConstructorTest();
}
#ifdef PEDANTIC
class DefaultConstructorTest {
int a;
public:
DefaultConstructorTest();
};
DefaultConstructorTest::DefaultConstructorTest() = default;
void fDefaultConstructorTest() {
DefaultConstructorTest(); }
#else
class DefaultConstructorTest {
int a;
public:
DefaultConstructorTest();
};
DefaultConstructorTest::DefaultConstructorTest() = default;
void fDefaultConstructorTest() {
DefaultConstructorTest();
}
#endif
class InitListTest1 {
int a;
int b;
public:
InitListTest1()
: a(1),
b(2) {
}
};
void fInitListTest1() {
InitListTest1();
}
class InitListTest2 {
int a;
int b;
public:
InitListTest2()
: a(3) {} };
void fInitListTest2() {
InitListTest2();
}
class InitListTest3 {
int a; int b;
public:
InitListTest3()
: b(4) {} };
void fInitListTest3() {
InitListTest3();
}
class CtorBodyTest1 {
int a, b;
public:
CtorBodyTest1() {
a = 5;
b = 6;
}
};
void fCtorBodyTest1() {
CtorBodyTest1();
}
class CtorBodyTest2 {
int a;
int b;
public:
CtorBodyTest2() {
a = 7; }
};
void fCtorBodyTest2() {
CtorBodyTest2();
}
class CtorBodyTest3 {
int a; int b;
public:
CtorBodyTest3() {
b = 8; }
};
void fCtorBodyTest3() {
CtorBodyTest3();
}
#ifdef PEDANTIC
class CtorBodyTest4 {
int a; int b;
public:
CtorBodyTest4() {}
};
void fCtorBodyTest4() {
CtorBodyTest4(); }
#else
class CtorBodyTest4 {
int a;
int b;
public:
CtorBodyTest4() {}
};
void fCtorBodyTest4() {
CtorBodyTest4();
}
#endif
class CtorDelegationTest1 {
int a;
int b;
public:
CtorDelegationTest1(int)
: a(9) {
}
CtorDelegationTest1()
: CtorDelegationTest1(int{}) { b = 10;
}
};
void fCtorDelegationTest1() {
CtorDelegationTest1();
}
class CtorDelegationTest2 {
int a; int b;
public:
CtorDelegationTest2(int)
: b(11) {
}
CtorDelegationTest2()
: CtorDelegationTest2(int{}) { }
};
void fCtorDelegationTest2() {
CtorDelegationTest2();
}
class ContainsRecordTest1 {
struct RecordType {
int x;
int y;
} rec;
int c, d;
public:
ContainsRecordTest1()
: rec({12, 13}),
c(14),
d(15) {
}
};
void fContainsRecordTest1() {
ContainsRecordTest1();
}
class ContainsRecordTest2 {
struct RecordType {
int x;
int y; } rec;
int c, d;
public:
ContainsRecordTest2()
: c(16),
d(17) {
rec.x = 18; }
};
void fContainsRecordTest2() {
ContainsRecordTest2();
}
class ContainsRecordTest3 {
struct RecordType {
int x; int y; } rec;
int c, d;
public:
ContainsRecordTest3()
: c(19),
d(20) { }
};
void fContainsRecordTest3() {
ContainsRecordTest3();
}
class ContainsRecordTest4 {
struct RecordType {
int x; int y; } rec;
int c, d;
public:
ContainsRecordTest4()
: c(19) { }
};
void fContainsRecordTest4() {
ContainsRecordTest4();
}
template <class T>
class IntTemplateClassTest1 {
T t;
int b;
public:
IntTemplateClassTest1(T i) {
b = 21;
t = i;
}
};
void fIntTemplateClassTest1() {
IntTemplateClassTest1<int>(22);
}
template <class T>
class IntTemplateClassTest2 {
T t; int b;
public:
IntTemplateClassTest2() {
b = 23; }
};
void fIntTemplateClassTest2() {
IntTemplateClassTest2<int>();
}
struct Record {
int x; int y; };
template <class T>
class RecordTemplateClassTest {
T t;
int b;
public:
RecordTemplateClassTest() {
b = 24; }
};
void fRecordTemplateClassTest() {
RecordTemplateClassTest<Record>();
}
template <class T>
void mayInitialize(T &);
template <class T>
void wontInitialize(const T &);
class PassingToUnknownFunctionTest1 {
int a, b;
public:
PassingToUnknownFunctionTest1() {
mayInitialize(a);
mayInitialize(b);
}
PassingToUnknownFunctionTest1(int) {
mayInitialize(a);
}
PassingToUnknownFunctionTest1(int, int) {
mayInitialize(*this);
}
};
void fPassingToUnknownFunctionTest1() {
PassingToUnknownFunctionTest1();
PassingToUnknownFunctionTest1(int());
PassingToUnknownFunctionTest1(int(), int());
}
class PassingToUnknownFunctionTest2 {
int a; int b;
public:
PassingToUnknownFunctionTest2() {
wontInitialize(a);
b = 4; }
};
void fPassingToUnknownFunctionTest2() {
PassingToUnknownFunctionTest2();
}
class ContainsSimpleUnionTest1 {
union SimpleUnion {
float uf;
int ui;
char uc;
} u;
public:
ContainsSimpleUnionTest1() {
u.uf = 3.14;
}
};
void fContainsSimpleUnionTest1() {
ContainsSimpleUnionTest1();
}
class ContainsSimpleUnionTest2 {
union SimpleUnion {
float uf;
int ui;
char uc;
} u;
public:
ContainsSimpleUnionTest2() {}
};
void fContainsSimpleUnionTest2() {
ContainsSimpleUnionTest2(); }
class UnionPointerTest1 {
public:
union SimpleUnion {
float uf;
int ui;
char uc;
};
private:
SimpleUnion *uptr;
public:
UnionPointerTest1(SimpleUnion *uptr, int) : uptr(uptr) {
}
};
void fUnionPointerTest1() {
UnionPointerTest1::SimpleUnion u;
u.uf = 41;
UnionPointerTest1(&u, int());
}
class UnionPointerTest2 {
public:
union SimpleUnion {
float uf;
int ui;
char uc;
};
private:
SimpleUnion *uptr;
public:
UnionPointerTest2(SimpleUnion *uptr, char) : uptr(uptr) {}
};
void fUnionPointerTest2() {
UnionPointerTest2::SimpleUnion u;
UnionPointerTest2(&u, int()); }
class ContainsUnionWithRecordTest1 {
union UnionWithRecord {
struct RecordType {
int x;
int y;
} us;
double ud;
long ul;
UnionWithRecord(){};
} u;
public:
ContainsUnionWithRecordTest1() {
u.ud = 3.14;
}
};
void fContainsUnionWithRecordTest1() {
ContainsUnionWithRecordTest1();
}
class ContainsUnionWithRecordTest2 {
union UnionWithRecord {
struct RecordType {
int x;
int y;
} us;
double ud;
long ul;
UnionWithRecord(){};
} u;
public:
ContainsUnionWithRecordTest2() {
u.us = UnionWithRecord::RecordType{42, 43};
}
};
void fContainsUnionWithRecordTest2() {
ContainsUnionWithRecordTest1();
}
class ContainsUnionWithRecordTest3 {
union UnionWithRecord {
struct RecordType {
int x;
int y;
} us;
double ud;
long ul;
UnionWithRecord(){};
} u;
public:
ContainsUnionWithRecordTest3() {
UnionWithRecord::RecordType rec;
rec.x = 44;
u.us = rec; }
};
void fContainsUnionWithRecordTest3() {
ContainsUnionWithRecordTest3();
}
class ContainsUnionWithSimpleUnionTest1 {
union UnionWithSimpleUnion {
union SimpleUnion {
float uf;
int ui;
char uc;
} usu;
long ul;
unsigned uu;
} u;
public:
ContainsUnionWithSimpleUnionTest1() {
u.usu.ui = 5;
}
};
void fContainsUnionWithSimpleUnionTest1() {
ContainsUnionWithSimpleUnionTest1();
}
class ContainsUnionWithSimpleUnionTest2 {
union UnionWithSimpleUnion {
union SimpleUnion {
float uf;
int ui;
char uc;
} usu;
long ul;
unsigned uu;
} u;
public:
ContainsUnionWithSimpleUnionTest2() {}
};
void fContainsUnionWithSimpleUnionTest2() {
ContainsUnionWithSimpleUnionTest2(); }
struct GlobalVariableTest {
int i;
GlobalVariableTest() {}
};
GlobalVariableTest gvt;
template <class T>
void funcToSquelchCompilerWarnings(const T &t);
#ifdef PEDANTIC
struct CopyConstructorTest {
int i;
CopyConstructorTest() : i(1337) {}
CopyConstructorTest(const CopyConstructorTest &other) {}
};
void fCopyConstructorTest() {
CopyConstructorTest cct;
CopyConstructorTest copy = cct; funcToSquelchCompilerWarnings(copy);
}
#else
struct CopyConstructorTest {
int i;
CopyConstructorTest() : i(1337) {}
CopyConstructorTest(const CopyConstructorTest &other) {}
};
void fCopyConstructorTest() {
CopyConstructorTest cct;
CopyConstructorTest copy = cct;
funcToSquelchCompilerWarnings(copy);
}
#endif
struct MoveConstructorTest {
int i;
MoveConstructorTest() : i(1337) {}
MoveConstructorTest(const CopyConstructorTest &other) = delete;
MoveConstructorTest(const CopyConstructorTest &&other) {}
};
void fMoveConstructorTest() {
MoveConstructorTest cct;
MoveConstructorTest copy(static_cast<MoveConstructorTest &&>(cct)); funcToSquelchCompilerWarnings(copy);
}
struct IntArrayTest {
int arr[256];
IntArrayTest() {
}
};
void fIntArrayTest() {
IntArrayTest();
}
struct RecordTypeArrayTest {
struct RecordType {
int x, y;
} arr[256];
RecordTypeArrayTest() {
}
};
void fRecordTypeArrayTest() {
RecordTypeArrayTest();
}
template <class T>
class CharArrayPointerTest {
T *t;
public:
CharArrayPointerTest(T *t, int) : t(t) {}
};
void fCharArrayPointerTest() {
char str[16] = "012345678912345";
CharArrayPointerTest<char[16]>(&str, int());
}
struct MemsetTest1 {
int a, b, c;
MemsetTest1() {
__builtin_memset(this, 0, sizeof(decltype(*this)));
}
};
void fMemsetTest1() {
MemsetTest1();
}
struct MemsetTest2 {
int a;
MemsetTest2() {
__builtin_memset(&a, 0, sizeof(int));
}
};
void fMemsetTest2() {
MemsetTest2();
}
template <class Callable>
struct LambdaThisTest {
Callable functor;
LambdaThisTest(const Callable &functor, int) : functor(functor) {
}
};
struct HasCapturableThis {
void fLambdaThisTest() {
auto isEven = [this](int a) { return a % 2 == 0; }; LambdaThisTest<decltype(isEven)>(isEven, int());
}
};
template <class Callable>
struct LambdaTest1 {
Callable functor;
LambdaTest1(const Callable &functor, int) : functor(functor) {
}
};
void fLambdaTest1() {
auto isEven = [](int a) { return a % 2 == 0; };
LambdaTest1<decltype(isEven)>(isEven, int());
}
#ifdef PEDANTIC
template <class Callable>
struct LambdaTest2 {
Callable functor;
LambdaTest2(const Callable &functor, int) : functor(functor) {} };
void fLambdaTest2() {
int b;
auto equals = [&b](int a) { return a == b; }; LambdaTest2<decltype(equals)>(equals, int());
}
#else
template <class Callable>
struct LambdaTest2 {
Callable functor;
LambdaTest2(const Callable &functor, int) : functor(functor) {}
};
void fLambdaTest2() {
int b;
auto equals = [&b](int a) { return a == b; };
LambdaTest2<decltype(equals)>(equals, int());
}
#endif
#ifdef PEDANTIC
namespace LT3Detail {
struct RecordType {
int x; int y; };
} template <class Callable>
struct LambdaTest3 {
Callable functor;
LambdaTest3(const Callable &functor, int) : functor(functor) {} };
void fLambdaTest3() {
LT3Detail::RecordType rec1;
auto equals = [&rec1](LT3Detail::RecordType rec2) {
return rec1.x == rec2.x;
};
LambdaTest3<decltype(equals)>(equals, int());
}
#else
namespace LT3Detail {
struct RecordType {
int x;
int y;
};
} template <class Callable>
struct LambdaTest3 {
Callable functor;
LambdaTest3(const Callable &functor, int) : functor(functor) {}
};
void fLambdaTest3() {
LT3Detail::RecordType rec1;
auto equals = [&rec1](LT3Detail::RecordType rec2) {
return rec1.x == rec2.x;
};
LambdaTest3<decltype(equals)>(equals, int());
}
#endif
template <class Callable>
struct MultipleLambdaCapturesTest1 {
Callable functor;
int dontGetFilteredByNonPedanticMode = 0;
MultipleLambdaCapturesTest1(const Callable &functor, int) : functor(functor) {} };
void fMultipleLambdaCapturesTest1() {
int b1, b2 = 3, b3;
auto equals = [&b1, &b2, &b3](int a) { return a == b1 == b2 == b3; }; MultipleLambdaCapturesTest1<decltype(equals)>(equals, int());
}
template <class Callable>
struct MultipleLambdaCapturesTest2 {
Callable functor;
int dontGetFilteredByNonPedanticMode = 0;
MultipleLambdaCapturesTest2(const Callable &functor, int) : functor(functor) {} };
void fMultipleLambdaCapturesTest2() {
int b1, b2 = 3, b3;
auto equals = [b1, &b2, &b3](int a) { return a == b1 == b2 == b3; }; MultipleLambdaCapturesTest2<decltype(equals)>(equals, int());
}
struct LambdaWrapper {
void *func; int dontGetFilteredByNonPedanticMode = 0;
LambdaWrapper(void *ptr) : func(ptr) {} };
struct ThisCapturingLambdaFactory {
int a;
auto ret() {
return [this] { (void)this; };
}
};
void fLambdaFieldWithInvalidThisCapture() {
void *ptr;
{
ThisCapturingLambdaFactory a;
decltype(a.ret()) lambda = a.ret();
ptr = λ
}
LambdaWrapper t(ptr);
}
#include "Inputs/system-header-simulator-for-cxx-uninitialized-object.h"
struct SystemHeaderTest1 {
RecordInSystemHeader rec;
SystemHeaderTest1() {
}
};
void fSystemHeaderTest1() {
SystemHeaderTest1();
}
#ifdef PEDANTIC
struct SystemHeaderTest2 {
struct RecordType {
int x; int y; };
ContainerInSystemHeader<RecordType> container;
SystemHeaderTest2(RecordType &rec, int) : container(rec) {} };
void fSystemHeaderTest2() {
SystemHeaderTest2::RecordType rec;
SystemHeaderTest2(rec, int());
}
#else
struct SystemHeaderTest2 {
struct RecordType {
int x;
int y;
};
ContainerInSystemHeader<RecordType> container;
SystemHeaderTest2(RecordType &rec, int) : container(rec) {}
};
void fSystemHeaderTest2() {
SystemHeaderTest2::RecordType rec;
SystemHeaderTest2(rec, int());
}
#endif
struct IncompleteTypeTest1 {
struct RecordType;
RecordType *recptr; int dontGetFilteredByNonPedanticMode = 0;
IncompleteTypeTest1() {} };
void fIncompleteTypeTest1() {
IncompleteTypeTest1();
}
struct IncompleteTypeTest2 {
struct RecordType;
RecordType *recptr; int dontGetFilteredByNonPedanticMode = 0;
RecordType *recordTypeFactory();
IncompleteTypeTest2() : recptr(recordTypeFactory()) {}
};
void fIncompleteTypeTest2() {
IncompleteTypeTest2();
}
struct IncompleteTypeTest3 {
struct RecordType;
RecordType &recref; int dontGetFilteredByNonPedanticMode = 0;
RecordType &recordTypeFactory();
IncompleteTypeTest3() : recref(recordTypeFactory()) {}
};
void fIncompleteTypeTest3() {
IncompleteTypeTest3();
}
struct IntegralTypeTest {
int a; int dontGetFilteredByNonPedanticMode = 0;
IntegralTypeTest() {} };
void fIntegralTypeTest() {
IntegralTypeTest();
}
struct FloatingTypeTest {
float a; int dontGetFilteredByNonPedanticMode = 0;
FloatingTypeTest() {} };
void fFloatingTypeTest() {
FloatingTypeTest();
}
struct NullptrTypeTypeTest {
decltype(nullptr) a; int dontGetFilteredByNonPedanticMode = 0;
NullptrTypeTypeTest() {} };
void fNullptrTypeTypeTest() {
NullptrTypeTypeTest();
}
struct EnumTest {
enum Enum {
A,
B
} enum1; enum class Enum2 {
A,
B
} enum2; int dontGetFilteredByNonPedanticMode = 0;
EnumTest() {} };
void fEnumTest() {
EnumTest();
}
void halt() __attribute__((__noreturn__));
void assert(int b) {
if (!b)
halt();
}
struct Singleton {
int i; int dontGetFilteredByNonPedanticMode = 0;
Singleton() {
assert(!isInstantiated);
isInstantiated = true; }
~Singleton() {
isInstantiated = false;
}
static bool isInstantiated;
};
bool Singleton::isInstantiated = false;
struct SingletonTest {
int dontGetFilteredByNonPedanticMode = 0;
SingletonTest() {
Singleton();
}
};
void fSingletonTest() {
SingletonTest();
}
struct CXX11MemberInitTest1 {
int a = 3;
int b;
CXX11MemberInitTest1() : b(2) {
}
};
void fCXX11MemberInitTest1() {
CXX11MemberInitTest1();
}
struct CXX11MemberInitTest2 {
struct RecordType {
int a; int b;
RecordType(int) {}
};
RecordType rec = RecordType(int());
int dontGetFilteredByNonPedanticMode = 0;
CXX11MemberInitTest2() {}
};
void fCXX11MemberInitTest2() {
CXX11MemberInitTest2(); }
struct MyAtomicInt {
_Atomic(int) x; int dontGetFilteredByNonPedanticMode = 0;
MyAtomicInt() {} };
void _AtomicTest() {
MyAtomicInt b;
}
struct VectorSizeLong {
VectorSizeLong() {}
__attribute__((__vector_size__(16))) long x;
};
void __vector_size__LongTest() {
VectorSizeLong v;
v.x[0] = 0;
}
struct ComplexUninitTest {
ComplexUninitTest() {}
__complex__ float x;
__complex__ int y;
};
struct ComplexInitTest {
ComplexInitTest() {
x = {1.0f, 1.0f};
y = {1, 1};
}
__complex__ float x;
__complex__ int y;
};
void fComplexTest() {
ComplexInitTest x;
ComplexUninitTest x2;
}