c-common.c (c_build_type_variant): Moved here from c-decl.c.
authorNiklas Hallqvist <niklas@gnu.org>
Sat, 30 Jan 1993 06:06:09 +0000 (06:06 +0000)
committerNiklas Hallqvist <niklas@gnu.org>
Sat, 30 Jan 1993 06:06:09 +0000 (06:06 +0000)
* c-common.c (c_build_type_variant): Moved here from c-decl.c.
Redirected the TYPE_MAIN_VARIANT to the "real" main variant.
Build the possibly new array type on the permanent obstack if it
        the original type was permanent.
(permanent_obstack): Added extern declaration.

From-SVN: r3388

gcc/c-common.c

index 3c51f0bf7b5736a7f2ccc188e8696b19801fc4d5..74168cbf2756b0687df7e98e4c66605bbc6018e1 100644 (file)
@@ -24,6 +24,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "flags.h"
 #include <stdio.h>
 
+extern struct obstack permanent_obstack;
+
 /* Make bindings for __FUNCTION__ and __PRETTY_FUNCTION__.  */
 
 void
@@ -1023,3 +1025,28 @@ get_directive_line (finput)
       char_escaped = (c == '\\' && ! char_escaped);
     }
 }
+\f
+/* Make a variant type in the proper way for C/C++, propagating qualifiers
+   down to the element type of an array.  */
+
+tree
+c_build_type_variant (type, constp, volatilep)
+     tree type;
+     int constp, volatilep;
+{
+  if (TREE_CODE (type) == ARRAY_TYPE)
+    {
+      tree real_main_variant = TYPE_MAIN_VARIANT (type);
+      int permanent = TREE_PERMANENT (type);
+
+      if (permanent)
+       push_obstacks (&permanent_obstack, &permanent_obstack);
+      type = build_array_type (c_build_type_variant (TREE_TYPE (type),
+                                                    constp, volatilep),
+                              TYPE_DOMAIN (type));
+      TYPE_MAIN_VARIANT (type) = real_main_variant;
+      if (permanent)
+       pop_obstacks ();
+    }
+  return build_type_variant (type, constp, volatilep);
+}