re PR c++/11614 (Incorrect handling of pointers to arrays)
cp: PR c++/11614 * decl.c (grokdeclarator): An array member is only a flexible array member if the field itself is the array. testsuite: * g++.dg/ext/flexary1.C: New test. From-SVN: r69673
This commit is contained in:
parent
a2f7be91fc
commit
817aed6fc3
4 changed files with 53 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
|||
2003-07-22 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
PR c++/11614
|
||||
* decl.c (grokdeclarator): An array member is only a flexible
|
||||
array member if the field itself is the array.
|
||||
|
||||
2003-07-22 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
|
||||
|
||||
PR c++/10793
|
||||
|
|
|
@ -10615,14 +10615,18 @@ grokdeclarator (tree declarator,
|
|||
register tree size;
|
||||
|
||||
size = TREE_OPERAND (declarator, 1);
|
||||
|
||||
/* VC++ spells a zero-sized array with []. */
|
||||
if (size == NULL_TREE && decl_context == FIELD && ! staticp
|
||||
&& ! RIDBIT_SETP (RID_TYPEDEF, specbits))
|
||||
size = integer_zero_node;
|
||||
|
||||
declarator = TREE_OPERAND (declarator, 0);
|
||||
|
||||
/* C99 spells a flexible array member []. */
|
||||
if (size == NULL_TREE && decl_context == FIELD && ! staticp
|
||||
&& ! RIDBIT_SETP (RID_TYPEDEF, specbits)
|
||||
&& !(declarator &&
|
||||
(TREE_CODE (declarator) == CALL_EXPR
|
||||
|| TREE_CODE (declarator) == INDIRECT_REF
|
||||
|| TREE_CODE (declarator) == ADDR_EXPR
|
||||
|| TREE_CODE (declarator) == ARRAY_REF)))
|
||||
size = integer_zero_node;
|
||||
|
||||
type = create_array_type_for_decl (dname, type, size);
|
||||
|
||||
ctype = NULL_TREE;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2003-07-22 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* g++.dg/ext/flexary1.C: New test.
|
||||
|
||||
2003-07-22 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
|
||||
|
||||
PR c++/10793
|
||||
|
|
33
gcc/testsuite/g++.dg/ext/flexary1.C
Normal file
33
gcc/testsuite/g++.dg/ext/flexary1.C
Normal file
|
@ -0,0 +1,33 @@
|
|||
// { dg-do compile }
|
||||
|
||||
// Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
// Contributed by Nathan Sidwell 22 Jul 2003 <nathan@codesourcery.com>
|
||||
|
||||
// PR c++ 11614
|
||||
|
||||
typedef int ary_t[];
|
||||
|
||||
struct test
|
||||
{
|
||||
ary_t *b;
|
||||
int (*a)[]; // this is not a flexible array member
|
||||
};
|
||||
|
||||
void test(void)
|
||||
{
|
||||
struct test s;
|
||||
int (*a)[] = 0;
|
||||
ary_t *b = 0;
|
||||
|
||||
a = s.a;
|
||||
a = s.b;
|
||||
|
||||
s.a = a;
|
||||
s.b = a;
|
||||
|
||||
b = s.a;
|
||||
b = s.b;
|
||||
|
||||
s.a = b;
|
||||
s.b = b;
|
||||
}
|
Loading…
Add table
Reference in a new issue