From patchwork Thu Jun 10 23:45:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWFudWVsIEzDs3Blei1JYsOhw7Fleg==?= X-Patchwork-Id: 55278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id BB1F1B7DBE for ; Fri, 11 Jun 2010 09:45:43 +1000 (EST) Received: (qmail 29623 invoked by alias); 10 Jun 2010 23:45:42 -0000 Received: (qmail 29613 invoked by uid 22791); 10 Jun 2010 23:45:41 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM X-Spam-Check-By: sourceware.org Received: from mail-ww0-f47.google.com (HELO mail-ww0-f47.google.com) (74.125.82.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 Jun 2010 23:45:36 +0000 Received: by wwb17 with SMTP id 17so377613wwb.20 for ; Thu, 10 Jun 2010 16:45:34 -0700 (PDT) Received: by 10.216.88.203 with SMTP id a53mr101529wef.44.1276213534209; Thu, 10 Jun 2010 16:45:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.21.6 with HTTP; Thu, 10 Jun 2010 16:45:14 -0700 (PDT) In-Reply-To: References: <20100607005213.GQ19235@codesourcery.com> <4C0E4E60.6010905@redhat.com> <4C0E6C5C.1060003@redhat.com> From: =?ISO-8859-1?Q?Manuel_L=F3pez=2DIb=E1=F1ez?= Date: Fri, 11 Jun 2010 01:45:14 +0200 Message-ID: Subject: Re: [PATCH,c++] use XALLOCAVEC in the C++ front-end To: "Joseph S. Myers" Cc: Jason Merrill , Nathan Froyd , gcc-patches@gcc.gnu.org X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 9 June 2010 22:35, Joseph S. Myers wrote: > On Wed, 9 Jun 2010, Manuel López-Ibáñez wrote: > >> note: to be safe all intermediate pointers must be equally qualified > > The requirement is not that they be equally qualified, it's that they be > const-qualified.  (That is, if you are adding "volatile" qualifiers, > "const" is still needed at intermediate levels; you can convert char ** to > volatile char *const * but not to volatile char *volatile *.) Bootstrapped and regression tested on x86_64-linux-gnu. OK for trunk? 2010-06-11 Manuel López-Ibáñez * c-typeck.c (handle_warn_cast_qual): Add loc parameter. Improve warning message. (build_c_cast): Pass location to handle_warn_cast_qual. Index: gcc/c-typeck.c =================================================================== --- gcc/c-typeck.c (revision 160464) +++ gcc/c-typeck.c (working copy) @@ -4411,16 +4411,17 @@ build_compound_expr (location_t loc, tre return ret; } /* Issue -Wcast-qual warnings when appropriate. TYPE is the type to which we are casting. OTYPE is the type of the expression being - cast. Both TYPE and OTYPE are pointer types. -Wcast-qual appeared - on the command line. Named address space qualifiers are not handled - here, because they result in different warnings. */ + cast. Both TYPE and OTYPE are pointer types. LOC is the location + of the cast. -Wcast-qual appeared on the command line. Named + address space qualifiers are not handled here, because they result + in different warnings. */ static void -handle_warn_cast_qual (tree type, tree otype) +handle_warn_cast_qual (location_t loc, tree type, tree otype) { tree in_type = type; tree in_otype = otype; int added = 0; int discarded = 0; @@ -4449,19 +4450,19 @@ handle_warn_cast_qual (tree type, tree o } while (TREE_CODE (in_type) == POINTER_TYPE && TREE_CODE (in_otype) == POINTER_TYPE); if (added) - warning (OPT_Wcast_qual, "cast adds %q#v qualifier to function type", - added); + warning_at (loc, OPT_Wcast_qual, + "cast adds %q#v qualifier to function type", added); if (discarded) /* There are qualifiers present in IN_OTYPE that are not present in IN_TYPE. */ - warning (OPT_Wcast_qual, - "cast discards %q#v qualifier from pointer target type", - discarded); + warning_at (loc, OPT_Wcast_qual, + "cast discards %q#v qualifier from pointer target type", + discarded); if (added || discarded) return; /* A cast from **T to const **T is unsafe, because it can cause a @@ -4490,14 +4491,14 @@ handle_warn_cast_qual (tree type, tree o in_type = TREE_TYPE (in_type); in_otype = TREE_TYPE (in_otype); if ((TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype)) != 0 && !is_const) { - int added = TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype); - warning (OPT_Wcast_qual, - ("new %qv qualifier in middle of multi-level non-const cast " - "is unsafe"), added); + warning_at (loc, OPT_Wcast_qual, + G_("to be safe all intermediate pointers in cast from " + "%qT to %qT must be % qualified"), + otype, type); break; } if (is_const) is_const = TYPE_READONLY (in_type); } @@ -4597,11 +4598,11 @@ build_c_cast (location_t loc, tree type, /* Optionally warn about potentially worrisome casts. */ if (warn_cast_qual && TREE_CODE (type) == POINTER_TYPE && TREE_CODE (otype) == POINTER_TYPE) - handle_warn_cast_qual (type, otype); + handle_warn_cast_qual (loc, type, otype); /* Warn about conversions between pointers to disjoint address spaces. */ if (TREE_CODE (type) == POINTER_TYPE && TREE_CODE (otype) == POINTER_TYPE