From patchwork Wed Dec 21 22:25:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 35543 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:8188:b0:89:790f:f786 with SMTP id m8csp4946050dye; Wed, 21 Dec 2022 14:27:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXtP112rzupahcBwc7kzR9ZIjHKOrpywhrVuTTGsJjT0whhBY0rY4obaUvXBDLLo29P9nGKa X-Received: by 2002:a17:907:cb12:b0:7c1:6f86:eee with SMTP id um18-20020a170907cb1200b007c16f860eeemr2462957ejc.33.1671661677342; Wed, 21 Dec 2022 14:27:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671661677; cv=pass; d=google.com; s=arc-20160816; b=JGjGOyHRoHpl0pGyCASgdmfEE8t4z6PRj8ECDGOGdFOTZs9CEx3a3bj26hxX4yufK7 2RrEMjXzehjOI+pLQwSnWRMB5dw3XGDsqXm9bZy4VntluWOLbp+5fzakzYnbyV+imF+g leM0KTTeDL3kkIROADX0w2d/QF6FUlvUwO5Umi3/HhtImGv22ZLn1MJOiDZXfLZB3e/8 f2/B5HG7TQkdJfZjykAr+RT3958J9y1PCUSyMCbV952XiVbrw4D8zqLfeo14TURaMxTU vA4w+lOd+d7tIYhWdJGbcp5eyAUNQsppwvkdA/Woich9/gHgpEHz8BnaX3NDC+zBQw3F KU1g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=Me5HWqW3YkeGQLYfTN4901JN5G2qKnWTC3HMERl6MVc=; b=NzbYNx6uZbxGKQh6IPHnihe1ab7VP7XgJEv/6sX4mD8nPlcrW1GuNtm+NcGSwJ1lap S1vMTd6+gdCYa7DoWurXnT9XEVxuET4jxrxKWloF4bYgMAPvOwNbH8bMFSm/8lHUX3zo EJt0WIrobS27LC4VCQLropmpShMQ0SwULBDlpfwV9lswljPZGPe7iPFShp2EPUL2lXOe af8WszdFhzFB26gMhR8Cxsqkx9FK8srZKqliTxNPhXG2PTUYD3pV27Juprucj/lz3uKx KxTZFiu3a2zVZrM5ZxrjrvVNGoNqRt9jcUHfcPsnMOQdXdNZs52/NMn2uLIKkLA+8nT1 u6FQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gotplt.org header.s=dreamhost header.b="CUdvvFR/"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id hs36-20020a1709073ea400b00832054a624csi4299809ejc.173.2022.12.21.14.27.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 14:27:57 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gotplt.org header.s=dreamhost header.b="CUdvvFR/"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F1B2F38493E9 for ; Wed, 21 Dec 2022 22:27:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from dog.birch.relay.mailchannels.net (dog.birch.relay.mailchannels.net [23.83.209.48]) by sourceware.org (Postfix) with ESMTPS id 1989D3858425 for ; Wed, 21 Dec 2022 22:26:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1989D3858425 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 58ADE5C1121; Wed, 21 Dec 2022 22:26:04 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id D655F5C0FF6; Wed, 21 Dec 2022 22:26:03 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1671661563; a=rsa-sha256; cv=none; b=cE3BqHY7j/2kva2Nb3K1buaNzp9KS5Lo635vE20Gyw0R0l+8u7F8dM1IugBOg8UfT/rKSY InR8Pb0lOyvI3Ihgcbgs+76K/e+Zdl1wOSoawGr/6ILq3cIt7GGvFi5lxud/LZqCu8dA+W +idnh8umWidDlYNzmQINTtWMOcgOhNq/wm5oEwCIhYFCNIJx6AiIHcwARjWRMcbMBCubSs jQ+IwQ/Mh1tcp3qZSQY+CWpoweEAZPQD/k4yCMkDxaWVj7IvrCAZcD7Y4F/RQjN7LAnAhd QgGioj8ifgk809zu5fBHCP0122Ry4a97wlZwlrk0BGhnqa++61p3i8czx4zI4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1671661563; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Me5HWqW3YkeGQLYfTN4901JN5G2qKnWTC3HMERl6MVc=; b=Xn5GW+TFBwY61WK0syzb3tWD9zzZZiWWQvZyZbsGANhnIRWB0J0CslDOrUiMQOGrAbKsSM KREy5aHffp9uz3r3izXr20ZVlkEAAgpqhT0DjDmsK2cm0EghKnCKiwh7qtM7YhLaw4DbMc JNw5u6VqweSbRAWe8+CailTfRyYU7vMI89Tvy0CFM6RxoPVyz7Uv5fPWAzZJMEaV5T95LI NOLTubUfSnRxeLl4Qy8J+D4E5l8KcU3RjKkh1orDEKIUlxx4X3sZiURi+nXzB7H6ATzNXH 7OkbBKi6QmaL8Fxbcv3EypYYWUoFNS1hCrEswN3b9WKo1Yb8/R9iZw3kFzmZ8A== ARC-Authentication-Results: i=1; rspamd-896578cf5-mns28; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Turn-Robust: 21f4efe5799ab227_1671661564147_1955596875 X-MC-Loop-Signature: 1671661564146:1795135825 X-MC-Ingress-Time: 1671661564146 Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.123.200.84 (trex/6.7.1); Wed, 21 Dec 2022 22:26:04 +0000 Received: from fedora.redhat.com (bras-base-toroon4834w-grc-23-76-68-24-147.dsl.bell.ca [76.68.24.147]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4Ncp1l03SnzVw; Wed, 21 Dec 2022 14:26:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1671661563; bh=Me5HWqW3YkeGQLYfTN4901JN5G2qKnWTC3HMERl6MVc=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=CUdvvFR/uNGoaUuxeTW2QlSNbiICPCu8sH9gJ5NChRXU+Omt1QoJyWjM6CufRPUBR O3bdVtrWD8E7b9XKb5qqXFbG6suGQHqeiiZJfaZAvwzrUfmRVWHmFz0Fe7OBMrUXdS z0Ten2Rkta9tv/mG/uyBzEAxqa5ePnu2Yc/RkcL/GSu8dx3aSGK1rKc0P/JKVEEnRH y9fcrKSnUWNy/rLBdigNwEN1LwSw70k4BvahioRECfoTuK3Z0b62ETNW1iE27NbB83 HytAb5WwVE2CjI18p2plZhdBL+6d7ce60LX2vXxMkxNkfl5kH9D6qRBqjpjIxA0k0z 6apk3neZ8qmAg== From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Cc: jakub@redhat.com Subject: [PATCH 1/2] testsuite: Run __bos tests to completion Date: Wed, 21 Dec 2022 17:25:53 -0500 Message-Id: <20221221222554.4141678-2-siddhesh@gotplt.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221222554.4141678-1-siddhesh@gotplt.org> References: <20221221222554.4141678-1-siddhesh@gotplt.org> MIME-Version: 1.0 X-Spam-Status: No, score=-3037.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752864314831961683?= X-GMAIL-MSGID: =?utf-8?q?1752864314831961683?= Instead of failing on first error, run all __builtin_object_size and __builtin_dynamic_object_size tests to completion and then provide a summary of which tests failed. gcc/testsuite/ChangeLog: * gcc.dg/builtin-dynamic-object-size-0.c: Move FAIL and nfail into... * gcc.dg/builtin-object-size-common.h: ... new file. * g++.dg/ext/builtin-object-size1.C: Include builtin-object-size-common.h. Replace all abort with FAIL. (main): Call DONE. * g++.dg/ext/builtin-object-size2.C: Likewise. * gcc.dg/builtin-object-size-1.c: Likewise. * gcc.dg/builtin-object-size-12.c: Likewise. * gcc.dg/builtin-object-size-13.c: Likewise. * gcc.dg/builtin-object-size-15.c: Likewise. * gcc.dg/builtin-object-size-2.c: Likewise. * gcc.dg/builtin-object-size-3.c: Likewise. * gcc.dg/builtin-object-size-4.c: Likewise. * gcc.dg/builtin-object-size-6.c: Likewise. * gcc.dg/builtin-object-size-7.c: Likewise. * gcc.dg/builtin-object-size-8.c: Likewise. * gcc.dg/pr101836.c: Likewise. * gcc.dg/strict-flex-array-3.c: Likewise. Signed-off-by: Siddhesh Poyarekar --- .../g++.dg/ext/builtin-object-size1.C | 257 ++++++++-------- .../g++.dg/ext/builtin-object-size2.C | 257 ++++++++-------- .../gcc.dg/builtin-dynamic-object-size-0.c | 14 +- gcc/testsuite/gcc.dg/builtin-object-size-1.c | 263 ++++++++-------- gcc/testsuite/gcc.dg/builtin-object-size-12.c | 12 +- gcc/testsuite/gcc.dg/builtin-object-size-13.c | 13 +- gcc/testsuite/gcc.dg/builtin-object-size-15.c | 11 +- gcc/testsuite/gcc.dg/builtin-object-size-2.c | 287 +++++++++--------- gcc/testsuite/gcc.dg/builtin-object-size-3.c | 263 ++++++++-------- gcc/testsuite/gcc.dg/builtin-object-size-4.c | 267 ++++++++-------- gcc/testsuite/gcc.dg/builtin-object-size-6.c | 257 ++++++++-------- gcc/testsuite/gcc.dg/builtin-object-size-7.c | 52 ++-- gcc/testsuite/gcc.dg/builtin-object-size-8.c | 13 +- .../gcc.dg/builtin-object-size-common.h | 12 + gcc/testsuite/gcc.dg/pr101836.c | 11 +- gcc/testsuite/gcc.dg/strict-flex-array-3.c | 11 +- 16 files changed, 1010 insertions(+), 990 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/builtin-object-size-common.h diff --git a/gcc/testsuite/g++.dg/ext/builtin-object-size1.C b/gcc/testsuite/g++.dg/ext/builtin-object-size1.C index 8590a0bbebd..165b415683b 100644 --- a/gcc/testsuite/g++.dg/ext/builtin-object-size1.C +++ b/gcc/testsuite/g++.dg/ext/builtin-object-size1.C @@ -1,8 +1,9 @@ // { dg-do run } // { dg-options "-O2" } +#include "../../gcc.dg/builtin-object-size-common.h" + typedef __SIZE_TYPE__ size_t; -extern "C" void abort (); extern "C" void exit (int); extern "C" void *malloc (size_t); extern "C" void free (void *); @@ -20,105 +21,105 @@ test1 (A *p) { char *c; if (__builtin_object_size (&p->a, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != (size_t) -1) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != (size_t) -1) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 1) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 1) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 2) != 0) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 3) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 3) != 0) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 3) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 3) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 3) != 0) - abort (); + FAIL (); } void @@ -129,105 +130,105 @@ test2 (void) size_t s = 2 * sizeof (A); A *p = (A *) malloc (2 * sizeof (A)); if (__builtin_object_size (&p->a, 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != s - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (A, b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 0) != s) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 0) != s) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 0) != s - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 0) != s - __builtin_offsetof (A, b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 0) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 1) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 1) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 1) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 2) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 2) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 2) != s - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 2) != s - __builtin_offsetof (A, b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 2) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 2) != s) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 2) != s) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 2) != s - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 2) != s - __builtin_offsetof (A, b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 2) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 3) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 3) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 3) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 3) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 3) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); free (p); } @@ -239,48 +240,48 @@ test3 (void) size_t s; A *p = (A *) malloc (4); if (__builtin_object_size (&p->a, 0) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != 1) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != 1) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != 0) - abort (); + FAIL (); free (p); s = __builtin_offsetof (A, c) + 4; p = (A *) malloc (s); if (__builtin_object_size (&p->a, 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != s - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (A, b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != 4) - abort (); + FAIL (); free (p); } @@ -294,17 +295,17 @@ __attribute__ ((noinline)) test4 (struct B *q, int i) { if (__builtin_object_size (&q->a[2].a[2], 1) != sizeof (q->a[0].a) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[2].c[2], 1) != sizeof (q->a[0].c) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[3].a[2], 1) != sizeof (q->a[0].a) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[3].c[2], 1) != sizeof (q->a[0].c) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[i].a[2], 1) != sizeof (q->a[0].a) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[i].c[2], 1) != sizeof (q->a[0].c) - 2) - abort (); + FAIL (); } struct C @@ -318,13 +319,13 @@ __attribute__ ((noinline)) test5 (struct C *c) { if (__builtin_object_size (&c->b, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&c->b, 1) != 1) - abort (); + FAIL (); if (__builtin_object_size (&c->b, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&c->b, 3) != 1) - abort (); + FAIL (); } struct D @@ -342,13 +343,13 @@ __attribute__ ((noinline)) test6 (struct D *d) { if (__builtin_object_size (&d->j.a[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&d->j.a[3], 1) != sizeof (d->j.a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&d->j.a[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&d->j.a[3], 3) != sizeof (d->j.a) - 3) - abort (); + FAIL (); } struct E @@ -366,21 +367,21 @@ __attribute__ ((noinline)) test7 (struct E *e) { if (__builtin_object_size (&e->j[0].a[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&e->j[0].a[3], 1) != sizeof (e->j[0].a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&e->j[0].a[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&e->j[0].a[3], 3) != sizeof (e->j[0].a) - 3) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 3) != 0) - abort (); + FAIL (); } union F @@ -398,13 +399,13 @@ __attribute__ ((noinline)) test8 (union F *f) { if (__builtin_object_size (&f->d.c[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&f->d.c[3], 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&f->d.c[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&f->d.c[3], 3) != 0) - abort (); + FAIL (); } int @@ -431,5 +432,5 @@ main (void) union F f, *fp = &f; __asm ("" : "+r" (fp)); test8 (fp); - exit (0); + DONE (); } diff --git a/gcc/testsuite/g++.dg/ext/builtin-object-size2.C b/gcc/testsuite/g++.dg/ext/builtin-object-size2.C index d79b1b83310..c5dbd96193c 100644 --- a/gcc/testsuite/g++.dg/ext/builtin-object-size2.C +++ b/gcc/testsuite/g++.dg/ext/builtin-object-size2.C @@ -1,8 +1,9 @@ // { dg-do run } // { dg-options "-O2" } +#include "../../gcc.dg/builtin-object-size-common.h" + typedef __SIZE_TYPE__ size_t; -extern "C" void abort (); extern "C" void exit (int); extern "C" void *malloc (size_t); extern "C" void free (void *); @@ -23,105 +24,105 @@ test1 (A *p) { char *c; if (__builtin_object_size (&p->a, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != (size_t) -1) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != (size_t) -1) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 1) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 1) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 2) != 0) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 3) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 3) != 0) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 3) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 3) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 3) != 0) - abort (); + FAIL (); } void @@ -132,105 +133,105 @@ test2 (void) size_t s = 2 * sizeof (A); A *p = (A *) malloc (2 * sizeof (A)); if (__builtin_object_size (&p->a, 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != s - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (A, b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 0) != s) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 0) != s) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 0) != s - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 0) != s - __builtin_offsetof (A, b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 0) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 1) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 1) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 1) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 2) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 2) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 2) != s - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 2) != s - __builtin_offsetof (A, b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 2) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 2) != s) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 2) != s) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 2) != s - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 2) != s - __builtin_offsetof (A, b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 2) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 3) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 3) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 3) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 3) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 3) != s - __builtin_offsetof (A, c)) - abort (); + FAIL (); free (p); } @@ -242,48 +243,48 @@ test3 (void) size_t s; A *p = (A *) malloc (4); if (__builtin_object_size (&p->a, 0) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != 1) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != 1) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != 0) - abort (); + FAIL (); free (p); s = __builtin_offsetof (A, c) + 4; p = (A *) malloc (s); if (__builtin_object_size (&p->a, 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != s - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (A, b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != 4) - abort (); + FAIL (); free (p); } @@ -297,17 +298,17 @@ __attribute__ ((noinline)) test4 (struct B *q, int i) { if (__builtin_object_size (&q->a[2].a[2], 1) != sizeof (q->a[0].a) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[2].c[2], 1) != sizeof (q->a[0].c) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[3].a[2], 1) != sizeof (q->a[0].a) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[3].c[2], 1) != sizeof (q->a[0].c) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[i].a[2], 1) != sizeof (q->a[0].a) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[i].c[2], 1) != sizeof (q->a[0].c) - 2) - abort (); + FAIL (); } struct C @@ -321,13 +322,13 @@ __attribute__ ((noinline)) test5 (struct C *c) { if (__builtin_object_size (&c->b, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&c->b, 1) != 1) - abort (); + FAIL (); if (__builtin_object_size (&c->b, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&c->b, 3) != 1) - abort (); + FAIL (); } struct D @@ -345,13 +346,13 @@ __attribute__ ((noinline)) test6 (struct D *d) { if (__builtin_object_size (&d->j.a[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&d->j.a[3], 1) != sizeof (d->j.a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&d->j.a[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&d->j.a[3], 3) != sizeof (d->j.a) - 3) - abort (); + FAIL (); } struct E @@ -369,21 +370,21 @@ __attribute__ ((noinline)) test7 (struct E *e) { if (__builtin_object_size (&e->j[0].a[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&e->j[0].a[3], 1) != sizeof (e->j[0].a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&e->j[0].a[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&e->j[0].a[3], 3) != sizeof (e->j[0].a) - 3) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 3) != 0) - abort (); + FAIL (); } union F @@ -401,13 +402,13 @@ __attribute__ ((noinline)) test8 (union F *f) { if (__builtin_object_size (&f->d.c[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&f->d.c[3], 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&f->d.c[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&f->d.c[3], 3) != 0) - abort (); + FAIL (); } int @@ -434,5 +435,5 @@ main (void) union F f, *fp = &f; __asm ("" : "+r" (fp)); test8 (fp); - exit (0); + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c index f9047a037d9..cf1ea009788 100644 --- a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c +++ b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c @@ -1,6 +1,8 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ +#include "builtin-object-size-common.h" + typedef __SIZE_TYPE__ size_t; #define abort __builtin_abort @@ -539,13 +541,6 @@ test_pr105736 (struct TV4 *a) return &a->v[0]; } -unsigned nfails = 0; - -#define FAIL() ({ \ - __builtin_printf ("Failure at line: %d\n", __LINE__); \ - nfails++; \ -}) - int main (int argc, char **argv) { @@ -707,8 +702,5 @@ main (int argc, char **argv) if (test_strndup_min (str, 4) != 1) FAIL (); - if (nfails > 0) - __builtin_abort (); - - return 0; + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-1.c b/gcc/testsuite/gcc.dg/builtin-object-size-1.c index c6e5b4c29f8..851194c30b5 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-1.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-1.c @@ -2,8 +2,9 @@ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ +#include "builtin-object-size-common.h" + typedef __SIZE_TYPE__ size_t; -extern void abort (void); extern void exit (int); extern void *malloc (size_t); extern void *calloc (size_t, size_t); @@ -39,22 +40,22 @@ test1 (void *q, int x) r = &a.c[1]; if (__builtin_object_size (p, 0) != sizeof (a) - __builtin_offsetof (struct A, a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&a.c[9], 0) != sizeof (a) - __builtin_offsetof (struct A, c) - 9) - abort (); + FAIL (); if (__builtin_object_size (q, 0) != (size_t) -1) - abort (); + FAIL (); #ifdef __builtin_object_size if (__builtin_object_size (r, 0) != (x < 0 ? sizeof (a) - __builtin_offsetof (struct A, a) - 9 : sizeof (a) - __builtin_offsetof (struct A, c) - 1)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 0) != sizeof (a) - __builtin_offsetof (struct A, a) - 9) - abort (); + FAIL (); #endif if (x < 6) r = &w[2].a[1]; @@ -62,23 +63,23 @@ test1 (void *q, int x) r = &a.a[6]; if (__builtin_object_size (&y, 0) != sizeof (y)) - abort (); + FAIL (); if (__builtin_object_size (w, 0) != sizeof (w)) - abort (); + FAIL (); if (__builtin_object_size (&y.b, 0) != sizeof (a) - __builtin_offsetof (struct A, b)) - abort (); + FAIL (); #ifdef __builtin_object_size if (__builtin_object_size (r, 0) != (x < 6 ? 2 * sizeof (w[0]) - __builtin_offsetof (struct A, a) - 1 : sizeof (a) - __builtin_offsetof (struct A, a) - 6)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 0) != 2 * sizeof (w[0]) - __builtin_offsetof (struct A, a) - 1) - abort (); + FAIL (); #endif if (x < 20) r = malloc (30); @@ -86,14 +87,14 @@ test1 (void *q, int x) r = calloc (2, 16); #ifdef __builtin_object_size if (__builtin_object_size (r, 0) != (x < 20 ? 30 : 2 * 16)) - abort (); + FAIL (); #else /* We may duplicate this test onto the two exit paths. On one path the size will be 32, the other it will be 30. If we don't duplicate this test, then the size will be 32. */ if (__builtin_object_size (r, 0) != 2 * 16 && __builtin_object_size (r, 0) != 30) - abort (); + FAIL (); #endif if (x < 20) r = malloc (30); @@ -101,10 +102,10 @@ test1 (void *q, int x) r = calloc (2, 14); #ifdef __builtin_object_size if (__builtin_object_size (r, 0) != (x < 20 ? 30 : 2 * 14)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 0) != 30) - abort (); + FAIL (); #endif if (x < 30) r = malloc (sizeof (a)); @@ -112,102 +113,102 @@ test1 (void *q, int x) r = &a.a[3]; #ifdef __builtin_object_size if (__builtin_object_size (r, 0) != (x < 30 ? sizeof (a) : sizeof (a) - 3)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 0) != sizeof (a)) - abort (); + FAIL (); #endif r = memcpy (r, "a", 2); #ifdef __builtin_object_size if (__builtin_object_size (r, 0) != (x < 30 ? sizeof (a) : sizeof (a) - 3)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 0) != sizeof (a)) - abort (); + FAIL (); #endif r = memcpy (r + 2, "b", 2) + 2; #ifdef __builtin_object_size if (__builtin_object_size (r, 0) != (x < 30 ? sizeof (a) - 4 : sizeof (a) - 7)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 0) != sizeof (a) - 4) - abort (); + FAIL (); #endif r = &a.a[4]; r = memset (r, 'a', 2); if (__builtin_object_size (r, 0) != sizeof (a) - __builtin_offsetof (struct A, a) - 4) - abort (); + FAIL (); r = memset (r + 2, 'b', 2) + 2; if (__builtin_object_size (r, 0) != sizeof (a) - __builtin_offsetof (struct A, a) - 8) - abort (); + FAIL (); r = &a.a[1]; r = strcpy (r, "ab"); if (__builtin_object_size (r, 0) != sizeof (a) - __builtin_offsetof (struct A, a) - 1) - abort (); + FAIL (); r = strcpy (r + 2, "cd") + 2; if (__builtin_object_size (r, 0) != sizeof (a) - __builtin_offsetof (struct A, a) - 5) - abort (); + FAIL (); if (__builtin_object_size (exta, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (exta + 10, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&exta[5], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (extb, 0) != sizeof (extb)) - abort (); + FAIL (); if (__builtin_object_size (extb + 10, 0) != sizeof (extb) - 10) - abort (); + FAIL (); if (__builtin_object_size (&extb[5], 0) != sizeof (extb) - 5) - abort (); + FAIL (); #ifdef __builtin_object_size if (__builtin_object_size (var, 0) != x + 10) - abort (); + FAIL (); if (__builtin_object_size (var + 10, 0) != x) - abort (); + FAIL (); if (__builtin_object_size (&var[5], 0) != x + 5) - abort (); + FAIL (); #else if (__builtin_object_size (var, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (var + 10, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&var[5], 0) != (size_t) -1) - abort (); + FAIL (); #endif if (__builtin_object_size (zerol, 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol, 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0], 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (zerol[0].a, 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0].a[0], 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0].b, 0) != 0) - abort (); + FAIL (); if (__builtin_object_size ("abcdefg", 0) != sizeof ("abcdefg")) - abort (); + FAIL (); if (__builtin_object_size ("abcd\0efg", 0) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg", 0) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg"[0], 0) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg"[4], 0) != sizeof ("abcd\0efg") - 4) - abort (); + FAIL (); if (__builtin_object_size ("abcd\0efg" + 5, 0) != sizeof ("abcd\0efg") - 5) - abort (); + FAIL (); if (__builtin_object_size (L"abcdefg", 0) != sizeof (L"abcdefg")) - abort (); + FAIL (); r = (char *) L"abcd\0efg"; if (__builtin_object_size (r + 2, 0) != sizeof (L"abcd\0efg") - 2) - abort (); + FAIL (); } size_t l1 = 1; @@ -254,7 +255,7 @@ test2 (void) res = 20; #endif if (__builtin_object_size (r, 0) != res) - abort (); + FAIL (); r = &buf3[20]; for (i = 0; i < 4; ++i) { @@ -282,29 +283,29 @@ test2 (void) res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; } if (__builtin_object_size (r, 0) != res) - abort (); + FAIL (); #else res = 15; #endif if (__builtin_object_size (r, 0) != res) - abort (); + FAIL (); r += 8; #ifdef __builtin_object_size res -= 8; if (__builtin_object_size (r, 0) != res) - abort (); + FAIL (); if (res >= 6) { if (__builtin_object_size (r + 6, 0) != res - 6) - abort (); + FAIL (); } else if (__builtin_object_size (r + 6, 0) != 0) - abort (); + FAIL (); #else if (__builtin_object_size (r, 0) != 7) - abort (); + FAIL (); if (__builtin_object_size (r + 6, 0) != 1) - abort (); + FAIL (); #endif r = &buf3[18]; for (i = 0; i < 4; ++i) @@ -335,13 +336,13 @@ test2 (void) if (res >= 12) { if (__builtin_object_size (r + 12, 0) != res - 12) - abort (); + FAIL (); } else if (__builtin_object_size (r + 12, 0) != 0) - abort (); + FAIL (); #else if (__builtin_object_size (r + 12, 0) != 4) - abort (); + FAIL (); #endif } @@ -357,103 +358,103 @@ test3 (void) double *dp; if (__builtin_object_size (buf4, 0) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4, 0) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4[0], 0) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4[1], 0) != sizeof (buf4) - 1) - abort (); + FAIL (); if (__builtin_object_size (&x, 0) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a, 0) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0], 0) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a, 0) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a[0], 0) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a[3], 0) != sizeof (x) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].b, 0) != sizeof (x) - __builtin_offsetof (struct A, b)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c, 0) != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c[0], 0) != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c[3], 0) != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.b, 0) != sizeof (x) - __builtin_offsetof (struct B, b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a, 0) != sizeof (x) - __builtin_offsetof (struct B, b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a[0], 0) != sizeof (x) - __builtin_offsetof (struct B, b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a[3], 0) != sizeof (x) - __builtin_offsetof (struct B, b) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.b.b, 0) != sizeof (x) - __builtin_offsetof (struct B, b) - __builtin_offsetof (struct A, b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c, 0) != sizeof (x) - __builtin_offsetof (struct B, b) - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c[0], 0) != sizeof (x) - __builtin_offsetof (struct B, b) - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c[3], 0) != sizeof (x) - __builtin_offsetof (struct B, b) - __builtin_offsetof (struct A, c) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.c, 0) != sizeof (x) - __builtin_offsetof (struct B, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.c[0], 0) != sizeof (x) - __builtin_offsetof (struct B, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.c[1], 0) != sizeof (x) - __builtin_offsetof (struct B, c) - 1) - abort (); + FAIL (); if (__builtin_object_size (&x.d, 0) != sizeof (x) - __builtin_offsetof (struct B, d)) - abort (); + FAIL (); if (__builtin_object_size (&x.e, 0) != sizeof (x) - __builtin_offsetof (struct B, e)) - abort (); + FAIL (); if (__builtin_object_size (&x.f, 0) != sizeof (x) - __builtin_offsetof (struct B, f)) - abort (); + FAIL (); dp = &__real__ x.f; if (__builtin_object_size (dp, 0) != sizeof (x) - __builtin_offsetof (struct B, f)) - abort (); + FAIL (); dp = &__imag__ x.f; if (__builtin_object_size (dp, 0) != sizeof (x) - __builtin_offsetof (struct B, f) - sizeof (x.f) / 2) - abort (); + FAIL (); dp = &y; if (__builtin_object_size (dp, 0) != sizeof (y)) - abort (); + FAIL (); if (__builtin_object_size (&z, 0) != sizeof (z)) - abort (); + FAIL (); dp = &__real__ z; if (__builtin_object_size (dp, 0) != sizeof (z)) - abort (); + FAIL (); dp = &__imag__ z; if (__builtin_object_size (dp, 0) != sizeof (z) / 2) - abort (); + FAIL (); } struct S { unsigned int a; }; @@ -470,7 +471,7 @@ test4 (char *x, int y) p = (struct A *) x; x = (char *) &p[1]; if (__builtin_object_size (p, 0) != (size_t) -1) - abort (); + FAIL (); } return x; } @@ -487,7 +488,7 @@ test5 (size_t x) p = p + 4; #ifdef __builtin_object_size if (__builtin_object_size (p, 0) != sizeof (buf) - 8 - 4 * x) - abort (); + FAIL (); #else /* My understanding of ISO C99 6.5.6 is that a conforming program will not end up with p equal to &buf[0] @@ -497,7 +498,7 @@ test5 (size_t x) bytes from p until end of the object is 56, otherwise it would be 64 (or conservative (size_t) -1 == unknown). */ if (__builtin_object_size (p, 0) != sizeof (buf) - 8) - abort (); + FAIL (); #endif memset (p, ' ', sizeof (buf) - 8 - 4 * 4); } @@ -514,10 +515,10 @@ test6 (size_t x) p = p + 4; #ifdef __builtin_object_size if (__builtin_object_size (p, 0) != sizeof (t) - 8 - 4 * x) - abort (); + FAIL (); #else if (__builtin_object_size (p, 0) != sizeof (t) - 8) - abort (); + FAIL (); #endif memset (p, ' ', sizeof (t) - 8 - 4 * 4); } @@ -531,13 +532,13 @@ test7 (void) char *p = &buf[64], *q = &t.buf[64]; if (__builtin_object_size (p + 64, 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (q + 63, 0) != sizeof (t) - 64 - 63) - abort (); + FAIL (); if (__builtin_object_size (q + 64, 0) != sizeof (t) - 64 - 64) - abort (); + FAIL (); if (__builtin_object_size (q + 256, 0) != 0) - abort (); + FAIL (); } void @@ -548,17 +549,17 @@ test8 (void) char *p = &t.buf2[-4]; char *q = &t.buf2[0]; if (__builtin_object_size (p, 0) != sizeof (t) - 10 + 4) - abort (); + FAIL (); if (__builtin_object_size (q, 0) != sizeof (t) - 10) - abort (); + FAIL (); /* GCC only handles additions, not subtractions. */ q = q - 8; if (__builtin_object_size (q, 0) != (size_t) -1 && __builtin_object_size (q, 0) != sizeof (t) - 10 + 8) - abort (); + FAIL (); p = &t.buf[-4]; if (__builtin_object_size (p, 0) != 0) - abort (); + FAIL (); } void @@ -575,10 +576,10 @@ test9 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (&p[-4], 0) != (cond ? 6 : 10)) - abort (); + FAIL (); #else if (__builtin_object_size (&p[-4], 0) != 10) - abort (); + FAIL (); #endif for (unsigned i = cond; i > 0; i--) @@ -586,10 +587,10 @@ test9 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (p, 0) != ((cond ? 2 : 6) + cond)) - abort (); + FAIL (); #else if (__builtin_object_size (p, 0) != 10) - abort (); + FAIL (); #endif p = &y.c[8]; @@ -599,10 +600,10 @@ test9 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (p, 0) != sizeof (y) - __builtin_offsetof (struct A, c) - 8 + cond) - abort (); + FAIL (); #else if (__builtin_object_size (p, 0) != sizeof (y)) - abort (); + FAIL (); #endif } @@ -620,10 +621,10 @@ test10 (void) { #ifdef __builtin_object_size if (__builtin_object_size (p - 3, 0) != sizeof (buf) - i + 3) - abort (); + FAIL (); #else if (__builtin_object_size (p - 3, 0) != sizeof (buf)) - abort (); + FAIL (); #endif break; } @@ -641,19 +642,19 @@ test11 (void) const char *ptr = "abcdefghijklmnopqrstuvwxyz"; char *res = strndup (ptr, 21); if (__builtin_object_size (res, 0) != 22) - abort (); + FAIL (); free (res); res = strndup (ptr, 32); if (__builtin_object_size (res, 0) != 27) - abort (); + FAIL (); free (res); res = strdup (ptr); if (__builtin_object_size (res, 0) != 27) - abort (); + FAIL (); free (res); @@ -662,19 +663,19 @@ test11 (void) res = strndup (ptr2, 21); if (__builtin_object_size (res, 0) != 22) - abort (); + FAIL (); free (res); res = strndup (ptr2, 32); if (__builtin_object_size (res, 0) != 33) - abort (); + FAIL (); free (res); res = strndup (ptr2, 128); if (__builtin_object_size (res, 0) != 64) - abort (); + FAIL (); free (res); @@ -684,39 +685,39 @@ test11 (void) #else if (__builtin_object_size (res, 0) != (size_t) -1) #endif - abort (); + FAIL (); free (res); free (ptr2); ptr = "abcd\0efghijklmnopqrstuvwxyz"; res = strdup (ptr); if (__builtin_object_size (res, 0) != 5) - abort (); + FAIL (); free (res); res = strndup (ptr, 24); if (__builtin_object_size (res, 0) != 5) - abort (); + FAIL (); free (res); res = strndup (ptr, 2); if (__builtin_object_size (res, 0) != 3) - abort (); + FAIL (); free (res); res = strdup (&ptr[4]); if (__builtin_object_size (res, 0) != 1) - abort (); + FAIL (); free (res); res = strndup (&ptr[4], 4); if (__builtin_object_size (res, 0) != 1) - abort (); + FAIL (); free (res); res = strndup (&ptr[4], 1); if (__builtin_object_size (res, 0) != 1) - abort (); + FAIL (); free (res); } @@ -736,5 +737,5 @@ main (void) test9 (1); test10 (); test11 (); - exit (0); + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-12.c b/gcc/testsuite/gcc.dg/builtin-object-size-12.c index b21eb0071b3..e29dd17d611 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-12.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-12.c @@ -1,7 +1,8 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ -extern void abort (void); +#include "builtin-object-size-common.h" + struct S { int len; char s[0]; @@ -10,10 +11,11 @@ int main() { char buf[sizeof (struct S) + 32]; if (__builtin_object_size (((struct S *)&buf[0])->s, 1) != 32) - abort (); + FAIL (); if (__builtin_object_size (((struct S *)&buf[1])->s, 1) != 31) - abort (); + FAIL (); if (__builtin_object_size (((struct S *)&buf[64])->s, 0) != 0) - abort (); - return 0; + FAIL (); + + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-13.c b/gcc/testsuite/gcc.dg/builtin-object-size-13.c index 80a6280e3f9..c7d58c941d4 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-13.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-13.c @@ -1,10 +1,11 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ +#include "builtin-object-size-common.h" + typedef __SIZE_TYPE__ size_t; extern void *malloc (size_t); extern void free (void *); -extern void abort (void); union A { @@ -56,13 +57,13 @@ struct H #define T(X, S0, S1) \ if (__builtin_object_size (X, 0) != (S0)) \ - abort (); \ + FAIL (); \ if (__builtin_object_size (X, 1) != (S1)) \ - abort (); \ + FAIL (); \ if (__builtin_object_size (X, 2) != (S0)) \ - abort (); \ + FAIL (); \ if (__builtin_object_size (X, 3) != (S1)) \ - abort () + FAIL () #define TS(X, S0) T(&X, S0, sizeof (X)) #define TA(X, S0, S1) \ T(X, S0, S1); T(&X[0], S0, S1); T(&X[1], (S0) - 1, (S1) - 1) @@ -347,5 +348,5 @@ main (void) free (h2); free (h1); - return 0; + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-15.c b/gcc/testsuite/gcc.dg/builtin-object-size-15.c index 97018572bf8..7ee8ac095e7 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-15.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-15.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ -extern void abort (void); +#include "builtin-object-size-common.h" int main () @@ -9,12 +9,12 @@ main () struct A { char buf1[9]; char buf2[1]; } a; if (__builtin_object_size (a.buf1 + (0 + 4), 1) != 5) - abort (); + FAIL (); char *p = a.buf1; p += 1; p += 3; if (__builtin_object_size (p, 1) != 5) - abort (); + FAIL (); p = (char *) &a; char *q = p + 1; char *r = q + 3; @@ -22,6 +22,7 @@ main () if (r != (char *) &a + 4) t = (char *) &a + 1; if (__builtin_object_size (t, 1) != 6) - abort (); - return 0; + FAIL (); + + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-2.c b/gcc/testsuite/gcc.dg/builtin-object-size-2.c index 639a83cfd39..d801b23392b 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-2.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-2.c @@ -2,8 +2,9 @@ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ +#include "builtin-object-size-common.h" + typedef __SIZE_TYPE__ size_t; -extern void abort (void); extern void exit (int); extern void *malloc (size_t); extern void *calloc (size_t, size_t); @@ -40,39 +41,39 @@ test1 (void *q, int x) else r = &a.c[1]; if (__builtin_object_size (p, 1) != sizeof (a.a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&a.c[9], 1) != sizeof (a.c) - 9) - abort (); + FAIL (); if (__builtin_object_size (q, 1) != (size_t) -1) - abort (); + FAIL (); #ifdef __builtin_object_size if (x < 0 ? __builtin_object_size (r, 1) != sizeof (a.a) - 9 : __builtin_object_size (r, 1) != sizeof (a.c) - 1) - abort (); + FAIL (); #else if (__builtin_object_size (r, 1) != sizeof (a.c) - 1) - abort (); + FAIL (); #endif if (x < 6) r = &w[2].a[1]; else r = &a.a[6]; if (__builtin_object_size (&y, 1) != sizeof (y)) - abort (); + FAIL (); if (__builtin_object_size (w, 1) != sizeof (w)) - abort (); + FAIL (); if (__builtin_object_size (&y.b, 1) != sizeof (a.b)) - abort (); + FAIL (); #ifdef __builtin_object_size if (x < 6 ? __builtin_object_size (r, 1) != sizeof (a.a) - 1 : __builtin_object_size (r, 1) != sizeof (a.a) - 6) - abort (); + FAIL (); #else if (__builtin_object_size (r, 1) != sizeof (a.a) - 1) - abort (); + FAIL (); #endif if (x < 20) r = malloc (30); @@ -80,14 +81,14 @@ test1 (void *q, int x) r = calloc (2, 16); #ifdef __builtin_object_size if (__builtin_object_size (r, 1) != (x < 20 ? 30 : 2 * 16)) - abort (); + FAIL (); #else /* We may duplicate this test onto the two exit paths. On one path the size will be 32, the other it will be 30. If we don't duplicate this test, then the size will be 32. */ if (__builtin_object_size (r, 1) != 2 * 16 && __builtin_object_size (r, 1) != 30) - abort (); + FAIL (); #endif if (x < 20) r = malloc (30); @@ -95,10 +96,10 @@ test1 (void *q, int x) r = calloc (2, 14); #ifdef __builtin_object_size if (__builtin_object_size (r, 1) != (x < 20 ? 30 : 2 * 14)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 1) != 30) - abort (); + FAIL (); #endif if (x < 30) r = malloc (sizeof (a)); @@ -106,132 +107,132 @@ test1 (void *q, int x) r = &a.a[3]; #ifdef __builtin_object_size if (__builtin_object_size (r, 1) != (x < 30 ? sizeof (a) : sizeof (a) - 3)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 1) != sizeof (a)) - abort (); + FAIL (); #endif r = memcpy (r, "a", 2); #ifdef __builtin_object_size if (__builtin_object_size (r, 1) != (x < 30 ? sizeof (a) : sizeof (a) - 3)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 1) != sizeof (a)) - abort (); + FAIL (); #endif r = memcpy (r + 2, "b", 2) + 2; #ifdef __builtin_object_size if (__builtin_object_size (r, 0) != (x < 30 ? sizeof (a) - 4 : sizeof (a) - 7)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 1) != sizeof (a) - 4) - abort (); + FAIL (); #endif r = &a.a[4]; r = memset (r, 'a', 2); if (__builtin_object_size (r, 1) != sizeof (a.a) - 4) - abort (); + FAIL (); r = memset (r + 2, 'b', 2) + 2; if (__builtin_object_size (r, 1) != sizeof (a.a) - 8) - abort (); + FAIL (); r = &a.a[1]; r = strcpy (r, "ab"); if (__builtin_object_size (r, 1) != sizeof (a.a) - 1) - abort (); + FAIL (); r = strcpy (r + 2, "cd") + 2; if (__builtin_object_size (r, 1) != sizeof (a.a) - 5) - abort (); + FAIL (); if (__builtin_object_size (exta, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (exta + 10, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&exta[5], 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (extb, 1) != sizeof (extb)) - abort (); + FAIL (); if (__builtin_object_size (extb + 10, 1) != sizeof (extb) - 10) - abort (); + FAIL (); if (__builtin_object_size (&extb[5], 1) != sizeof (extb) - 5) - abort (); + FAIL (); if (__builtin_object_size (extc, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (extc + 10, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&extc[5], 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&extc->a, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&(extc + 10)->b, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&extc[5].c[3], 1) != (size_t) -1) - abort (); + FAIL (); #ifdef __builtin_object_size if (__builtin_object_size (var, 1) != x + 10) - abort (); + FAIL (); if (__builtin_object_size (var + 10, 1) != x) - abort (); + FAIL (); if (__builtin_object_size (&var[5], 1) != x + 5) - abort (); + FAIL (); if (__builtin_object_size (vara, 1) != (x + 10) * sizeof (struct A)) - abort (); + FAIL (); if (__builtin_object_size (vara + 10, 1) != x * sizeof (struct A)) - abort (); + FAIL (); if (__builtin_object_size (&vara[5], 1) != (x + 5) * sizeof (struct A)) - abort (); + FAIL (); #else if (__builtin_object_size (var, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (var + 10, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&var[5], 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (vara, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (vara + 10, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&vara[5], 1) != (size_t) -1) - abort (); + FAIL (); #endif if (__builtin_object_size (&vara[0].a, 1) != sizeof (vara[0].a)) - abort (); + FAIL (); if (__builtin_object_size (&vara[10].a[0], 1) != sizeof (vara[0].a)) - abort (); + FAIL (); if (__builtin_object_size (&vara[5].a[4], 1) != sizeof (vara[0].a) - 4) - abort (); + FAIL (); if (__builtin_object_size (&vara[5].b, 1) != sizeof (vara[0].b)) - abort (); + FAIL (); if (__builtin_object_size (&vara[7].c[7], 1) != sizeof (vara[0].c) - 7) - abort (); + FAIL (); if (__builtin_object_size (zerol, 1) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol, 1) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0], 1) != 0) - abort (); + FAIL (); if (__builtin_object_size (zerol[0].a, 1) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0].a[0], 1) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0].b, 1) != 0) - abort (); + FAIL (); if (__builtin_object_size ("abcdefg", 1) != sizeof ("abcdefg")) - abort (); + FAIL (); if (__builtin_object_size ("abcd\0efg", 1) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg", 1) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg"[0], 1) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg"[4], 1) != sizeof ("abcd\0efg") - 4) - abort (); + FAIL (); if (__builtin_object_size ("abcd\0efg" + 5, 1) != sizeof ("abcd\0efg") - 5) - abort (); + FAIL (); if (__builtin_object_size (L"abcdefg", 1) != sizeof (L"abcdefg")) - abort (); + FAIL (); r = (char *) L"abcd\0efg"; if (__builtin_object_size (r + 2, 1) != sizeof (L"abcd\0efg") - 2) - abort (); + FAIL (); } size_t l1 = 1; @@ -277,10 +278,10 @@ test2 (void) dyn_res = sizeof (a.buf1) - 9; } if (__builtin_object_size (r, 1) != dyn_res) - abort (); + FAIL (); #else if (__builtin_object_size (r, 1) != sizeof (buf3)) - abort (); + FAIL (); #endif r = &buf3[20]; for (i = 0; i < 4; ++i) @@ -309,10 +310,10 @@ test2 (void) dyn_res = sizeof (a.buf1) - 9; } if (__builtin_object_size (r, 1) != dyn_res) - abort (); + FAIL (); #else if (__builtin_object_size (r, 1) != sizeof (buf3) - 5) - abort (); + FAIL (); #endif r += 8; #ifdef __builtin_object_size @@ -320,23 +321,23 @@ test2 (void) { dyn_res -= 8; if (__builtin_object_size (r, 1) != dyn_res) - abort (); + FAIL (); if (dyn_res >= 6) { if (__builtin_object_size (r + 6, 1) != dyn_res - 6) - abort (); + FAIL (); } else if (__builtin_object_size (r + 6, 1) != 0) - abort (); + FAIL (); } else if (__builtin_object_size (r, 1) != 0) - abort (); + FAIL (); #else if (__builtin_object_size (r, 1) != sizeof (buf3) - 13) - abort (); + FAIL (); if (__builtin_object_size (r + 6, 1) != sizeof (buf3) - 19) - abort (); + FAIL (); #endif } @@ -352,78 +353,78 @@ test3 (void) double *dp; if (__builtin_object_size (buf4, 1) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4, 1) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4[0], 1) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4[1], 1) != sizeof (buf4) - 1) - abort (); + FAIL (); if (__builtin_object_size (&x, 1) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a, 1) != sizeof (x.a)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0], 1) != sizeof (x.a)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a, 1) != sizeof (x.a[0].a)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a[0], 1) != sizeof (x.a[0].a)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a[3], 1) != sizeof (x.a[0].a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].b, 1) != sizeof (x.a[0].b)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c, 1) != sizeof (x.a[1].c)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c[0], 1) != sizeof (x.a[1].c)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c[3], 1) != sizeof (x.a[1].c) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.b, 1) != sizeof (x.b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a, 1) != sizeof (x.b.a)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a[0], 1) != sizeof (x.b.a)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a[3], 1) != sizeof (x.b.a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.b.b, 1) != sizeof (x.b.b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c, 1) != sizeof (x.b.c)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c[0], 1) != sizeof (x.b.c)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c[3], 1) != sizeof (x.b.c) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.c, 1) != sizeof (x.c)) - abort (); + FAIL (); if (__builtin_object_size (&x.c[0], 1) != sizeof (x.c)) - abort (); + FAIL (); if (__builtin_object_size (&x.c[1], 1) != sizeof (x.c) - 1) - abort (); + FAIL (); if (__builtin_object_size (&x.d, 1) != sizeof (x.d)) - abort (); + FAIL (); if (__builtin_object_size (&x.e, 1) != sizeof (x.e)) - abort (); + FAIL (); if (__builtin_object_size (&x.f, 1) != sizeof (x.f)) - abort (); + FAIL (); dp = &__real__ x.f; if (__builtin_object_size (dp, 1) != sizeof (x.f) / 2) - abort (); + FAIL (); dp = &__imag__ x.f; if (__builtin_object_size (dp, 1) != sizeof (x.f) / 2) - abort (); + FAIL (); dp = &y; if (__builtin_object_size (dp, 1) != sizeof (y)) - abort (); + FAIL (); if (__builtin_object_size (&z, 1) != sizeof (z)) - abort (); + FAIL (); dp = &__real__ z; if (__builtin_object_size (dp, 1) != sizeof (z) / 2) - abort (); + FAIL (); dp = &__imag__ z; if (__builtin_object_size (dp, 1) != sizeof (z) / 2) - abort (); + FAIL (); } struct S { unsigned int a; }; @@ -440,7 +441,7 @@ test4 (char *x, int y) p = (struct A *) x; x = (char *) &p[1]; if (__builtin_object_size (p, 1) != (size_t) -1) - abort (); + FAIL (); } return x; } @@ -457,10 +458,10 @@ test5 (size_t x) p = p + 4; #ifdef __builtin_object_size if (__builtin_object_size (p, 1) != sizeof (t.buf) - 8 - 4 * x) - abort (); + FAIL (); #else if (__builtin_object_size (p, 1) != sizeof (t.buf) - 8) - abort (); + FAIL (); #endif memset (p, ' ', sizeof (t.buf) - 8 - 4 * 4); } @@ -474,11 +475,11 @@ test6 (void) char *p = &buf[64], *q = &t.buf[64]; if (__builtin_object_size (p + 64, 1) != 0) - abort (); + FAIL (); if (__builtin_object_size (q + 0, 1) != 0) - abort (); + FAIL (); if (__builtin_object_size (q + 64, 1) != 0) - abort (); + FAIL (); } void @@ -489,18 +490,18 @@ test7 (void) char *p = &t.buf2[-4]; char *q = &t.buf2[0]; if (__builtin_object_size (p, 1) != 0) - abort (); + FAIL (); if (__builtin_object_size (q, 1) != sizeof (t.buf2)) - abort (); + FAIL (); q = &t.buf[10]; if (__builtin_object_size (q, 1) != 0) - abort (); + FAIL (); q = &t.buf[11]; if (__builtin_object_size (q, 1) != 0) - abort (); + FAIL (); p = &t.buf[-4]; if (__builtin_object_size (p, 1) != 0) - abort (); + FAIL (); } void @@ -517,10 +518,10 @@ test8 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (&p[-4], 1) != (cond ? 6 : 10)) - abort (); + FAIL (); #else if (__builtin_object_size (&p[-4], 1) != 10) - abort (); + FAIL (); #endif for (unsigned i = cond; i > 0; i--) @@ -528,10 +529,10 @@ test8 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (p, 1) != ((cond ? 2 : 6) + cond)) - abort (); + FAIL (); #else if (__builtin_object_size (p, 1) != 10) - abort (); + FAIL (); #endif p = &y.c[8]; @@ -540,10 +541,10 @@ test8 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (p, 1) != sizeof (y.c) - 8 + cond) - abort (); + FAIL (); #else if (__builtin_object_size (p, 1) != sizeof (y.c)) - abort (); + FAIL (); #endif } @@ -555,19 +556,19 @@ test9 (void) const char *ptr = "abcdefghijklmnopqrstuvwxyz"; char *res = strndup (ptr, 21); if (__builtin_object_size (res, 1) != 22) - abort (); + FAIL (); free (res); res = strndup (ptr, 32); if (__builtin_object_size (res, 1) != 27) - abort (); + FAIL (); free (res); res = strdup (ptr); if (__builtin_object_size (res, 1) != 27) - abort (); + FAIL (); free (res); @@ -576,19 +577,19 @@ test9 (void) res = strndup (ptr2, 21); if (__builtin_object_size (res, 1) != 22) - abort (); + FAIL (); free (res); res = strndup (ptr2, 32); if (__builtin_object_size (res, 1) != 33) - abort (); + FAIL (); free (res); res = strndup (ptr2, 128); if (__builtin_object_size (res, 1) != 64) - abort (); + FAIL (); free (res); @@ -598,7 +599,7 @@ test9 (void) #else if (__builtin_object_size (res, 1) != (size_t) -1) #endif - abort (); + FAIL (); free (res); free (ptr2); @@ -606,32 +607,32 @@ test9 (void) ptr = "abcd\0efghijklmnopqrstuvwxyz"; res = strdup (ptr); if (__builtin_object_size (res, 1) != 5) - abort (); + FAIL (); free (res); res = strndup (ptr, 24); if (__builtin_object_size (res, 1) != 5) - abort (); + FAIL (); free (res); res = strndup (ptr, 2); if (__builtin_object_size (res, 1) != 3) - abort (); + FAIL (); free (res); res = strdup (&ptr[4]); if (__builtin_object_size (res, 1) != 1) - abort (); + FAIL (); free (res); res = strndup (&ptr[4], 4); if (__builtin_object_size (res, 1) != 1) - abort (); + FAIL (); free (res); res = strndup (&ptr[4], 1); if (__builtin_object_size (res, 1) != 1) - abort (); + FAIL (); free (res); } @@ -649,5 +650,5 @@ main (void) test7 (); test8 (1); test9 (); - exit (0); + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-3.c b/gcc/testsuite/gcc.dg/builtin-object-size-3.c index ff4f1747334..ad0f981adaa 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-3.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-3.c @@ -2,8 +2,9 @@ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ +#include "builtin-object-size-common.h" + typedef __SIZE_TYPE__ size_t; -extern void abort (void); extern void exit (int); extern void *malloc (size_t); extern void *calloc (size_t, size_t); @@ -39,22 +40,22 @@ test1 (void *q, int x) r = &a.c[1]; if (__builtin_object_size (p, 2) != sizeof (a) - __builtin_offsetof (struct A, a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&a.c[9], 2) != sizeof (a) - __builtin_offsetof (struct A, c) - 9) - abort (); + FAIL (); if (__builtin_object_size (q, 2) != 0) - abort (); + FAIL (); #ifdef __builtin_object_size if (__builtin_object_size (r, 2) != (x < 0 ? sizeof (a) - __builtin_offsetof (struct A, a) - 9 : sizeof (a) - __builtin_offsetof (struct A, c) - 1)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 2) != sizeof (a) - __builtin_offsetof (struct A, c) - 1) - abort (); + FAIL (); #endif if (x < 6) r = &w[2].a[1]; @@ -62,23 +63,23 @@ test1 (void *q, int x) r = &a.a[6]; if (__builtin_object_size (&y, 2) != sizeof (y)) - abort (); + FAIL (); if (__builtin_object_size (w, 2) != sizeof (w)) - abort (); + FAIL (); if (__builtin_object_size (&y.b, 2) != sizeof (a) - __builtin_offsetof (struct A, b)) - abort (); + FAIL (); #ifdef __builtin_object_size if (__builtin_object_size (r, 2) != (x < 6 ? 2 * sizeof (w[0]) - __builtin_offsetof (struct A, a) - 1 : sizeof (a) - __builtin_offsetof (struct A, a) - 6)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 2) != sizeof (a) - __builtin_offsetof (struct A, a) - 6) - abort (); + FAIL (); #endif if (x < 20) r = malloc (30); @@ -86,10 +87,10 @@ test1 (void *q, int x) r = calloc (2, 16); #ifdef __builtin_object_size if (__builtin_object_size (r, 2) != (x < 20 ? 30 : 2 * 16)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 2) != 30) - abort (); + FAIL (); #endif if (x < 20) r = malloc (30); @@ -97,10 +98,10 @@ test1 (void *q, int x) r = calloc (2, 14); #ifdef __builtin_object_size if (__builtin_object_size (r, 2) != (x < 20 ? 30 : 2 * 14)) - abort (); + FAIL (); #else if (__builtin_object_size (r, 2) != 2 * 14) - abort (); + FAIL (); #endif if (x < 30) r = malloc (sizeof (a)); @@ -110,104 +111,104 @@ test1 (void *q, int x) size_t objsz = (x < 30 ? sizeof (a) : sizeof (a) - __builtin_offsetof (struct A, a) - 3); if (__builtin_object_size (r, 2) != objsz) - abort (); + FAIL (); #else if (__builtin_object_size (r, 2) != sizeof (a) - __builtin_offsetof (struct A, a) - 3) - abort (); + FAIL (); #endif r = memcpy (r, "a", 2); #ifdef __builtin_object_size if (__builtin_object_size (r, 2) != objsz) - abort (); + FAIL (); #else if (__builtin_object_size (r, 2) != sizeof (a) - __builtin_offsetof (struct A, a) - 3) - abort (); + FAIL (); #endif r = memcpy (r + 2, "b", 2) + 2; #ifdef __builtin_object_size if (__builtin_object_size (r, 2) != objsz - 4) - abort (); + FAIL (); #else if (__builtin_object_size (r, 2) != sizeof (a) - __builtin_offsetof (struct A, a) - 3 - 4) - abort (); + FAIL (); #endif r = &a.a[4]; r = memset (r, 'a', 2); if (__builtin_object_size (r, 2) != sizeof (a) - __builtin_offsetof (struct A, a) - 4) - abort (); + FAIL (); r = memset (r + 2, 'b', 2) + 2; if (__builtin_object_size (r, 2) != sizeof (a) - __builtin_offsetof (struct A, a) - 8) - abort (); + FAIL (); r = &a.a[1]; r = strcpy (r, "ab"); if (__builtin_object_size (r, 2) != sizeof (a) - __builtin_offsetof (struct A, a) - 1) - abort (); + FAIL (); r = strcpy (r + 2, "cd") + 2; if (__builtin_object_size (r, 2) != sizeof (a) - __builtin_offsetof (struct A, a) - 5) - abort (); + FAIL (); if (__builtin_object_size (exta, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (exta + 10, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&exta[5], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (extb, 2) != sizeof (extb)) - abort (); + FAIL (); if (__builtin_object_size (extb + 10, 2) != sizeof (extb) - 10) - abort (); + FAIL (); if (__builtin_object_size (&extb[5], 2) != sizeof (extb) - 5) - abort (); + FAIL (); #ifdef __builtin_object_size if (__builtin_object_size (var, 2) != x + 10) - abort (); + FAIL (); if (__builtin_object_size (var + 10, 2) != x) - abort (); + FAIL (); if (__builtin_object_size (&var[5], 2) != x + 5) - abort (); + FAIL (); #else if (__builtin_object_size (var, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (var + 10, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&var[5], 2) != 0) - abort (); + FAIL (); #endif if (__builtin_object_size (zerol, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (zerol[0].a, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0].a[0], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0].b, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size ("abcdefg", 2) != sizeof ("abcdefg")) - abort (); + FAIL (); if (__builtin_object_size ("abcd\0efg", 2) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg", 2) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg"[0], 2) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg"[4], 2) != sizeof ("abcd\0efg") - 4) - abort (); + FAIL (); if (__builtin_object_size ("abcd\0efg" + 5, 2) != sizeof ("abcd\0efg") - 5) - abort (); + FAIL (); if (__builtin_object_size (L"abcdefg", 2) != sizeof (L"abcdefg")) - abort (); + FAIL (); r = (char *) L"abcd\0efg"; if (__builtin_object_size (r + 2, 2) != sizeof (L"abcd\0efg") - 2) - abort (); + FAIL (); } size_t l1 = 1; @@ -253,10 +254,10 @@ test2 (void) dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; } if (__builtin_object_size (r, 2) != dyn_res) - abort (); + FAIL (); #else if (__builtin_object_size (r, 2) != 3) - abort (); + FAIL (); #endif r = &buf3[20]; for (i = 0; i < 4; ++i) @@ -271,7 +272,7 @@ test2 (void) r = &a.buf1[9]; } if (__builtin_object_size (r, 2) != 0) - abort (); + FAIL (); r = &buf3[2]; for (i = 0; i < 4; ++i) { @@ -299,28 +300,28 @@ test2 (void) dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 4; } if (__builtin_object_size (r, 2) != dyn_res) - abort (); + FAIL (); #else if (__builtin_object_size (r, 2) != 15) - abort (); + FAIL (); #endif r += 8; #ifdef __builtin_object_size dyn_res -= 8; if (__builtin_object_size (r, 2) != dyn_res) - abort (); + FAIL (); if (dyn_res >= 6) { if (__builtin_object_size (r + 6, 2) != dyn_res - 6) - abort (); + FAIL (); } else if (__builtin_object_size (r + 6, 2) != 0) - abort (); + FAIL (); #else if (__builtin_object_size (r, 2) != 7) - abort (); + FAIL (); if (__builtin_object_size (r + 6, 2) != 1) - abort (); + FAIL (); #endif r = &buf3[18]; for (i = 0; i < 4; ++i) @@ -351,13 +352,13 @@ test2 (void) if (dyn_res >= 12) { if (__builtin_object_size (r + 12, 2) != dyn_res - 12) - abort (); + FAIL (); } else if (__builtin_object_size (r + 12, 2) != 0) - abort (); + FAIL (); #else if (__builtin_object_size (r + 12, 2) != 0) - abort (); + FAIL (); #endif } @@ -373,103 +374,103 @@ test3 (void) double *dp; if (__builtin_object_size (buf4, 2) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4, 2) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4[0], 2) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4[1], 2) != sizeof (buf4) - 1) - abort (); + FAIL (); if (__builtin_object_size (&x, 2) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a, 2) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0], 2) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a, 2) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a[0], 2) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a[3], 2) != sizeof (x) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].b, 2) != sizeof (x) - __builtin_offsetof (struct A, b)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c, 2) != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c[0], 2) != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c[3], 2) != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.b, 2) != sizeof (x) - __builtin_offsetof (struct B, b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a, 2) != sizeof (x) - __builtin_offsetof (struct B, b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a[0], 2) != sizeof (x) - __builtin_offsetof (struct B, b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a[3], 2) != sizeof (x) - __builtin_offsetof (struct B, b) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.b.b, 2) != sizeof (x) - __builtin_offsetof (struct B, b) - __builtin_offsetof (struct A, b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c, 2) != sizeof (x) - __builtin_offsetof (struct B, b) - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c[0], 2) != sizeof (x) - __builtin_offsetof (struct B, b) - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c[3], 2) != sizeof (x) - __builtin_offsetof (struct B, b) - __builtin_offsetof (struct A, c) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.c, 2) != sizeof (x) - __builtin_offsetof (struct B, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.c[0], 2) != sizeof (x) - __builtin_offsetof (struct B, c)) - abort (); + FAIL (); if (__builtin_object_size (&x.c[1], 2) != sizeof (x) - __builtin_offsetof (struct B, c) - 1) - abort (); + FAIL (); if (__builtin_object_size (&x.d, 2) != sizeof (x) - __builtin_offsetof (struct B, d)) - abort (); + FAIL (); if (__builtin_object_size (&x.e, 2) != sizeof (x) - __builtin_offsetof (struct B, e)) - abort (); + FAIL (); if (__builtin_object_size (&x.f, 2) != sizeof (x) - __builtin_offsetof (struct B, f)) - abort (); + FAIL (); dp = &__real__ x.f; if (__builtin_object_size (dp, 2) != sizeof (x) - __builtin_offsetof (struct B, f)) - abort (); + FAIL (); dp = &__imag__ x.f; if (__builtin_object_size (dp, 2) != sizeof (x) - __builtin_offsetof (struct B, f) - sizeof (x.f) / 2) - abort (); + FAIL (); dp = &y; if (__builtin_object_size (dp, 2) != sizeof (y)) - abort (); + FAIL (); if (__builtin_object_size (&z, 2) != sizeof (z)) - abort (); + FAIL (); dp = &__real__ z; if (__builtin_object_size (dp, 2) != sizeof (z)) - abort (); + FAIL (); dp = &__imag__ z; if (__builtin_object_size (dp, 2) != sizeof (z) / 2) - abort (); + FAIL (); } struct S { unsigned int a; }; @@ -486,7 +487,7 @@ test4 (char *x, int y) p = (struct A *) x; x = (char *) &p[1]; if (__builtin_object_size (p, 2) != 0) - abort (); + FAIL (); } return x; } @@ -506,7 +507,7 @@ test5 (size_t x) #else if (__builtin_object_size (p, 2) != 0) #endif - abort (); + FAIL (); memset (p, ' ', sizeof (buf) - 8 - 4 * 4); } @@ -525,7 +526,7 @@ test6 (size_t x) #else if (__builtin_object_size (p, 2) != 0) #endif - abort (); + FAIL (); memset (p, ' ', sizeof (t) - 8 - 4 * 4); } @@ -538,13 +539,13 @@ test7 (void) char *p = &buf[64], *q = &t.buf[64]; if (__builtin_object_size (p + 64, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (q + 63, 2) != sizeof (t) - 64 - 63) - abort (); + FAIL (); if (__builtin_object_size (q + 64, 2) != sizeof (t) - 64 - 64) - abort (); + FAIL (); if (__builtin_object_size (q + 256, 2) != 0) - abort (); + FAIL (); } void @@ -555,17 +556,17 @@ test8 (void) char *p = &t.buf2[-4]; char *q = &t.buf2[0]; if (__builtin_object_size (p, 2) != sizeof (t) - 10 + 4) - abort (); + FAIL (); if (__builtin_object_size (q, 2) != sizeof (t) - 10) - abort (); + FAIL (); /* GCC only handles additions, not subtractions. */ q = q - 8; if (__builtin_object_size (q, 2) != 0 && __builtin_object_size (q, 2) != sizeof (t) - 10 + 8) - abort (); + FAIL (); p = &t.buf[-4]; if (__builtin_object_size (p, 2) != 0) - abort (); + FAIL (); } void @@ -582,10 +583,10 @@ test9 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (&p[-4], 2) != (cond ? 6 : 10)) - abort (); + FAIL (); #else if (__builtin_object_size (&p[-4], 2) != 0) - abort (); + FAIL (); #endif for (unsigned i = cond; i > 0; i--) @@ -593,10 +594,10 @@ test9 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (p, 2) != ((cond ? 2 : 6) + cond)) - abort (); + FAIL (); #else if (__builtin_object_size (p, 2) != 0) - abort (); + FAIL (); #endif p = &y.c[8]; @@ -606,10 +607,10 @@ test9 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (p, 2) != sizeof (y) - __builtin_offsetof (struct A, c) - 8 + cond) - abort (); + FAIL (); #else if (__builtin_object_size (p, 2) != 0) - abort (); + FAIL (); #endif } @@ -627,10 +628,10 @@ test10 (void) { #ifdef __builtin_object_size if (__builtin_object_size (p - 3, 2) != sizeof (buf) - i + 3) - abort (); + FAIL (); #else if (__builtin_object_size (p - 3, 2) != 0) - abort (); + FAIL (); #endif break; } @@ -647,19 +648,19 @@ test11 (void) const char *ptr = "abcdefghijklmnopqrstuvwxyz"; char *res = strndup (ptr, 21); if (__builtin_object_size (res, 2) != 22) - abort (); + FAIL (); free (res); res = strndup (ptr, 32); if (__builtin_object_size (res, 2) != 27) - abort (); + FAIL (); free (res); res = strdup (ptr); if (__builtin_object_size (res, 2) != 27) - abort (); + FAIL (); free (res); @@ -668,19 +669,19 @@ test11 (void) res = strndup (ptr2, 21); if (__builtin_object_size (res, 2) != 1) - abort (); + FAIL (); free (res); res = strndup (ptr2, 32); if (__builtin_object_size (res, 2) != 1) - abort (); + FAIL (); free (res); res = strndup (ptr2, 128); if (__builtin_object_size (res, 2) != 1) - abort (); + FAIL (); free (res); @@ -691,7 +692,7 @@ test11 (void) #else if (__builtin_object_size (res, 2) != 1) #endif - abort (); + FAIL (); free (res); free (ptr2); @@ -699,32 +700,32 @@ test11 (void) ptr = "abcd\0efghijklmnopqrstuvwxyz"; res = strdup (ptr); if (__builtin_object_size (res, 2) != 5) - abort (); + FAIL (); free (res); res = strndup (ptr, 24); if (__builtin_object_size (res, 2) != 5) - abort (); + FAIL (); free (res); res = strndup (ptr, 2); if (__builtin_object_size (res, 2) != 3) - abort (); + FAIL (); free (res); res = strdup (&ptr[4]); if (__builtin_object_size (res, 2) != 1) - abort (); + FAIL (); free (res); res = strndup (&ptr[4], 4); if (__builtin_object_size (res, 2) != 1) - abort (); + FAIL (); free (res); res = strndup (&ptr[4], 1); if (__builtin_object_size (res, 2) != 1) - abort (); + FAIL (); free (res); } @@ -744,5 +745,5 @@ main (void) test9 (1); test10 (); test11 (); - exit (0); + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-4.c b/gcc/testsuite/gcc.dg/builtin-object-size-4.c index 4c007c364b7..34385d3cc9f 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-4.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-4.c @@ -2,8 +2,9 @@ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ +#include "builtin-object-size-common.h" + typedef __SIZE_TYPE__ size_t; -extern void abort (void); extern void exit (int); extern void *malloc (size_t); extern void *calloc (size_t, size_t); @@ -40,36 +41,36 @@ test1 (void *q, int x) else r = &a.c[1]; if (__builtin_object_size (p, 3) != sizeof (a.a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&a.c[9], 3) != sizeof (a.c) - 9) - abort (); + FAIL (); if (__builtin_object_size (q, 3) != 0) - abort (); + FAIL (); #ifdef __builtin_object_size if (__builtin_object_size (r, 3) != (x < 0 ? sizeof (a.a) - 9 : sizeof (a.c) - 1)) #else if (__builtin_object_size (r, 3) != sizeof (a.a) - 9) #endif - abort (); + FAIL (); if (x < 6) r = &w[2].a[1]; else r = &a.a[6]; if (__builtin_object_size (&y, 3) != sizeof (y)) - abort (); + FAIL (); if (__builtin_object_size (w, 3) != sizeof (w)) - abort (); + FAIL (); if (__builtin_object_size (&y.b, 3) != sizeof (a.b)) - abort (); + FAIL (); #ifdef __builtin_object_size if (__builtin_object_size (r, 3) != (x < 6 ? sizeof (w[2].a) - 1 : sizeof (a.a) - 6)) #else if (__builtin_object_size (r, 3) != sizeof (a.a) - 6) #endif - abort (); + FAIL (); if (x < 20) r = malloc (30); else @@ -79,7 +80,7 @@ test1 (void *q, int x) #else if (__builtin_object_size (r, 3) != 30) #endif - abort (); + FAIL (); if (x < 20) r = malloc (30); else @@ -89,7 +90,7 @@ test1 (void *q, int x) #else if (__builtin_object_size (r, 3) != 2 * 14) #endif - abort (); + FAIL (); if (x < 30) r = malloc (sizeof (a)); else @@ -100,125 +101,125 @@ test1 (void *q, int x) #else if (__builtin_object_size (r, 3) != sizeof (a.a) - 3) #endif - abort (); + FAIL (); r = memcpy (r, "a", 2); #ifdef __builtin_object_size if (__builtin_object_size (r, 3) != objsz) #else if (__builtin_object_size (r, 3) != sizeof (a.a) - 3) #endif - abort (); + FAIL (); r = memcpy (r + 2, "b", 2) + 2; #ifdef __builtin_object_size if (__builtin_object_size (r, 3) != objsz - 4) #else if (__builtin_object_size (r, 3) != sizeof (a.a) - 3 - 4) #endif - abort (); + FAIL (); r = &a.a[4]; r = memset (r, 'a', 2); if (__builtin_object_size (r, 3) != sizeof (a.a) - 4) - abort (); + FAIL (); r = memset (r + 2, 'b', 2) + 2; if (__builtin_object_size (r, 3) != sizeof (a.a) - 8) - abort (); + FAIL (); r = &a.a[1]; r = strcpy (r, "ab"); if (__builtin_object_size (r, 3) != sizeof (a.a) - 1) - abort (); + FAIL (); r = strcpy (r + 2, "cd") + 2; if (__builtin_object_size (r, 3) != sizeof (a.a) - 5) - abort (); + FAIL (); if (__builtin_object_size (exta, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (exta + 10, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (&exta[5], 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (extb, 3) != sizeof (extb)) - abort (); + FAIL (); if (__builtin_object_size (extb + 10, 3) != sizeof (extb) - 10) - abort (); + FAIL (); if (__builtin_object_size (&extb[5], 3) != sizeof (extb) - 5) - abort (); + FAIL (); if (__builtin_object_size (extc, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (extc + 10, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (&extc[5], 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (&extc->a, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (&(extc + 10)->b, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (&extc[5].c[3], 3) != 0) - abort (); + FAIL (); #ifdef __builtin_object_size if (__builtin_object_size (var, 3) != x + 10) - abort (); + FAIL (); if (__builtin_object_size (var + 10, 3) != x) - abort (); + FAIL (); if (__builtin_object_size (&var[5], 3) != x + 5) - abort (); + FAIL (); if (__builtin_object_size (vara, 3) != (x + 10) * sizeof (struct A)) - abort (); + FAIL (); if (__builtin_object_size (vara + 10, 3) != x * sizeof (struct A)) - abort (); + FAIL (); if (__builtin_object_size (&vara[5], 3) != (x + 5) * sizeof (struct A)) - abort (); + FAIL (); #else if (__builtin_object_size (var, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (var + 10, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (&var[5], 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (vara, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (vara + 10, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (&vara[5], 3) != 0) - abort (); + FAIL (); #endif if (__builtin_object_size (&vara[0].a, 3) != sizeof (vara[0].a)) - abort (); + FAIL (); if (__builtin_object_size (&vara[10].a[0], 3) != sizeof (vara[0].a)) - abort (); + FAIL (); if (__builtin_object_size (&vara[5].a[4], 3) != sizeof (vara[0].a) - 4) - abort (); + FAIL (); if (__builtin_object_size (&vara[5].b, 3) != sizeof (vara[0].b)) - abort (); + FAIL (); if (__builtin_object_size (&vara[7].c[7], 3) != sizeof (vara[0].c) - 7) - abort (); + FAIL (); if (__builtin_object_size (zerol, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0], 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (zerol[0].a, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0].a[0], 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (&zerol[0].b, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size ("abcdefg", 3) != sizeof ("abcdefg")) - abort (); + FAIL (); if (__builtin_object_size ("abcd\0efg", 3) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg", 3) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg"[0], 3) != sizeof ("abcd\0efg")) - abort (); + FAIL (); if (__builtin_object_size (&"abcd\0efg"[4], 3) != sizeof ("abcd\0efg") - 4) - abort (); + FAIL (); if (__builtin_object_size ("abcd\0efg" + 5, 3) != sizeof ("abcd\0efg") - 5) - abort (); + FAIL (); if (__builtin_object_size (L"abcdefg", 3) != sizeof (L"abcdefg")) - abort (); + FAIL (); r = (char *) L"abcd\0efg"; if (__builtin_object_size (r + 2, 3) != sizeof (L"abcd\0efg") - 2) - abort (); + FAIL (); /* Prevent DSE from removing calls that prevent bad combining of addresses and offsets. */ asm volatile ("" : : "g" (&a)); @@ -253,7 +254,7 @@ test2 (void) r = &a.buf1[9]; } if (__builtin_object_size (r, 3) != sizeof (a.buf1) - 9) - abort (); + FAIL (); r = &buf3[20]; for (i = 0; i < 4; ++i) { @@ -267,7 +268,7 @@ test2 (void) r = &a.buf1[9]; } if (__builtin_object_size (r, 3) != 0) - abort (); + FAIL (); r = &buf3[1]; for (i = 0; i < 4; ++i) { @@ -295,22 +296,22 @@ test2 (void) dyn_res = sizeof (a.buf1) - 2; } if (__builtin_object_size (r, 3) != dyn_res) - abort (); + FAIL (); #else if (__builtin_object_size (r, 3) != sizeof (a.buf1) - 6) - abort (); + FAIL (); #endif r += 2; #ifdef __builtin_object_size if (__builtin_object_size (r, 3) != dyn_res - 2) - abort (); + FAIL (); if (__builtin_object_size (r + 1, 3) != dyn_res - 3) - abort (); + FAIL (); #else if (__builtin_object_size (r, 3) != sizeof (a.buf1) - 6 - 2) - abort (); + FAIL (); if (__builtin_object_size (r + 1, 3) != sizeof (a.buf1) - 6 - 3) - abort (); + FAIL (); #endif } @@ -326,78 +327,78 @@ test3 (void) double *dp; if (__builtin_object_size (buf4, 3) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4, 3) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4[0], 3) != sizeof (buf4)) - abort (); + FAIL (); if (__builtin_object_size (&buf4[1], 3) != sizeof (buf4) - 1) - abort (); + FAIL (); if (__builtin_object_size (&x, 3) != sizeof (x)) - abort (); + FAIL (); if (__builtin_object_size (&x.a, 3) != sizeof (x.a)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0], 3) != sizeof (x.a)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a, 3) != sizeof (x.a[0].a)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a[0], 3) != sizeof (x.a[0].a)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].a[3], 3) != sizeof (x.a[0].a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.a[0].b, 3) != sizeof (x.a[0].b)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c, 3) != sizeof (x.a[1].c)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c[0], 3) != sizeof (x.a[1].c)) - abort (); + FAIL (); if (__builtin_object_size (&x.a[1].c[3], 3) != sizeof (x.a[1].c) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.b, 3) != sizeof (x.b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a, 3) != sizeof (x.b.a)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a[0], 3) != sizeof (x.b.a)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.a[3], 3) != sizeof (x.b.a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.b.b, 3) != sizeof (x.b.b)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c, 3) != sizeof (x.b.c)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c[0], 3) != sizeof (x.b.c)) - abort (); + FAIL (); if (__builtin_object_size (&x.b.c[3], 3) != sizeof (x.b.c) - 3) - abort (); + FAIL (); if (__builtin_object_size (&x.c, 3) != sizeof (x.c)) - abort (); + FAIL (); if (__builtin_object_size (&x.c[0], 3) != sizeof (x.c)) - abort (); + FAIL (); if (__builtin_object_size (&x.c[1], 3) != sizeof (x.c) - 1) - abort (); + FAIL (); if (__builtin_object_size (&x.d, 3) != sizeof (x.d)) - abort (); + FAIL (); if (__builtin_object_size (&x.e, 3) != sizeof (x.e)) - abort (); + FAIL (); if (__builtin_object_size (&x.f, 3) != sizeof (x.f)) - abort (); + FAIL (); dp = &__real__ x.f; if (__builtin_object_size (dp, 3) != sizeof (x.f) / 2) - abort (); + FAIL (); dp = &__imag__ x.f; if (__builtin_object_size (dp, 3) != sizeof (x.f) / 2) - abort (); + FAIL (); dp = &y; if (__builtin_object_size (dp, 3) != sizeof (y)) - abort (); + FAIL (); if (__builtin_object_size (&z, 3) != sizeof (z)) - abort (); + FAIL (); dp = &__real__ z; if (__builtin_object_size (dp, 3) != sizeof (z) / 2) - abort (); + FAIL (); dp = &__imag__ z; if (__builtin_object_size (dp, 3) != sizeof (z) / 2) - abort (); + FAIL (); } struct S { unsigned int a; }; @@ -414,7 +415,7 @@ test4 (char *x, int y) p = (struct A *) x; x = (char *) &p[1]; if (__builtin_object_size (p, 3) != 0) - abort (); + FAIL (); } return x; } @@ -434,7 +435,7 @@ test5 (size_t x) #else if (__builtin_object_size (p, 3) != 0) #endif - abort (); + FAIL (); memset (p, ' ', sizeof (t.buf) - 8 - 4 * 4); } @@ -447,11 +448,11 @@ test6 (void) char *p = &buf[64], *q = &t.buf[64]; if (__builtin_object_size (p + 64, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (q + 0, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (q + 64, 3) != 0) - abort (); + FAIL (); } void @@ -462,18 +463,18 @@ test7 (void) char *p = &t.buf2[-4]; char *q = &t.buf2[0]; if (__builtin_object_size (p, 3) != 0) - abort (); + FAIL (); if (__builtin_object_size (q, 3) != sizeof (t.buf2)) - abort (); + FAIL (); q = &t.buf[10]; if (__builtin_object_size (q, 3) != 0) - abort (); + FAIL (); q = &t.buf[11]; if (__builtin_object_size (q, 3) != 0) - abort (); + FAIL (); p = &t.buf[-4]; if (__builtin_object_size (p, 3) != 0) - abort (); + FAIL (); } void @@ -490,10 +491,10 @@ test8 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (&p[-4], 3) != (cond ? 6 : 10)) - abort (); + FAIL (); #else if (__builtin_object_size (&p[-4], 3) != 0) - abort (); + FAIL (); #endif for (unsigned i = cond; i > 0; i--) @@ -501,10 +502,10 @@ test8 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (p, 3) != ((cond ? 2 : 6) + cond)) - abort (); + FAIL (); #else if (__builtin_object_size (p, 3) != 0) - abort (); + FAIL (); #endif p = &y.c[8]; @@ -513,10 +514,10 @@ test8 (unsigned cond) #ifdef __builtin_object_size if (__builtin_object_size (p, 3) != sizeof (y.c) - 8 + cond) - abort (); + FAIL (); #else if (__builtin_object_size (p, 3) != 0) - abort (); + FAIL (); #endif } @@ -528,19 +529,19 @@ test9 (void) const char *ptr = "abcdefghijklmnopqrstuvwxyz"; char *res = strndup (ptr, 21); if (__builtin_object_size (res, 3) != 22) - abort (); + FAIL (); free (res); res = strndup (ptr, 32); if (__builtin_object_size (res, 3) != 27) - abort (); + FAIL (); free (res); res = strdup (ptr); if (__builtin_object_size (res, 3) != 27) - abort (); + FAIL (); free (res); @@ -549,19 +550,19 @@ test9 (void) res = strndup (ptr2, 21); if (__builtin_object_size (res, 3) != 1) - abort (); + FAIL (); free (res); res = strndup (ptr2, 32); if (__builtin_object_size (res, 3) != 1) - abort (); + FAIL (); free (res); res = strndup (ptr2, 128); if (__builtin_object_size (res, 3) != 1) - abort (); + FAIL (); free (res); @@ -571,7 +572,7 @@ test9 (void) #else if (__builtin_object_size (res, 3) != 1) #endif - abort (); + FAIL (); free (res); free (ptr2); @@ -579,32 +580,32 @@ test9 (void) ptr = "abcd\0efghijklmnopqrstuvwxyz"; res = strdup (ptr); if (__builtin_object_size (res, 3) != 5) - abort (); + FAIL (); free (res); res = strndup (ptr, 24); if (__builtin_object_size (res, 3) != 5) - abort (); + FAIL (); free (res); res = strndup (ptr, 2); if (__builtin_object_size (res, 3) != 3) - abort (); + FAIL (); free (res); res = strdup (&ptr[4]); if (__builtin_object_size (res, 3) != 1) - abort (); + FAIL (); free (res); res = strndup (&ptr[4], 4); if (__builtin_object_size (res, 3) != 1) - abort (); + FAIL (); free (res); res = strndup (&ptr[4], 1); if (__builtin_object_size (res, 3) != 1) - abort (); + FAIL (); free (res); } @@ -622,5 +623,5 @@ main (void) test7 (); test8 (1); test9 (); - exit (0); + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-6.c b/gcc/testsuite/gcc.dg/builtin-object-size-6.c index c6887b854ac..4ce05184143 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-6.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-6.c @@ -1,8 +1,9 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ +#include "builtin-object-size-common.h" + typedef __SIZE_TYPE__ size_t; -extern void abort (void); extern void exit (int); extern void *malloc (size_t); extern void free (void *); @@ -20,105 +21,105 @@ test1 (struct A *p) { char *c; if (__builtin_object_size (&p->a, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != (size_t) -1) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != (size_t) -1) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 1) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 1) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 2) != 0) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 3) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 3) != 0) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 3) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 3) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 3) != 0) - abort (); + FAIL (); } void @@ -129,105 +130,105 @@ test2 (void) size_t s = 2 * sizeof (struct A); struct A *p = malloc (2 * sizeof (struct A)); if (__builtin_object_size (&p->a, 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != s - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (struct A, b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != s - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 0) != s) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 0) != s) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 0) != s - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 0) != s - __builtin_offsetof (struct A, b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 0) != s - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != s - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 1) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 1) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 1) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 1) != s - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 2) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 2) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 2) != s - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 2) != s - __builtin_offsetof (struct A, b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 2) != s - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 2) != s) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 2) != s) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 2) != s - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 2) != s - __builtin_offsetof (struct A, b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 2) != s - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 3) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 3) != s - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); c = p->a; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[0]; if (__builtin_object_size (c, 3) != sizeof (p->a)) - abort (); + FAIL (); c = &p->a[3]; if (__builtin_object_size (c, 3) != sizeof (p->a) - 3) - abort (); + FAIL (); c = (char *) &p->b; if (__builtin_object_size (c, 3) != sizeof (p->b)) - abort (); + FAIL (); c = (char *) &p->c; if (__builtin_object_size (c, 3) != s - __builtin_offsetof (struct A, c)) - abort (); + FAIL (); free (p); } @@ -239,48 +240,48 @@ test3 (void) size_t s; struct A *p = malloc (4); if (__builtin_object_size (&p->a, 0) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != 1) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != 1) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != 0) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != 0) - abort (); + FAIL (); free (p); s = __builtin_offsetof (struct A, c) + 4; p = malloc (s); if (__builtin_object_size (&p->a, 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 0) != s) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 0) != s - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (struct A, b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 0) != 4) - abort (); + FAIL (); if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) - abort (); + FAIL (); if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) - abort (); + FAIL (); if (__builtin_object_size (&p->c, 1) != 4) - abort (); + FAIL (); free (p); } @@ -294,17 +295,17 @@ __attribute__ ((noinline)) test4 (struct B *q, int i) { if (__builtin_object_size (&q->a[2].a[2], 1) != sizeof (q->a[0].a) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[2].c[2], 1) != sizeof (q->a[0].c) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[3].a[2], 1) != sizeof (q->a[0].a) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[3].c[2], 1) != sizeof (q->a[0].c) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[i].a[2], 1) != sizeof (q->a[0].a) - 2) - abort (); + FAIL (); if (__builtin_object_size (&q->a[i].c[2], 1) != sizeof (q->a[0].c) - 2) - abort (); + FAIL (); } struct C @@ -318,13 +319,13 @@ __attribute__ ((noinline)) test5 (struct C *c) { if (__builtin_object_size (&c->b, 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&c->b, 1) != 1) - abort (); + FAIL (); if (__builtin_object_size (&c->b, 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&c->b, 3) != 1) - abort (); + FAIL (); } struct D @@ -342,13 +343,13 @@ __attribute__ ((noinline)) test6 (struct D *d) { if (__builtin_object_size (&d->j.a[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&d->j.a[3], 1) != sizeof (d->j.a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&d->j.a[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&d->j.a[3], 3) != sizeof (d->j.a) - 3) - abort (); + FAIL (); } struct E @@ -366,21 +367,21 @@ __attribute__ ((noinline)) test7 (struct E *e) { if (__builtin_object_size (&e->j[0].a[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&e->j[0].a[3], 1) != sizeof (e->j[0].a) - 3) - abort (); + FAIL (); if (__builtin_object_size (&e->j[0].a[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&e->j[0].a[3], 3) != sizeof (e->j[0].a) - 3) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size ((char *) &e->j[0], 3) != 0) - abort (); + FAIL (); } union F @@ -398,13 +399,13 @@ __attribute__ ((noinline)) test8 (union F *f) { if (__builtin_object_size (&f->d.c[3], 0) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&f->d.c[3], 1) != (size_t) -1) - abort (); + FAIL (); if (__builtin_object_size (&f->d.c[3], 2) != 0) - abort (); + FAIL (); if (__builtin_object_size (&f->d.c[3], 3) != 0) - abort (); + FAIL (); } int @@ -431,5 +432,5 @@ main (void) union F f, *fp = &f; __asm ("" : "+r" (fp)); test8 (fp); - exit (0); + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-7.c b/gcc/testsuite/gcc.dg/builtin-object-size-7.c index 41742b974ef..15d7cfade8f 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-7.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-7.c @@ -1,6 +1,8 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ +#include "builtin-object-size-common.h" + typedef __SIZE_TYPE__ size_t; extern void *malloc (size_t); extern void abort (void); @@ -20,52 +22,52 @@ main (void) struct A *a = malloc (s); struct A *b = malloc (o + 212); if (__builtin_object_size (a->buf, 0) != s - o) - abort (); + FAIL (); if (__builtin_object_size (a->buf, 1) != sizeof (a->buf)) - abort (); + FAIL (); if (__builtin_object_size (a->buf, 2) != s - o) - abort (); + FAIL (); if (__builtin_object_size (a->buf, 3) != sizeof (a->buf)) - abort (); + FAIL (); if (__builtin_object_size (&a->buf[0], 0) != s - o) - abort (); + FAIL (); if (__builtin_object_size (&a->buf[0], 1) != sizeof (a->buf)) - abort (); + FAIL (); if (__builtin_object_size (&a->buf[0], 2) != s - o) - abort (); + FAIL (); if (__builtin_object_size (&a->buf[0], 3) != sizeof (a->buf)) - abort (); + FAIL (); if (__builtin_object_size (&a->buf[6], 0) != s - o - 6) - abort (); + FAIL (); if (__builtin_object_size (&a->buf[6], 1) != sizeof (a->buf) - 6) - abort (); + FAIL (); if (__builtin_object_size (&a->buf[6], 2) != s - o - 6) - abort (); + FAIL (); if (__builtin_object_size (&a->buf[6], 3) != sizeof (a->buf) - 6) - abort (); + FAIL (); if (__builtin_object_size (b->buf, 0) != 212) - abort (); + FAIL (); if (__builtin_object_size (b->buf, 1) != 212) - abort (); + FAIL (); if (__builtin_object_size (b->buf, 2) != 212) - abort (); + FAIL (); if (__builtin_object_size (b->buf, 3) != 212) - abort (); + FAIL (); if (__builtin_object_size (&b->buf[0], 0) != 212) - abort (); + FAIL (); if (__builtin_object_size (&b->buf[0], 1) != 212) - abort (); + FAIL (); if (__builtin_object_size (&b->buf[0], 2) != 212) - abort (); + FAIL (); if (__builtin_object_size (&b->buf[0], 3) != 212) - abort (); + FAIL (); if (__builtin_object_size (&b->buf[28], 0) != 212 - 28) - abort (); + FAIL (); if (__builtin_object_size (&b->buf[28], 1) != 212 - 28) - abort (); + FAIL (); if (__builtin_object_size (&b->buf[28], 2) != 212 - 28) - abort (); + FAIL (); if (__builtin_object_size (&b->buf[28], 3) != 212 - 28) - abort (); - return 0; + FAIL (); + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-8.c b/gcc/testsuite/gcc.dg/builtin-object-size-8.c index f2d88f9d591..f67902e29f0 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-8.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-8.c @@ -1,10 +1,11 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ +#include "builtin-object-size-common.h" + typedef __SIZE_TYPE__ size_t; extern void *malloc (size_t); extern void free (void *); -extern void abort (void); union A { @@ -56,13 +57,13 @@ struct H #define T(X, S0, S1) \ if (__builtin_object_size (X, 0) != (S0)) \ - abort (); \ + FAIL (); \ if (__builtin_object_size (X, 1) != (S1)) \ - abort (); \ + FAIL (); \ if (__builtin_object_size (X, 2) != (S0)) \ - abort (); \ + FAIL (); \ if (__builtin_object_size (X, 3) != (S1)) \ - abort () + FAIL () #define TS(X, S0) T(&X, S0, sizeof (X)) #define TA(X, S0, S1) \ T(X, S0, S1); T(&X[0], S0, S1); T(&X[1], (S0) - 1, (S1) - 1) @@ -196,5 +197,5 @@ main (void) free (h2); free (h1); - return 0; + DONE (); } diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-common.h b/gcc/testsuite/gcc.dg/builtin-object-size-common.h new file mode 100644 index 00000000000..ca3b65c7ab5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtin-object-size-common.h @@ -0,0 +1,12 @@ +unsigned nfails = 0; + +#define FAIL() ({ \ + __builtin_printf ("Failure at line: %d\n", __LINE__); \ + nfails++; \ +}) + +#define DONE() ({ \ + if (nfails > 0) \ + __builtin_abort (); \ + return 0; \ +}) diff --git a/gcc/testsuite/gcc.dg/pr101836.c b/gcc/testsuite/gcc.dg/pr101836.c index efad02cfe89..87495236be4 100644 --- a/gcc/testsuite/gcc.dg/pr101836.c +++ b/gcc/testsuite/gcc.dg/pr101836.c @@ -4,16 +4,17 @@ /* { dg-do run } */ /* { dg-options "-O2 -fstrict-flex-arrays" } */ -#include +#include "builtin-object-size-common.h" +typedef __SIZE_TYPE__ size_t; #define expect(p, _v) do { \ size_t v = _v; \ if (p == v) \ - printf("ok: %s == %zd\n", #p, p); \ + __builtin_printf("ok: %s == %zd\n", #p, p); \ else \ { \ - printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ - __builtin_abort (); \ + __builtin_printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + FAIL (); \ } \ } while (0); @@ -56,5 +57,5 @@ int main(int argc, char *argv[]) { stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]); - return 0; + DONE (); } diff --git a/gcc/testsuite/gcc.dg/strict-flex-array-3.c b/gcc/testsuite/gcc.dg/strict-flex-array-3.c index 602f99dc79a..2592e3fa8e7 100644 --- a/gcc/testsuite/gcc.dg/strict-flex-array-3.c +++ b/gcc/testsuite/gcc.dg/strict-flex-array-3.c @@ -4,16 +4,17 @@ /* { dg-do run } */ /* { dg-options "-O2 -fstrict-flex-arrays=0" } */ -#include +#include "builtin-object-size-common.h" +typedef __SIZE_TYPE__ size_t; #define expect(p, _v) do { \ size_t v = _v; \ if (p == v) \ - printf("ok: %s == %zd\n", #p, p); \ + __builtin_printf ("ok: %s == %zd\n", #p, p); \ else \ { \ - printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ - __builtin_abort (); \ + __builtin_printf ("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + FAIL (); \ } \ } while (0); @@ -56,5 +57,5 @@ int main(int argc, char *argv[]) { stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]); - return 0; + DONE (); }