aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Wilson <wilson@gcc.gnu.org>1993-05-03 17:10:51 -0700
committerJim Wilson <wilson@gcc.gnu.org>1993-05-03 17:10:51 -0700
commit50e658546e5c22ddf703ef305282840fedb07d8f (patch)
tree8f54c059f3a8b67028e639739587b415d9bd1d4d
parent1d77b9c11d2145e67b4b5957ea7bb792d1c7dfb1 (diff)
downloadgcc-50e658546e5c22ddf703ef305282840fedb07d8f.zip
gcc-50e658546e5c22ddf703ef305282840fedb07d8f.tar.gz
gcc-50e658546e5c22ddf703ef305282840fedb07d8f.tar.bz2
(grokdeclarator, ARRAY_REF case): Build array type, and
then build the variant array type. From-SVN: r4314
-rw-r--r--gcc/c-decl.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 8180ba7..fa7d5bc 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -4189,15 +4189,19 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
warning ("array type has incomplete element type");
#endif
- /* Build the array type itself.
- Merge any constancy or volatility into the target type. */
-
#if 0 /* We shouldn't have a function type here at all!
Functions aren't allowed as array elements. */
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
&& (constp || volatilep))
pedwarn ("ANSI C forbids const or volatile function types");
#endif
+
+ /* Build the array type itself, then merge any constancy or
+ volatility into the target type. We must do it in this order
+ to ensure that the TYPE_MAIN_VARIANT field of the array type
+ is set correctly. */
+
+ type = build_array_type (type, itype);
if (constp || volatilep)
type = c_build_type_variant (type, constp, volatilep);
@@ -4207,7 +4211,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
volatilep = 0;
#endif
- type = build_array_type (type, itype);
if (size_varies)
C_TYPE_VARIABLE_SIZE (type) = 1;
}