Added checking for completeness of lvalue in conditional operator
authorAditya Singh <f20190478@goa.bits-pilani.ac.in>
Mon, 27 Mar 2023 18:45:43 +0000 (14:45 -0400)
committerAaron Ballman <aaron@aaronballman.com>
Mon, 27 Mar 2023 18:47:08 +0000 (14:47 -0400)
commitdedd7b6548f4a37f4f691aa0cd3a709756b7e794
treed6b41aba9139e46ac58369de5bbfd5c9ac4dfd9b
parentfd059ea7ec044198fd75bb2b3aa30734bcace33e
Added checking for completeness of lvalue in conditional operator

Given:
```
struct x y;
int main(void)
{
    (void)(1 ? y : y);
}
struct x {int i;};
```
The conditional operator(?:) requires the second and third operands to
be of compatible types. To be compatible, they also need to be
complete (however, both can be void). Therefore, the expected response
from clang after running the above code as a C program should be error
dialogue pointing out that both the types are incomplete hence
incompatible, but the code compiled without any errors.

The patch ensures the completeness in the CheckCondtionalOperand
function present in llvm-project/clang/lib/Sema/SemaChecking.cpp.

Fixes https://github.com/llvm/llvm-project/issues/59718
Differential Revision: https://reviews.llvm.org/D144358
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/incomplete-decl.c