On Tue, Nov 11, 2014 at 11:27:21PM +0530, Prathamesh Kulkarni wrote:
> I tried the following:
> struct A { struct B {}; int x; } /* { dg-warning "empty struct has
> size 0 in C" } */
>                                            /* { dg-bogus "delcaration
> does not declare anything" } */
> but it fails in excess errors.
> How do I resolve this ?
 
Try something like
/* { dg-warning "empty struct has size 0 in C|declaration does not declare 
anything" } */

> Index: gcc/c/c-decl.c
> ===================================================================
> --- gcc/c/c-decl.c    (revision 217287)
> +++ gcc/c/c-decl.c    (working copy)
> @@ -7506,12 +7506,28 @@
>  /* Finish up struct info used by -Wc++-compat.  */
>  
>  static void
> -warn_cxx_compat_finish_struct (tree fieldlist)
> +warn_cxx_compat_finish_struct (tree fieldlist, enum tree_code code, 
> location_t record_loc)

This line is too long, please indent the last argument properly on
next line.

>    unsigned int ix;
>    tree x;
>    struct c_binding *b;
>  
> +  if (fieldlist == NULL_TREE)
> +    {
> +      if (code == RECORD_TYPE)
> +     {
> +       warning_at (record_loc, OPT_Wc___compat,
> +                   "empty struct has size 0 in C, size 1 in C++");
> +     }
> +      else if (code == UNION_TYPE)
> +     {
> +       warning_at (record_loc, OPT_Wc___compat,
> +                   "empty union has size 0 in C, size 1 in C++");
> +     }

Drop the { } around warning_at's.

> +      else
> +     gcc_unreachable ();
> +    }
> +

I don't think this is needed.

Thanks,

        Marek

Reply via email to