scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit b3a6d0e78452e23b9d2044454aec454d39631263
parent 47748d1745b972b61f51f7fb3fa34c3e245196d8
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  8 Jan 2016 11:19:37 +0100

Add tests for ugly ternary operator

Diffstat:
cc1/tests/test041.c | 39+++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+), 0 deletions(-)

diff --git a/cc1/tests/test041.c b/cc1/tests/test041.c @@ -0,0 +1,39 @@ +/* +name: TEST041 +description: Test for bug parsing ternary operators +output: +test041.c:36: error: type mismatch in conditional expression +F1 I +G2 F1 main +{ +\ +A3 I i +A4 P p +S6 foo +M7 I i +A8 S6 foo + A3 A3 #I0 !I #W0 #W0 ?W gI :I + A4 A3 #I0 !I #P0 #P0 ?P :P + A4 A3 #I0 !I #P0 #P0 ?P :P + A4 A3 #I0 !I #P0 #P0 ?P :P +test041.c:36: error: incompatible types when assigning +test041.c:37: error: used struct/union type value where scalar is required +test041.c:38: warning: 'i' defined but not used +test041.c:38: warning: 'foo' defined but not used +*/ + +int +main(void) +{ + int i; + void *p; + struct foo {int i;} foo; + + i = i ? 0 : 0l; + p = i ? (void *) 0 : 0; + p = i ? 0 : (void *) 0; + p = i ? 0 : (const void *) 0; + p = i ? 2 : p; + foo ? 1 : 2; +} +