From patchwork Sun Apr 15 17:02:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 152672 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 A32C5B6FD1 for ; Mon, 16 Apr 2012 03:02:33 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1335114153; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=9O4KwJg WAp9oVZeQ/8/ALDNAFdY=; b=p0ZOjddZOqyFsWy7FHVoLXy/y5HZMAeLz6v5ODK 6rfkQlW01+appQdsgBy1nIoUvNtGDTrN/Z2YyTCTQwHTfR79sMAPw7AkGndszd/x 5OXaCbTtj616kz9RpjVbrthU3DQ+qGYXxVSMCoMyyAXl1xZtgbTQjeN7WaolOrEg 4VxU= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=FWRwhbPdxGI8po3GRo4FneCPccv5czIyBsLRFGEcEue0hm33LjAnaJCme0J3In 7s12pzFds+zo8VmD/nYgbMgGNY9uX61h/NfHireMKPnugJN3F1T85WQv6lUNIBRY Oe7bssS4ksiqmDoojqsO6YaDqEXYSg0/YBlrVz8UAlCr0=; Received: (qmail 30042 invoked by alias); 15 Apr 2012 17:02:29 -0000 Received: (qmail 30033 invoked by uid 22791); 15 Apr 2012 17:02:28 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, SPF_HELO_PASS, TW_CX, 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; Sun, 15 Apr 2012 17:02:13 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3FH2C3k026685 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 15 Apr 2012 13:02:12 -0400 Received: from [10.3.113.15] ([10.3.113.15]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3FH2BX6019297 for ; Sun, 15 Apr 2012 13:02:12 -0400 Message-ID: <4F8AFF13.3090500@redhat.com> Date: Sun, 15 Apr 2012 13:02:11 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/52818 (%ld in C++11) 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 C++11 inherits from C99, so we shouldn't complain about using %ld in that mode. Tested x86_64-pc-linux-gnu, applying to trunk. commit 4433edb6e099fbb6251c1ab76266108c45582ebc Author: Jason Merrill Date: Fri Apr 13 16:03:59 2012 -0400 PR c++/52818 * c-format.c (CPLUSPLUS_STD_VER): C++11 inherits from C99. (C_STD_NAME): Distinguish between C++98 and C++11. diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index 9fabc39..b967492 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -334,7 +334,7 @@ decode_format_attr (tree args, function_format_info *info, int validated_p) /* The C standard version C++ is treated as equivalent to or inheriting from, for the purpose of format features supported. */ -#define CPLUSPLUS_STD_VER STD_C94 +#define CPLUSPLUS_STD_VER (cxx_dialect < cxx11 ? STD_C94 : STD_C99) /* The C standard version we are checking formats against when pedantic. */ #define C_STD_VER ((int) (c_dialect_cxx () \ ? CPLUSPLUS_STD_VER \ @@ -345,7 +345,8 @@ decode_format_attr (tree args, function_format_info *info, int validated_p) pedantic. FEATURE_VER is the version in which the feature warned out appeared, which is higher than C_STD_VER. */ #define C_STD_NAME(FEATURE_VER) (c_dialect_cxx () \ - ? "ISO C++" \ + ? (cxx_dialect < cxx11 ? "ISO C++98" \ + : "ISO C++11") \ : ((FEATURE_VER) == STD_EXT \ ? "ISO C" \ : "ISO C90")) diff --git a/gcc/testsuite/g++.dg/warn/format8.C b/gcc/testsuite/g++.dg/warn/format8.C new file mode 100644 index 0000000..ffceb79 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/format8.C @@ -0,0 +1,7 @@ +// PR c++/52818 +// { dg-options "-pedantic-errors -Wformat" } + +extern "C" int printf (const char *, ...); +void f() { + printf("%lf", 0.0); // { dg-warning "%lf" "" { target c++98 } } +}