view gcc/testsuite/gcc.dg/init-excess-2.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* Test for diagnostics about excess initializers when using a macro
   defined in a system header:
   c/71115 - Missing warning: excess elements in struct initializer.  */
/* { dg-do compile } */
/* { dg-options "" } */
/* { dg-require-effective-target int32plus } */

#include <stddef.h>

int* a[1] = {
  0,
  NULL              /* { dg-warning "excess elements|near init" } */
};

const char str[1] = {
  0,
  NULL              /* { dg-warning "excess elements|near init" } */
};

struct S {
  int *a;
} s = {
  0,
  NULL              /* { dg-warning "excess elements|near init" } */
};

struct __attribute__ ((designated_init)) S2 {
  int *a;
} s2 = {
  NULL              /* { dg-warning "positional initialization|near init" } */
};

union U {
  int *a;
} u = {
  0,
  NULL              /* { dg-warning "excess elements|near init" } */
};

int __attribute__ ((vector_size (16))) ivec = {
  0, 0, 0, 0,
  NULL              /* { dg-warning "excess elements|near init" } */
};

int* scal = {
  0,
  NULL              /* { dg-warning "excess elements|near init" } */
};