On Wed, 2 Mar 2011, Richard Guenther wrote:

> 2011-03-02  Richard Guenther  <rguent...@suse.de>
> 
>       PR c/47939
>       * c-decl.c (grokdeclarator): Drop to the main variant only
>       for array types.  Drop flag_gen_aux_info check.

I can't convince myself that this is safe - that is, that it will maintain 
the invariant that TYPE_MAIN_VARIANT for an array type always points to a 
version where the ultimate element type is unqualified.  The problem would 
be where the type from the declaration specifiers is a qualified type, not 
an array type, but becomes an array element type through array declarators 
being processed by grokdeclarator, and so arrays are built up directly 
with qualified element type without the unqualified variants being built 
first to become the main variants.  It certainly appears that in a case 
such as

typedef const int T;
T a[10];
const int b[10];

you get multiple copies of the const int[10] type, some of which have a 
const int[10] variant as their main variant (incorrect) and some of which 
have an int[10] variant as their main variant (correct); the canonical 
types look rather odd as well.  It's reasonable have multiple copies here 
- for the type T[10] to remember the type name T it was derived from - but 
in such a case they should still all be on the variant chain for a single 
int[10] main variant.

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to