From: Niklas Hallqvist Date: Sat, 30 Jan 1993 06:06:09 +0000 (+0000) Subject: c-common.c (c_build_type_variant): Moved here from c-decl.c. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0b73773ce6d43ab6557a9ae8b85913a78f98099b;p=gcc.git c-common.c (c_build_type_variant): Moved here from c-decl.c. * 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 --- diff --git a/gcc/c-common.c b/gcc/c-common.c index 3c51f0bf7b5..74168cbf275 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -24,6 +24,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "flags.h" #include +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); } } + +/* 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); +}