xref: /aosp_15_r20/external/clang/test/CodeGen/cxx-default-arg.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t
2*67e74705SXin Li 
3*67e74705SXin Li // Note-LABEL: define CLANG_GENERATE_KNOWN_GOOD and compile to generate code
4*67e74705SXin Li // that makes all of the defaulted arguments explicit. The resulting
5*67e74705SXin Li // byte code should be identical to the compilation without
6*67e74705SXin Li // CLANG_GENERATE_KNOWN_GOOD.
7*67e74705SXin Li #ifdef CLANG_GENERATE_KNOWN_GOOD
8*67e74705SXin Li #  define DEFARG(...) __VA_ARGS__
9*67e74705SXin Li #else
10*67e74705SXin Li #  define DEFARG(...)
11*67e74705SXin Li #endif
12*67e74705SXin Li 
13*67e74705SXin Li extern int x;
14*67e74705SXin Li struct S { float x; float y; } s;
15*67e74705SXin Li double _Complex c;
16*67e74705SXin Li 
17*67e74705SXin Li void f(int i = 0, int j = 1, int k = x, struct S t = s, double _Complex d = c);
18*67e74705SXin Li 
g()19*67e74705SXin Li void g() {
20*67e74705SXin Li   f(0, 1, x, s DEFARG(, c));
21*67e74705SXin Li   f(0, 1, x DEFARG(, s, c));
22*67e74705SXin Li   f(0, 1 DEFARG(, x, s, c));
23*67e74705SXin Li   f(0 DEFARG(, 1, x, s, c));
24*67e74705SXin Li   f(DEFARG(0, 1, x, s, c));
25*67e74705SXin Li }
26