[clang] [RISCV] Handle empty structs/unions passing in C++ (PR #97315)
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 5 15:38:35 PDT 2024
topperc wrote:
> The current spec language is:
>
> > Empty structs or union arguments or return values are ignored by C compilers which support them as a non-standard extension. This is not the case for C++, which requires them to be sized types.
>
> So empty structs in C are ignored, empty structs in C++ are treated as non-empty.
>
> The "C++ struct containing an empty array" is sort of an edge case, since it's not actually legal C++, but the spec says the distinguishing factor is whether we're in C++ mode. And gcc seems to do that, so let's do the same thing. So instead of checking for `Size == 0`, check for `LangOpts.CPlusPlus`.
>
> Also, please add a release note for this.
gcc does ignore the empty array case for assigning argument registers in C++. Compare the two cases here https://godbolt.org/z/j4WP89rE8
https://github.com/llvm/llvm-project/pull/97315
More information about the cfe-commits
mailing list