1/* { dg-do compile } */ 2/* { dg-options "-O1 -fdump-tree-optimized" } */ 3 4/* Tests for SRA of unions. */ 5 6 7typedef union testunion 8{ 9 double d; 10 char f1; 11} testunion; 12 13void 14copyunion1 (testunion param) 15{ 16 testunion local; 17 param.f1 = 0; 18 local = param; 19 if (local.f1 != 0) 20 link_error (); 21} 22 23void 24copyunion11 (testunion *param) 25{ 26 testunion local; 27 param->f1 = 0; 28 local = *param; 29 if (local.f1 != 0) 30 link_error (); 31} 32 33void 34copyunion111 (testunion param) 35{ 36 testunion *local = ¶m; 37 param.f1 = 0; 38 if (local->f1 != 0) 39 link_error (); 40} 41 42testunion globuf; 43void 44copyunion1111 (void) 45{ 46 testunion local; 47 globuf.f1 = 0; 48 local = globuf; 49 if (local.f1 != 0) 50 link_error (); 51} 52 53void 54copyunion11111 (void) 55{ 56 testunion *local = &globuf; 57 globuf.f1 = 0; 58 if (local->f1 != 0) 59 link_error (); 60} 61 62void 63copyunion111111 (testunion param) 64{ 65 static testunion local; 66 param.f1 = 0; 67 local = param; 68 if (local.f1 != 0) 69 link_error (); 70} 71 72/* There should be no reference to link_error. */ 73/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */ 74/* { dg-final { cleanup-tree-dump "optimized" } } */ 75