From patchwork Tue Jul 27 06:56:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 59979 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 CDDD9B6F0E for ; Tue, 27 Jul 2010 16:54:18 +1000 (EST) Received: (qmail 6831 invoked by alias); 27 Jul 2010 06:54:17 -0000 Received: (qmail 6820 invoked by uid 22791); 27 Jul 2010 06:54:16 -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; Tue, 27 Jul 2010 06:54:09 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6R6roJd009044 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Jul 2010 02:53:50 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6R6rn4n027812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 27 Jul 2010 02:53:50 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o6R6uCio003960; Tue, 27 Jul 2010 08:56:13 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o6R6uBxH003958; Tue, 27 Jul 2010 08:56:11 +0200 Date: Tue, 27 Jul 2010 08:56:11 +0200 From: Jakub Jelinek To: "Joseph S. Myers" Cc: gcc-patches@gcc.gnu.org Subject: [C PATCH] Handle C_MAYBE_CONST_EXPR in diagnostic (PR c/45079) Message-ID: <20100727065611.GR18378@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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 Hi! As the testcase below shows, C_MAYBE_CONST_EXPR isn't handled by pp_c_expression. The following patch fixes that. Bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk/4.5? 2010-07-27 Jakub Jelinek PR c/45079 * c-pretty-print.c (pp_c_expression): Handle C_MAYBE_CONST_EXPR. * gcc.dg/pr45079.c: New test. Jakub --- gcc/c-family/c-pretty-print.c.jj 2010-06-07 11:24:57.000000000 +0200 +++ gcc/c-family/c-pretty-print.c 2010-07-26 16:41:12.000000000 +0200 @@ -2167,6 +2167,10 @@ pp_c_expression (c_pretty_printer *pp, t pp_string (pp, "({...})"); break; + case C_MAYBE_CONST_EXPR: + pp_c_expression (pp, C_MAYBE_CONST_EXPR_EXPR (e)); + break; + default: pp_unsupported_tree (pp, e); break; --- gcc/testsuite/gcc.dg/pr45079.c.jj 2010-07-26 16:44:37.000000000 +0200 +++ gcc/testsuite/gcc.dg/pr45079.c 2010-07-26 16:44:19.000000000 +0200 @@ -0,0 +1,10 @@ +/* PR c/45079 */ +/* { dg-do compile } */ + +void +foo (const char *p, int cond, int a, int b) +{ + p[cond ? a : b] = '\0'; /* { dg-error "assignment of read-only location" } */ +} + +/* { dg-bogus "not supported by" "" { target *-*-* } 0 } */