From patchwork Wed Feb 1 16:46:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1735759 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gotplt.org header.i=@gotplt.org header.a=rsa-sha256 header.s=dreamhost header.b=ioOWPC9X; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P6SW96Bgxz23j9 for ; Thu, 2 Feb 2023 03:46:59 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A3133858288 for ; Wed, 1 Feb 2023 16:46:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from hedgehog.birch.relay.mailchannels.net (hedgehog.birch.relay.mailchannels.net [23.83.209.81]) by sourceware.org (Postfix) with ESMTPS id 31DDE3858D33 for ; Wed, 1 Feb 2023 16:46:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 31DDE3858D33 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 0E86B501B3C; Wed, 1 Feb 2023 16:46:35 +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 89319501D60; Wed, 1 Feb 2023 16:46:31 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1675269994; a=rsa-sha256; cv=none; b=RMFo/M8I4SrwuyRO8AhPR9L7KGufec1z6AAuLmVD8Tcr7D8XEK/pMi1GnQ7qB1my1PdsRi UrUQ9psZKugYYnjykvRWIKRVHE37gcINl9n8cyabP54cN7z0onXkaTU1BgV2aWZRBYvhF3 emvQXYH/VQpWJb7I0Q1RRxcwDQtRLpcEu8/KcduOoYZe05Gl8S/neqCpFOfn2dubkQDSVn M6kseHz/FrjKPZXz1nVs+xBC0veT9gu9jIMnqDI8e5nDqxJ4CmTgtuSb3cjCYjT2RT+EWU hEEwhBwImakwkIr1hLnVEAi/I4+gQBKgUvT9JnHnqps/lz75xeFEmCUDKRZnOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1675269994; 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=72bIT0c7WGh77XaQY1xvM5bNOiUzhSN2HOVrlibOPzs=; b=GyvjpVwWW9R2fw/qBTv5lrG7TmWYNx/eL1XM2H+GOQ1cUpMoEJQLTKSEUFVz/fgUdVeW7N MVgr0mlzSLdh9JAKEIy8za6cibOgRnJvY7jDJR6ceEf3VDac9lJcJqY9Sq1SNIxpLfI1qf 6sZqqO3M2UmG1WytXw2qusftWzP7ayLQmfaeH80NHNIJ9zuEAVUAefVhXmmoCwOVkWBprf 5tvqHO2HI+N7IJ74dm7EpDiM3CMHL9dHdlys//wuC9G1YXL1BOrF3JwF7LS07toe3ajsQC bQQV1sOFAkB8hbOTEjttsoyMYxbzFzVttCeZJwGYJfKEbTrD77fwiZgEXb2p3Q== ARC-Authentication-Results: i=1; rspamd-5fb8f68d88-gmcpr; 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-Army-Madly: 372253ad2e0bcee4_1675269994894_2649485403 X-MC-Loop-Signature: 1675269994893:2549487539 X-MC-Ingress-Time: 1675269994893 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.99.229.7 (trex/6.7.1); Wed, 01 Feb 2023 16:46:34 +0000 Received: from fedora.redhat.com (bras-vprn-toroon4834w-lp130-07-174-93-43-36.dsl.bell.ca [174.93.43.36]) (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 4P6SVZ6tSyz3f; Wed, 1 Feb 2023 08:46:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1675269991; bh=72bIT0c7WGh77XaQY1xvM5bNOiUzhSN2HOVrlibOPzs=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=ioOWPC9Xln6Vkqo2x/jRIn1ACThtyU5NPlpdRJ2nuPfhYDUJaIga94cV8MRdVKIls i4gqAydKM9QJE8fyZD7cC8EFBOkP3WydGJcBnwyJCxE+b49oVqT6amZ3GtjvNjXxN8 DTHHsYqPzQI/mNxBPxH6Exdq/kX/M3w/crR4EL+7Fcqq0YoHFy6+GO2BJf/n1Y7ayE h4/P5VsLhIJQqyE2qyDqerDgGsC5TiY4Xm0a1gDivS39HxRnlxjyaBgej42Gij+QkK yTnvxj3guSFffodRkCPegzH3Z/0CAzlRaovB/C5q700RESLedTU/A801xUjA3yq3/l YWRZQFn0K9mtg== From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Cc: jakub@redhat.com Subject: [committed v2] testsuite: Run __bos tests to completion Date: Wed, 1 Feb 2023 11:46:26 -0500 Message-Id: <20230201164626.699192-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-3037.4 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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 | 260 ++++++++------- .../g++.dg/ext/builtin-object-size2.C | 260 ++++++++------- .../gcc.dg/builtin-dynamic-object-size-0.c | 14 +- gcc/testsuite/gcc.dg/builtin-object-size-1.c | 297 ++++++++--------- gcc/testsuite/gcc.dg/builtin-object-size-12.c | 12 +- gcc/testsuite/gcc.dg/builtin-object-size-13.c | 15 +- gcc/testsuite/gcc.dg/builtin-object-size-15.c | 11 +- gcc/testsuite/gcc.dg/builtin-object-size-2.c | 305 +++++++++--------- gcc/testsuite/gcc.dg/builtin-object-size-3.c | 275 ++++++++-------- gcc/testsuite/gcc.dg/builtin-object-size-4.c | 285 ++++++++-------- gcc/testsuite/gcc.dg/builtin-object-size-6.c | 260 ++++++++------- gcc/testsuite/gcc.dg/builtin-object-size-7.c | 54 ++-- gcc/testsuite/gcc.dg/builtin-object-size-8.c | 15 +- .../gcc.dg/builtin-object-size-common.h | 32 ++ gcc/testsuite/gcc.dg/pr101836.c | 10 +- gcc/testsuite/gcc.dg/strict-flex-array-3.c | 10 +- 16 files changed, 1039 insertions(+), 1076 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..ebbeced1942 100644 --- a/gcc/testsuite/g++.dg/ext/builtin-object-size1.C +++ b/gcc/testsuite/g++.dg/ext/builtin-object-size1.C @@ -1,11 +1,7 @@ // { dg-do run } // { dg-options "-O2" } -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 *); +#include "../../gcc.dg/builtin-object-size-common.h" struct A { @@ -20,105 +16,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 +125,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 +235,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 +290,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 +314,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 +338,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 +362,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 +394,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 +427,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..7a8f4e62733 100644 --- a/gcc/testsuite/g++.dg/ext/builtin-object-size2.C +++ b/gcc/testsuite/g++.dg/ext/builtin-object-size2.C @@ -1,11 +1,7 @@ // { dg-do run } // { dg-options "-O2" } -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 *); +#include "../../gcc.dg/builtin-object-size-common.h" typedef struct A { @@ -23,105 +19,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 +128,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 +238,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 +293,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 +317,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 +341,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 +365,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 +397,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 +430,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 76079d8702e..6da04202ffe 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 @@ -604,13 +606,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) { @@ -790,8 +785,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..db325801f93 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-1.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-1.c @@ -2,18 +2,7 @@ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ -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); -extern void free (void *); -extern void *alloca (size_t); -extern void *memcpy (void *, const void *, size_t); -extern void *memset (void *, int, size_t); -extern char *strcpy (char *, const char *); -extern char *strdup (const char *); -extern char *strndup (const char *, size_t); +#include "builtin-object-size-common.h" struct A { @@ -39,22 +28,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 +51,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 +75,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 +90,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 +101,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; @@ -242,19 +231,19 @@ test2 (void) for (i = 0; i < 4; ++i) { if (i == l1 - 1) - res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 1; + res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 1; else if (i == l1) - res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 7; + res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 7; else if (i == l1 + 1) - res = sizeof (buf3) - 5; + res = sizeof (buf3) - 5; else if (i == l1 + 2) - res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; + res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; } #else res = 20; #endif if (__builtin_object_size (r, 0) != res) - abort (); + FAIL (); r = &buf3[20]; for (i = 0; i < 4; ++i) { @@ -273,38 +262,38 @@ test2 (void) for (i = 0; i < 4; ++i) { if (i == l1 - 1) - res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 7; + res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 7; else if (i == l1) - res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 7; + res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 7; else if (i == l1 + 1) - res = sizeof (buf3) - 5; + res = sizeof (buf3) - 5; else if (i == l1 + 2) - res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; + 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) @@ -324,24 +313,24 @@ test2 (void) for (i = 0; i < 4; ++i) { if (i == l1 - 1) - res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; + res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; else if (i == l1) - res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 9; + res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 9; else if (i == l1 + 1) - res = sizeof (buf3) - 5; + res = sizeof (buf3) - 5; else if (i == l1 + 2) - res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 4; + res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 4; } 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 +346,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 +459,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 +476,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 +486,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 +503,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 +520,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 +537,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 +564,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 +575,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 +588,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 +609,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 +630,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 +651,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 +673,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 +725,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..7b6264d7486 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-13.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-13.c @@ -1,10 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ -typedef __SIZE_TYPE__ size_t; -extern void *malloc (size_t); -extern void free (void *); -extern void abort (void); +#include "builtin-object-size-common.h" union A { @@ -56,13 +53,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 +344,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..4c71b1f6a37 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-2.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-2.c @@ -2,18 +2,7 @@ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ -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); -extern void free (void *); -extern void *alloca (size_t); -extern void *memcpy (void *, const void *, size_t); -extern void *memset (void *, int, size_t); -extern char *strcpy (char *, const char *); -extern char *strdup (const char *); -extern char *strndup (const char *, size_t); +#include "builtin-object-size-common.h" struct A { @@ -40,39 +29,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 +69,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 +84,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 +95,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 +266,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) @@ -300,19 +289,19 @@ test2 (void) for (i = 0; i < 4; ++i) { if (i == l1 - 1) - dyn_res = sizeof (a.buf1) - 7; + dyn_res = sizeof (a.buf1) - 7; else if (i == l1) - dyn_res = sizeof (a.buf2) - 7; + dyn_res = sizeof (a.buf2) - 7; else if (i == l1 + 1) - dyn_res = sizeof (buf3) - 5; + dyn_res = sizeof (buf3) - 5; else if (i == l1 + 2) - dyn_res = sizeof (a.buf1) - 9; + 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 +309,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 +341,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 +429,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 +446,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 +463,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 +478,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 +506,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 +517,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 +529,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 +544,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 +565,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 +587,7 @@ test9 (void) #else if (__builtin_object_size (res, 1) != (size_t) -1) #endif - abort (); + FAIL (); free (res); free (ptr2); @@ -606,32 +595,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 +638,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..3d907ef4814 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-3.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-3.c @@ -2,18 +2,7 @@ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ -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); -extern void free (void *); -extern void *alloca (size_t); -extern void *memcpy (void *, const void *, size_t); -extern void *memset (void *, int, size_t); -extern char *strcpy (char *, const char *); -extern char *strdup (const char *); -extern char *strndup (const char *, size_t); +#include "builtin-object-size-common.h" struct A { @@ -39,22 +28,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 +51,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 +75,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 +86,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)); @@ -108,106 +97,106 @@ test1 (void *q, int x) r = &a.a[3]; #ifdef __builtin_object_size size_t objsz = (x < 30 ? sizeof (a) - : sizeof (a) - __builtin_offsetof (struct A, a) - 3); + : 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 +242,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 +260,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 +288,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 +340,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 +362,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 +475,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 +495,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 +514,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 +527,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 +544,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 +571,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 +582,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 +595,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 +616,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 +636,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 +657,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 +680,7 @@ test11 (void) #else if (__builtin_object_size (res, 2) != 1) #endif - abort (); + FAIL (); free (res); free (ptr2); @@ -699,32 +688,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 +733,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..c9af07499a4 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-4.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-4.c @@ -2,18 +2,7 @@ /* { dg-options "-O2 -Wno-stringop-overread" } */ /* { dg-require-effective-target alloca } */ -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); -extern void free (void *); -extern void *alloca (size_t); -extern void *memcpy (void *, const void *, size_t); -extern void *memset (void *, int, size_t); -extern char *strcpy (char *, const char *); -extern char *strdup (const char *); -extern char *strndup (const char *, size_t); +#include "builtin-object-size-common.h" struct A { @@ -40,36 +29,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 +68,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 +78,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 +89,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 +242,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 +256,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) { @@ -286,31 +275,31 @@ test2 (void) for (i = 0; i < 4; ++i) { if (i == l1 - 1) - dyn_res = sizeof (a.buf1) - 6; + dyn_res = sizeof (a.buf1) - 6; else if (i == l1) - dyn_res = sizeof (a.buf2) - 4; + dyn_res = sizeof (a.buf2) - 4; else if (i == l1 + 1) - dyn_res = sizeof (buf3) - 5; + dyn_res = sizeof (buf3) - 5; else if (i == l1 + 2) - dyn_res = sizeof (a.buf1) - 2; + 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 +315,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 +403,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 +423,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 +436,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 +451,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 +479,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 +490,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 +502,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 +517,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 +538,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 +560,7 @@ test9 (void) #else if (__builtin_object_size (res, 3) != 1) #endif - abort (); + FAIL (); free (res); free (ptr2); @@ -579,32 +568,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 +611,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..b456b321db0 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-6.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-6.c @@ -1,11 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ -typedef __SIZE_TYPE__ size_t; -extern void abort (void); -extern void exit (int); -extern void *malloc (size_t); -extern void free (void *); +#include "builtin-object-size-common.h" struct A { @@ -20,105 +16,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 +125,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 +235,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 +290,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 +314,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 +338,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 +362,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 +394,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 +427,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..0d11c429876 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-7.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-7.c @@ -1,9 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ -typedef __SIZE_TYPE__ size_t; -extern void *malloc (size_t); -extern void abort (void); +#include "builtin-object-size-common.h" struct A { @@ -20,52 +18,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..294e5242633 100644 --- a/gcc/testsuite/gcc.dg/builtin-object-size-8.c +++ b/gcc/testsuite/gcc.dg/builtin-object-size-8.c @@ -1,10 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ -typedef __SIZE_TYPE__ size_t; -extern void *malloc (size_t); -extern void free (void *); -extern void abort (void); +#include "builtin-object-size-common.h" union A { @@ -56,13 +53,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 +193,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..66ff7cdd953 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtin-object-size-common.h @@ -0,0 +1,32 @@ +typedef __SIZE_TYPE__ size_t; +#ifdef __cplusplus +extern "C" { +#endif + extern void exit (int); + extern void *malloc (size_t); + extern void free (void *); + extern void *calloc (size_t, size_t); + extern void *alloca (size_t); + extern void *memcpy (void *, const void *, size_t); + extern void *memset (void *, int, size_t); + extern char *strcpy (char *, const char *); + extern char *strdup (const char *); + extern char *strndup (const char *, size_t); +#ifdef __cplusplus +} +#endif + +unsigned nfails = 0; + +#define FAIL() \ + do { \ + __builtin_printf ("Failure at line: %d\n", __LINE__); \ + nfails++; \ + } while (0) + +#define DONE() \ + do { \ + if (nfails > 0) \ + __builtin_abort (); \ + return 0; \ + } while (0) diff --git a/gcc/testsuite/gcc.dg/pr101836.c b/gcc/testsuite/gcc.dg/pr101836.c index efad02cfe89..096196d9b7f 100644 --- a/gcc/testsuite/gcc.dg/pr101836.c +++ b/gcc/testsuite/gcc.dg/pr101836.c @@ -4,16 +4,16 @@ /* { dg-do run } */ /* { dg-options "-O2 -fstrict-flex-arrays" } */ -#include +#include "builtin-object-size-common.h" #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 +56,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..f74ed96c751 100644 --- a/gcc/testsuite/gcc.dg/strict-flex-array-3.c +++ b/gcc/testsuite/gcc.dg/strict-flex-array-3.c @@ -4,16 +4,16 @@ /* { dg-do run } */ /* { dg-options "-O2 -fstrict-flex-arrays=0" } */ -#include +#include "builtin-object-size-common.h" #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 +56,5 @@ int main(int argc, char *argv[]) { stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]); - return 0; + DONE (); }