On Friday, September 24, 2010 12:37:09 am Jan Kratochvil wrote: > On Wed, 15 Sep 2010 19:20:37 +0200, Ken Werner wrote: > > The attached patch changes the dwarf parsing of const types. In case the > > const qualifier is applied to an array type, the element type is so > > qualified, not the array type. Comments are welcome. > > I have filed now http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45765 as > I believe it could be fixed more at the DWARF producer side. > > It is questionable whether it gets accepted and fixed by GCC and whether > you would like it then fixed in GDB even for older GCCs and non-GCC > compilers. > > I believe besides TYPE_CODE_ARRAY the same logic should be applied even to > all the fields of TYPE_CODE_STRUCT and TYPE_CODE_UNION (excluding the > static fields). While ISO C99 does not say so (or does?) GCC behaves > correctly: C99 is pretty clear for const arrays but structs and unions seem to be different. Section 6.5.2.3 says that the result of the . and -> operators have the const version of the type. So, in that case we probably don't want to copy the type in the dwarf reader but alter the result types in case of field access. > I would find this patch OK even if it fixes only the TYPE_CODE_ARRAY. Thanks for reviewing. I've changed the last make_cv_type argument to NULL and attached a new version of that patch, OK to apply? > > + make_cv_type (1, TYPE_VOLATILE (el_type), el_type, 0); > > ^ NULL? > I would find NULL for a pointer parameter more readable. Fixed. Regards Ken