Home | History | Annotate | Line # | Download | only in lint1
d_c99_union_cast.c revision 1.6
      1 /*	$NetBSD: d_c99_union_cast.c,v 1.6 2021/08/03 20:46:10 rillig Exp $	*/
      2 # 3 "d_c99_union_cast.c"
      3 
      4 /* C99 does not define union cast, it is a GCC extension. */
      5 
      6 /* lint1-flags: -Sw */
      7 
      8 struct bar {
      9 	int a;
     10 	int b;
     11 };
     12 
     13 union foo {
     14 	struct bar *a;
     15 	int b;
     16 };
     17 
     18 void
     19 foo(struct bar *a)
     20 {
     21 	/* TODO: warn about union casts in general */
     22 	a = ((union foo)a).a;
     23 	/* expect+1: error: type 'pointer to char' is not a member of 'union foo' [329] */
     24 	a = ((union foo)"string");
     25 	a->a++;
     26 }
     27