[NFC][AMDGPU] Pre-commit tests for IR variant - isFMAFasterThanFMulAdd (#121925)
[llvm-project.git] / clang / test / ASTMerge / exprs-cpp / Inputs / exprs3.cpp
blob6fdc33fb3919f314ba0ee7d5451b0433d1b2f78c
1 // Integer literals
2 const char Ch1 = 'a';
3 const signed char Ch2 = 'b';
4 const unsigned char Ch3 = 'c';
6 const wchar_t Ch4 = L'd';
7 const signed wchar_t Ch5 = L'e';
8 const unsigned wchar_t Ch6 = L'f';
10 const short C1 = 12;
11 const unsigned short C2 = 13;
13 const int C3 = 12;
14 const unsigned int C4 = 13;
16 const long C5 = 22;
17 const unsigned long C6 = 23;
19 const long long C7 = 66;
20 const unsigned long long C8 = 67;
23 // String literals
24 const char str1[] = "ABCD";
25 const char str2[] = "ABCD" "0123";
27 const wchar_t wstr1[] = L"DEF";
28 const wchar_t wstr2[] = L"DEF" L"123";
31 // Boolean literals
32 const bool bval1 = true;
33 const bool bval2 = false;
35 // Floating Literals
36 const float F1 = 12.2F;
37 const double F2 = 1E4;
38 const long double F3 = 1.2E-3L;
41 // nullptr literal
42 const void *vptr = nullptr;
45 int glb_1[4] = { 10, 20, 30, 40 };
47 struct S1 {
48 int a;
49 int b[3];
52 struct S2 {
53 int c;
54 S1 d;
57 S2 glb_2 = { 22, .d.a = 44, .d.b[0] = 55, .d.b[1] = 66 };
59 void testNewThrowDelete() {
60 throw;
61 char *p = new char[10];
62 delete[] p;
65 int testArrayElement(int *x, int n) {
66 return x[n];
69 int testTernaryOp(int c, int x, int y) {
70 return c ? x : y;
73 S1 &testConstCast(const S1 &x) {
74 return const_cast<S1&>(x);
77 S1 &testStaticCast(S1 &x) {
78 return static_cast<S1&>(x);
81 S1 &testReinterpretCast(S1 &x) {
82 return reinterpret_cast<S1&>(x);
85 S1 &testDynamicCast(S1 &x) {
86 return dynamic_cast<S1&>(x);
89 int testScalarInit(int x) {
90 return int(x);
93 struct S {
94 float f;
95 double d;
97 struct T {
98 int i;
99 struct S s[10];
102 void testOffsetOf() {
103 __builtin_offsetof(struct T, s[2].d);
107 int testDefaultArg(int a = 2*2) {
108 return a;
111 int testDefaultArgExpr() {
112 return testDefaultArg();
115 template <typename T> // T has TemplateTypeParmType
116 void testTemplateTypeParmType(int i);
118 void useTemplateType() {
119 testTemplateTypeParmType<char>(4);
122 const bool ExpressionTrait = __is_lvalue_expr(1);
123 const unsigned ArrayRank = __array_rank(int[10][20]);
124 const unsigned ArrayExtent = __array_extent(int[10][20], 1);
126 constexpr int testLambdaAdd(int toAdd) {
127 const int Captured1 = 1, Captured2 = 2;
128 constexpr auto LambdaAdd = [Captured1, Captured2](int k) -> int {
129 return Captured1 + Captured2 + k;
131 return LambdaAdd(toAdd);
134 template<typename T>
135 struct TestLambdaTemplate {
136 T i, j;
137 TestLambdaTemplate(T i, const T &j) : i(i), j(j) {}
138 T testLambda(T k) {
139 return [this](T k) -> decltype(auto) { return i + j + k; }(k);