From patchwork Wed Aug 3 15:45:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 655468 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s4Gs93MMdz9sCY for ; Thu, 4 Aug 2016 01:17:33 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=rX94EUbb; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=xRkrhFy07saMEvxEyzE4uLnZICcE3ShucRST70XtLkGqVhkZS/+TX Wbeb2IY5aQCQ1KrH4swO45spP8lIuj6+1w7I665y+bXvTary4/bMct+gYsXOP6hB MA8mY2yMmm1PL1DXEb32Sxhte8LdLeC333D27cO1Of5QBTqQBkQP8c= 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:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=nFVqlQzibekI0aiMyKAmCLTuMb0=; b=rX94EUbbWlj/UE5w510F 9k15yRKzVKRMtRXVgJJZKqLJ/OGMRhQT6fgSlA3YtANzoUAD4mI5GrGJljii8XqU JqWGo6S2PyA6HQsVQBH46mubR7+T5YxgmtNjhQpPUWCRpGEqVg4uoS4+QjMs4t4s 4aeFfYoufamQpjeV8p828uo= Received: (qmail 8985 invoked by alias); 3 Aug 2016 15:17:23 -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 8971 invoked by uid 89); 3 Aug 2016 15:17:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=LOC X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 03 Aug 2016 15:17:12 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 43016C057FAA; Wed, 3 Aug 2016 15:17:11 +0000 (UTC) Received: from c64.redhat.com (vpn-228-76.phx2.redhat.com [10.3.228.76]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u73FHAvY002709; Wed, 3 Aug 2016 11:17:10 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: Joseph Myers , David Malcolm Subject: [PATCH 1/4] selftest.h: Add ASSERT_TRUE_AT and ASSERT_FALSE_AT Date: Wed, 3 Aug 2016 11:45:10 -0400 Message-Id: <1470239113-42666-1-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1469841382.17384.65.camel@redhat.com> References: <1469841382.17384.65.camel@redhat.com> X-IsSubscribed: yes I split out the selftest.h changes from v2 of the kit for ease of review; here they are. Successfully bootstrapped®rtested in conjunction with the rest of the patch kit on x86_64-pc-linux-gnu. OK for trunk? gcc/ChangeLog: * selftest.h (ASSERT_TRUE): Reimplement in terms of... (ASSERT_TRUE_AT): New macro. (ASSERT_FALSE): Reimplement in terms of... (ASSERT_FALSE_AT): New macro. (ASSERT_STREQ_AT): Fix typo in comment. --- gcc/selftest.h | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/gcc/selftest.h b/gcc/selftest.h index 0bee476..397e998 100644 --- a/gcc/selftest.h +++ b/gcc/selftest.h @@ -104,13 +104,19 @@ extern int num_passes; ::selftest::fail if it false. */ #define ASSERT_TRUE(EXPR) \ + ASSERT_TRUE_AT (SELFTEST_LOCATION, (EXPR)) + +/* Like ASSERT_TRUE, but treat LOC as the effective location of the + selftest. */ + +#define ASSERT_TRUE_AT(LOC, EXPR) \ SELFTEST_BEGIN_STMT \ const char *desc = "ASSERT_TRUE (" #EXPR ")"; \ bool actual = (EXPR); \ if (actual) \ - ::selftest::pass (SELFTEST_LOCATION, desc); \ + ::selftest::pass ((LOC), desc); \ else \ - ::selftest::fail (SELFTEST_LOCATION, desc); \ + ::selftest::fail ((LOC), desc); \ SELFTEST_END_STMT /* Evaluate EXPR and coerce to bool, calling @@ -118,13 +124,19 @@ extern int num_passes; ::selftest::fail if it true. */ #define ASSERT_FALSE(EXPR) \ + ASSERT_FALSE_AT (SELFTEST_LOCATION, (EXPR)) + +/* Like ASSERT_FALSE, but treat LOC as the effective location of the + selftest. */ + +#define ASSERT_FALSE_AT(LOC, EXPR) \ SELFTEST_BEGIN_STMT \ - const char *desc = "ASSERT_FALSE (" #EXPR ")"; \ - bool actual = (EXPR); \ - if (actual) \ - ::selftest::fail (SELFTEST_LOCATION, desc); \ - else \ - ::selftest::pass (SELFTEST_LOCATION, desc); \ + const char *desc = "ASSERT_FALSE (" #EXPR ")"; \ + bool actual = (EXPR); \ + if (actual) \ + ::selftest::fail ((LOC), desc); \ + else \ + ::selftest::pass ((LOC), desc); \ SELFTEST_END_STMT /* Evaluate EXPECTED and ACTUAL and compare them with ==, calling @@ -169,7 +181,7 @@ extern int num_passes; (EXPECTED), (ACTUAL)); \ SELFTEST_END_STMT -/* Like ASSERT_STREQ_AT, but treat LOC as the effective location of the +/* Like ASSERT_STREQ, but treat LOC as the effective location of the selftest. */ #define ASSERT_STREQ_AT(LOC, EXPECTED, ACTUAL) \