This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: confused by code in C++ parser
- To: Zack Weinberg <zackw at stanford dot edu>
- Subject: Re: confused by code in C++ parser
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Thu, 21 Jun 2001 09:36:19 +0100
- CC: gcc at gcc dot gnu dot org
- Organization: Codesourcery LLC
- References: <20010620131957.B12387@stanford.edu>
Zack Weinberg wrote:
>
> This is (a slightly edited form of) the primary: string-constant rule
> in the C++ parser.
>
> | STRING
> {
> /* c_build_string doesn't set up TYPE_MAIN_VARIANT of
> a const array the way we want, so fix it. */
> if (flag_const_strings)
> TREE_TYPE ($$) = build_cplus_array_type
> (TREE_TYPE (TREE_TYPE ($$)),
> TYPE_DOMAIN (TREE_TYPE ($$)));
> }
>
> Can someone please explain to me what c_build_string (formerly
> combine_strings) gets wrong about the type of a string constant for
> C++, and what the correct type is? Thanks.
It's to do with array types. And yes, I think it could be done better.
There is a difference between C & C++ as to how const qualified
array types are represented. In the c front end, they ARRAY_TYPE is
qualified, in the c++ front end the outermost non-ARRAY_TYPE is qualified.
That's why build_cplus_array_type is there. Why the flag_const_string
is there, I don't know -- I think it's always 1.
We really should have some language dependant callback to do this right
in the first place -- as Mark found out when fixing some dwarf debug
output problem which had the same cause.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org