From patchwork Fri Aug 19 08:45:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 74218 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp202145qga; Fri, 19 Aug 2016 01:45:34 -0700 (PDT) X-Received: by 10.66.155.129 with SMTP id vw1mr11622826pab.148.1471596334522; Fri, 19 Aug 2016 01:45:34 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y5si7258427pax.43.2016.08.19.01.45.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Aug 2016 01:45:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-434265-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-434265-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-434265-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=vr88I7/OOZyhADOBTfiQkY3OW5BWWx8NXDQd5hPMh5b+Fa rh1kko1xdMLeK47RhCHkG9WKJVnDNnuYx5/l/ZKru9HfjRp4ojcBzBR7Sjrq43DE vUJxd41Z5fmOvclDwh1vg3jRNvmFUsQOR0xxUOQ5N5DWXoq2xk5ivmSmppf/g= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=SjDFjsY4ugT1I54VBBDSLD3PL6g=; b=SRJL5SQTAasXEnSECp01 vSlt3PFigKPabFZlcqs0/HBSImvxd6EH+Re7V4bNDmeDzK6FoYQreH19GInRO8CV wrbM7j5867Q3HnbpYHHUDiXQhl6Fqi2aWrtqekkzJSY3h7LiR0RiFkyp5hX4l+Vc etrvSm+p0YjVjKQkkZhi/X8= Received: (qmail 2999 invoked by alias); 19 Aug 2016 08:45:21 -0000 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 Received: (qmail 955 invoked by uid 89); 19 Aug 2016 08:45:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=appends, UD:expr.c, expr.c, exprc X-HELO: mail-io0-f171.google.com Received: from mail-io0-f171.google.com (HELO mail-io0-f171.google.com) (209.85.223.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 Aug 2016 08:45:10 +0000 Received: by mail-io0-f171.google.com with SMTP id q83so42403722iod.1 for ; Fri, 19 Aug 2016 01:45:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=z8JmWptlrBm2dY2DhPL+EyhdtczDvpKNBBde1p6TbGk=; b=OzXt+u32RWEUS9LXwsJyzLirvR4z+guXdNOYibfNfJDd1AmE2JTCqcE1RMWqonPQ9F rv61BVQxuaGTMnu/T7zDkVmpn2y2pUm9VYlca9q652k8HBqrtjFmCrHpF84S9x1e4vY8 j+USlrn0HJ9aYDl1vTccaFJAltGfkVmQLxx0wox/SVEBM4bDA1kxsEb89Muu6622sS6r cg5VCP4OMh55P5S5pfBTcPVtrqbttrBm4waODn4Vy3+dYDYo+dIrjl+3X6WBybWlY0os QUQutFBT7Q8K3cDlnO/mFfa1Zwnbfxwu6rDngau9JIu507XG/4JVRr2Co7H94QqrbKc+ XZlw== X-Gm-Message-State: AEkoousRuQyeEgL0cgWhHb6tkxi8VkxHAEZHVcODZ7IsWHf/iDQSNOeyww4NUXst6sV/3lMuBVA06NQqMZRYzqJZ X-Received: by 10.107.159.147 with SMTP id i141mr8116968ioe.29.1471596308679; Fri, 19 Aug 2016 01:45:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.208.18 with HTTP; Fri, 19 Aug 2016 01:45:08 -0700 (PDT) From: Prathamesh Kulkarni Date: Fri, 19 Aug 2016 14:15:08 +0530 Message-ID: Subject: [libcpp] append "evaluates to 0" for Wundef diagnostic To: gcc Patches , David Malcolm X-IsSubscribed: yes Hi David, This trivial patch appends "evaluates to 0", in Wundef diagnostic, similar to clang, which prints the following diagnostic for undefined macro: undef.c:1:5: warning: 'FOO' is not defined, evaluates to 0 [-Wundef] #if FOO ^ Bootstrapped+tested on x86_64-unknown-linux-gnu. OK to commit ? Thanks, Prathamesh 2016-08-19 Prathamesh Kulkarni libcpp/ * expr.c (eval_token): Append "evaluates to 0" to Wundef diagnostic. testsuite/ * gcc.dg/cpp/warn-undef.c: Append "evaluates to 0" to dg-error. * gcc.dg/cpp/warn-undef-2.c: Likewise. diff --git a/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c b/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c index 15fdde9..e71aeba 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c @@ -1,5 +1,5 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=undef" } /* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -#if x // { dg-error "\"x\" is not defined .-Werror=undef." } +#if x // { dg-error "\"x\" is not defined, evaluates to 0 .-Werror=undef." } #endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-undef.c b/gcc/testsuite/gcc.dg/cpp/warn-undef.c index dd4524d..2c2c421 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-undef.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-undef.c @@ -1,5 +1,5 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Wundef" } -#if x // { dg-warning "\"x\" is not defined .-Wundef." } +#if x // { dg-warning "\"x\" is not defined, evaluates to 0 .-Wundef." } #endif diff --git a/libcpp/expr.c b/libcpp/expr.c index 5cdca6f..d32f5a9 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -1073,7 +1073,7 @@ eval_token (cpp_reader *pfile, const cpp_token *token, result.low = 0; if (CPP_OPTION (pfile, warn_undef) && !pfile->state.skip_eval) cpp_warning_with_line (pfile, CPP_W_UNDEF, virtual_location, 0, - "\"%s\" is not defined", + "\"%s\" is not defined, evaluates to 0", NODE_NAME (token->val.node.node)); } break;