From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17693 invoked by alias); 23 Sep 2010 22:37:21 -0000 Received: (qmail 17635 invoked by uid 22791); 23 Sep 2010 22:37:20 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 23 Sep 2010 22:37:15 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8NMbDLR005221 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 23 Sep 2010 18:37:13 -0400 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8NMbBT7029590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 23 Sep 2010 18:37:12 -0400 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o8NMbAmW011955; Fri, 24 Sep 2010 00:37:10 +0200 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o8NMb97S011942; Fri, 24 Sep 2010 00:37:09 +0200 Date: Fri, 24 Sep 2010 04:50:00 -0000 From: Jan Kratochvil To: Ken Werner Cc: gdb-patches@sourceware.org Subject: Re: [patch] const array types Message-ID: <20100923223709.GA25145@host1.dyn.jankratochvil.net> References: <201009151920.37105.ken@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201009151920.37105.ken@linux.vnet.ibm.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-09/txt/msg00424.txt.bz2 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: const struct { int x; } b1; __typeof__ (b1.x) b2; (gdb) ptype b1.x type = int ^^^ = The GDB (and possibly even GCC) bug. (gdb) ptype b2 type = const int ^^^^^^^^^ GCC is aware the element is in fact `const'. I would find this patch OK even if it fixes only the TYPE_CODE_ARRAY. > + while (TYPE_CODE (TYPE_TARGET_TYPE (inner_array)) == TYPE_CODE_ARRAY) The type can be opaque and TYPE_TARGET_TYPE is then NULL. Opaque type should not be possible to be produced for an array element but some `error' call would be nice there. > + make_cv_type (1, TYPE_VOLATILE (el_type), el_type, 0); ^ NULL? I would find NULL for a pointer parameter more readable. Thanks, Jan