c-typeck.c (set_init_index): Require designator to be of integer type.
* c-typeck.c (set_init_index): Require designator to be of integer type. testsuite: * gcc.dg/c99-init-3.c, gcc.dg/gnu99-init-2.c: New tests. * gcc.dg/noncompile/921102-1.c: Update expected error message. From-SVN: r85023
This commit is contained in:
parent
916c59199c
commit
3ea8cd0655
6 changed files with 37 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
2004-07-22 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* c-typeck.c (set_init_index): Require designator to be of integer
|
||||
type.
|
||||
|
||||
2004-07-22 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
PR c/11250
|
||||
|
|
|
@ -4956,6 +4956,13 @@ set_init_index (tree first, tree last)
|
|||
|
||||
designator_errorneous = 1;
|
||||
|
||||
if (!INTEGRAL_TYPE_P (TREE_TYPE (first))
|
||||
|| (last && !INTEGRAL_TYPE_P (TREE_TYPE (last))))
|
||||
{
|
||||
error_init ("array index in initializer not of integer type");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((TREE_CODE (first) == NOP_EXPR
|
||||
|| TREE_CODE (first) == CONVERT_EXPR
|
||||
|| TREE_CODE (first) == NON_LVALUE_EXPR)
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2004-07-22 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* gcc.dg/c99-init-3.c, gcc.dg/gnu99-init-2.c: New tests.
|
||||
* gcc.dg/noncompile/921102-1.c: Update expected error message.
|
||||
|
||||
2004-07-22 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
PR c/11250
|
||||
|
|
8
gcc/testsuite/gcc.dg/c99-init-3.c
Normal file
8
gcc/testsuite/gcc.dg/c99-init-3.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Test for designated initializers: array designators must be of
|
||||
integer type. */
|
||||
/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
|
||||
|
||||
int a[] = { [(void *)0] = 1 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "integer type|near init" "pointer designator" { target *-*-* } 7 } */
|
11
gcc/testsuite/gcc.dg/gnu99-init-2.c
Normal file
11
gcc/testsuite/gcc.dg/gnu99-init-2.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* Test for designated initializers: array designators must be of
|
||||
integer type. Test for index ranges (GNU extension). */
|
||||
/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=gnu99" } */
|
||||
|
||||
int a[] = { [(void *)0 ... 0] = 1 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "integer type|near init" "pointer designator" { target *-*-* } 7 } */
|
||||
|
||||
int b[] = { [0 ... (void *)0] = 1 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "integer type|near init" "pointer designator" { target *-*-* } 10 } */
|
|
@ -1 +1 @@
|
|||
int x[]={[0.3 ... 4.6]9}; /* { dg-error "nonconstant array|near init" } */
|
||||
int x[]={[0.3 ... 4.6]9}; /* { dg-error "not of integer type|near init" } */
|
||||
|
|
Loading…
Add table
Reference in a new issue