summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/init-bad-9.c
blob: 035d34940dd600b926d5e19c8d97df6e34b4e764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
/* PR c/71552 - Confusing error for incorrect struct initialization */
/* { dg-do compile } */

struct A { void *p; };
struct B { struct A *p; };
struct A a;

/* Verify that the initializer is diagnosed for its incompatibility
   with the type of the object being initialized, not for its lack
   of constness (which is a lesser problem).  */
struct B b = { a };   /* { dg-error "incompatible types when initializing" } */
struct B *p = a;      /* { dg-error "incompatible types when initializing" } */