From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2778 invoked by alias); 1 Jan 2007 22:16:00 -0000 Received: (qmail 2765 invoked by uid 22791); 1 Jan 2007 22:15:58 -0000 X-Spam-Check-By: sourceware.org Received: from w099.z064220152.sjc-ca.dsl.cnc.net (HELO bluesmobile.corp.specifix.com) (64.220.152.99) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 01 Jan 2007 22:15:50 +0000 Received: from localhost.localdomain (bluesmobile.specifix.com [64.220.152.99]) by bluesmobile.corp.specifix.com (Postfix) with ESMTP id 054063B92F; Mon, 1 Jan 2007 14:15:47 -0800 (PST) Subject: RE: how to support C type qualifiers applied to arrays? From: Jim Wilson To: Gary Funck Cc: gdb@sourceware.org, 'Daniel Jacobowitz' In-Reply-To: <200612141837.kBEIb7Lw024917@intrepid.intrepid.com> References: <200612141837.kBEIb7Lw024917@intrepid.intrepid.com> Content-Type: text/plain Date: Mon, 01 Jan 2007 22:16:00 -0000 Message-Id: <1167689747.2505.17.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 (2.6.3-1.fc5.5) Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00007.txt.bz2 On Thu, 2006-12-14 at 12:22 -0800, Gary Funck wrote: > The main difficulty is that GCC doesn't create new qualified > types for declarations. Rather, it sets TREE_READONLY() > and TREE_THIS_VOLATILE() in the DECL node for declarations > such as: > volatile int A[10]; If you look at the types created by the C front end, they are OK. c_build_qualified_type knows how to handle an array correctly. The problem arises in the DWARF2 output code. gen_type_die calls type_main_variant for all types other than vector types, which strips off the const and volatile type modifiers. Then it clumsily tries to put them back later in gen_variable_die, except that for array types, it puts them back in the wrong place. This seems to answer the question I asked long ago. Why are we trying to put back qualifiers from the decl? Because gen_type_die stripped them off. This seems wrong. If we fix gen_type_die to stop calling type_main_variant, and if we fix gen_variable_die to stop adding back the type qualifiers, then I get the right result. So I think I was on the right track before, we just need another little change to gen_type_die in addition to what I already described. I haven't investigated this in detail yet. There may be other parts of the code that expect to see a type main variant here, so we might need other cascading fixes. This still seems fixable to me though. -- Jim Wilson, GNU Tools Support, http://www.specifix.com