[clang] [RISCV] Handle empty structs/unions passing in C++ (PR #97315)

Sudharsan Veeravalli via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 5 21:27:14 PDT 2024


svs-quic 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.

Thanks Eli. I have made these changes.

https://github.com/llvm/llvm-project/pull/97315


More information about the cfe-commits mailing list