Longsheng Mou 4461b69022
[X86_32][C++] fix 0 sized struct case in vaarg. (#86388)
struct SuperEmpty { struct{ int a[0];} b;};
Such 0 sized structs in c++ mode can not be ignored in i386 for that c++
fields are never empty.But when EmitVAArg, its size is 0, so that
va_list not increase.Maybe we can just Ignore this kind of arguments,
like X86_64 did. Fix #86385.
2024-08-02 09:20:49 +08:00

39 lines
776 B
C++

// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
// CHECK: _Z3fooRi(ptr inreg
void __attribute__ ((regparm (1))) foo(int &a) {
}
struct S1 {
int x;
S1(const S1 &y);
};
void __attribute__((regparm(3))) foo2(S1 a, int b);
// CHECK: declare void @_Z4foo22S1i(ptr inreg noundef, i32 inreg noundef)
void bar2(S1 a, int b) {
foo2(a, b);
}
struct S2 {
int x;
};
void __attribute__((regparm(3))) foo3(struct S2 a, int b);
// CHECK: declare void @_Z4foo32S2i(i32 inreg, i32 inreg noundef)
void bar3(struct S2 a, int b) {
foo3(a, b);
}
struct S3 {
struct {
struct {} b[0];
} a;
};
__attribute((regparm(2))) void foo4(S3 a, int b);
// CHECK: declare void @_Z4foo42S3i(i32 inreg noundef)
void bar3(S3 a, int b) {
foo4(a, b);
}