From patchwork Tue Feb 28 18:47:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 65809 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B581B3858410 for ; Tue, 28 Feb 2023 18:48:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B581B3858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677610106; bh=jmw7c91O3FG5p3HME1YQ2YImHLpDWeFqxeT1JgvGWxM=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=NO7zfaLzMvPYLjQhrHXem9lRL+ZTOTYJcHlmzbRJtkE3YcsJduPNO51KR9QwG5aiH cY+Bz9lXgCb2fGRBv8xPebWSd2d7+U9WkGqJ0dQ8J0bLLdaFcyFkZFiZl/hIOhbW1C R7WS/0XVaP2eSF6wbqIM8NaHl/s/uvUhacM4/Kdg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by sourceware.org (Postfix) with ESMTPS id EF8693858D33 for ; Tue, 28 Feb 2023 18:47:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF8693858D33 To: CC: Subject: [PATCH 1/2] testsuite: Fix analyzer errors for newlib-errno MIME-Version: 1.0 Message-ID: <20230228184735.24E6E20438@pchp3.se.axis.com> Date: Tue, 28 Feb 2023 19:47:35 +0100 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, 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: , X-Patchwork-Original-From: Hans-Peter Nilsson via Gcc-patches From: Hans-Peter Nilsson Reply-To: Hans-Peter Nilsson Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Ok to commit? -- >8 -- Investigating analyzer tesstsuite errors for cris-elf. The same are seen for pru-elf according to posts to gcc-testresults@. For glibc, errno is #defined as: extern int *__errno_location (void) __THROW __attribute_const__; # define errno (*__errno_location ()) while for newlib in its default configuration, it's: #define errno (*__errno()) extern int *__errno (void); The critical difference is that __attribute__ ((__const__)), where glibc says that the caller will see the same value on all calls (from the same context; read: same thread). I'm not sure the absence of __attribute__ ((__const__)) for the newlib definition is deliberate, but I guess it can. Either way, without the "const" attribute, it can't be known that the same location will be returned the next time, so analyzer-tests that depend the value being known it should see UNKNOWN rather than TRUE, that's why the deliberate check for UNKNOWN rather than xfailing the test. For isatty-1.c, it's the same problem, but here it'd be unweildy with the extra dg-lines, so better just skip it for newlib targets. testsuite: * gcc.dg/analyzer/call-summaries-errno.c: Expect UNKNOWN for newlib after having set errno. * gcc.dg/analyzer/errno-1.c: Ditto. * gcc.dg/analyzer/isatty-1.c: Skip for newlib targets. --- gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c | 3 ++- gcc/testsuite/gcc.dg/analyzer/errno-1.c | 3 ++- gcc/testsuite/gcc.dg/analyzer/isatty-1.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c b/gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c index e4333b30bb77..cf4d9f7141e4 100644 --- a/gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c +++ b/gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c @@ -13,5 +13,6 @@ void test_sets_errno (int y) sets_errno (y); sets_errno (y); - __analyzer_eval (errno == y); /* { dg-warning "TRUE" } */ + __analyzer_eval (errno == y); /* { dg-warning "TRUE" "errno is at a constant location" { target { ! newlib } } } */ + /* { dg-warning "UNKNOWN" "errno is not known to be at a constant location" { target { newlib } } .-1 } */ } diff --git a/gcc/testsuite/gcc.dg/analyzer/errno-1.c b/gcc/testsuite/gcc.dg/analyzer/errno-1.c index 6b9d28c10799..af0cc3d52a36 100644 --- a/gcc/testsuite/gcc.dg/analyzer/errno-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/errno-1.c @@ -17,7 +17,8 @@ void test_storing_to_errno (int val) { __analyzer_eval (errno == val); /* { dg-warning "UNKNOWN" } */ errno = val; - __analyzer_eval (errno == val); /* { dg-warning "TRUE" } */ + __analyzer_eval (errno == val); /* { dg-warning "TRUE" "errno is at a constant location" { target { ! newlib } } } */ + /* { dg-warning "UNKNOWN" "errno is not known to be at a constant location" { target { newlib } } .-1 } */ external_fn (); __analyzer_eval (errno == val); /* { dg-warning "UNKNOWN" } */ } diff --git a/gcc/testsuite/gcc.dg/analyzer/isatty-1.c b/gcc/testsuite/gcc.dg/analyzer/isatty-1.c index 389d2cdf3f18..450a7d71990d 100644 --- a/gcc/testsuite/gcc.dg/analyzer/isatty-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/isatty-1.c @@ -1,4 +1,4 @@ -/* { dg-skip-if "" { powerpc*-*-aix* } } */ +/* { dg-skip-if "" { powerpc*-*-aix* || newlib } } */ #include #include "analyzer-decls.h"