[PATCH] Fixes canonical types PRs c++/33977, c++/33886
Doug Gregor
doug.gregor@gmail.com
Mon Nov 5 15:53:00 GMT 2007
(Mark, I'm directing this to you since you're the only maintainer who
has studied the canonical types system.)
This patches fixes PRs c++/33977 (P1) and c++/33886 (P3), both of
which stem from the same problem with canonical types and arrays. I'm
continually amazed by the sheer number of places where we copy,
create, and munge ARRAY_TYPE nodes. Here, I stumbled upon the
duplicate code for creating cv-qualified (array) types in C
(c_build_qualified_type) and C++ (cp_build_qualified_type). The latter
handles canonical types for cv-qualified arrays, because C++ uses
canonical types; the former does not. However, through
cp_complete_array_type and its call to complete_array_type, the C++
front end can actually end up calling c_build_qualified_type,
thwarting the canonical types system. Gaaa!
The fix, in this case, was to move c_build_qualified_type into
c-typeck.c, so it will only be available in the C front end. Then, the
C++ front end defines its own c_build_qualified_type, which merely
redirects to cp_build_qualified_type.
Tested i686-pc-linux-gnu. Okay for mainline?
- Doug
2007-11-05 Douglas Gregor <doug.gregor@gmail.com>
PR c++/33977
PR c++/33886
* tree.c (c_build_qualified_type): Define bridge to
cp_build_qualified_type.
2007-11-05 Douglas Gregor <doug.gregor@gmail.com>
PR c++/33977
PR c++/33886
* c-common.c (c_build_qualified_type): Moved to c-typeck.c.
(complete_array_type): Set canonical type appropriately.
* c-typeck.c (c_build_qualified_type): Moved from c-common.c. The
C and C++ front ends now have different versions of this function,
because the C++ version needs to maintain canonical types here.
2007-11-05 Douglas Gregor <doug.gregor@gmail.com>
PR c++/33977
PR c++/33886
* g++.dg/other/canon-array.C: New.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: canon-array.patch
Type: text/x-patch
Size: 6704 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20071105/28eb665b/attachment.bin>
More information about the Gcc-patches
mailing list