This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch - [PR 12165] Typedef'ed array variables ignore typedef's const qualifier


Hi,

If code below is compiled with gcc

---------------------------------------
typedef const int ACINT[2] ;
static ACINT myArray = {2,4};
---------------------------------------

the array myArray should be in rodata section but it is placed in data section.
With g++, myArray is placed in rodata section.

The problem only appears for typedef const array_type.

The patch below, regtested on i686-pc-linux-gnu works for me. It is based on the  cc1plus implemetation.

The problem is observed in both 3.3 and 3.4.

-Dhananjay

2003-09-19  Dhananjay Deshpande <dhananjayd@kpitcummins.com>

        PR c/12165
        * c-decl.c (grokdeclarator): Set type qualifiers of array elements to array_type

==================================================================================
--- gcc/c-decl.c.old	2003-09-19 14:51:04.000000000 +0530
+++ gcc/c-decl.c	2003-09-19 14:52:04.000000000 +0530
@@ -3621,6 +3621,9 @@
 		| (restrictp ? TYPE_QUAL_RESTRICT : 0)
 		| (volatilep ? TYPE_QUAL_VOLATILE : 0));
 
+  /* Apply qualifiers of array elements to array type */
+  type_quals |= TYPE_QUALS (strip_array_types (type));
+
   /* Warn if two storage classes are given. Default to `auto'.  */
 
   {
==================================================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]