From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 986FC385828A for ; Sun, 19 Nov 2023 07:36:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 986FC385828A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 986FC385828A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700379395; cv=none; b=GAuHfileF/EmiZpTLVynILOZrWCG/MAPmZS+lpZUI83QPgp/c4j0TEInL10PY7D/QFaE6+vb3lrjtPsm+L52ESxgbXAaBkG/5tclr7j7lYXuhzYm5z+Pceu/yr0/MscyylSghUm76GqusyFLO4CIpzyd58Nxv7jj+zw37u24Xvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700379395; c=relaxed/simple; bh=ldqPst9PCZlmiaSlRQm3IsHfk4r0oj2cmftffQewqkI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=B0fxE9qlm3t/b31nGn0S4XOxBFEGQXgA4H9Xtn28eF4oK9xNZQmr1c+eDxndyfjXXYOtqCrVeRvgHGH2k0rkRqtoUbyxi7yj+3JOB93ZPlRBFu7YAgcUhLYvqm1Z/F3SsCGTX2BHYchdA/xnwRwF2K7snBwTg6x+537fauFV3oE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6bd0e1b1890so2739619b3a.3 for ; Sat, 18 Nov 2023 23:36:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1700379392; x=1700984192; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=6odN22/JdEiJcoxjK+dK6cvEZnI/HS9cQq4RKBZJ9Vo=; b=i/booOMUj6JcUFJPwQKSs/cShN6qmqz9Trc1T0N1piCXeYxMppm0iclgWPdQf3SNvG z0jp85r8CunxsJV5yS/VXMo6y/4AJ4/RTergoTnW8sZIis4tI7lNkjgqg1TPzeCiATmN 6n2uixYm7J1LYayz4rpDhsQsw6DZMQQ1OpjbTsvMcXZuw1W9b55IQXAx8AMiux2akpLZ 9nObOUHBiZjXXgy99j88GGxrPTtYCUqyuoI15MVfJT3RXkXaz9hL2DdkU9OONobVPt2L DobWArjwj4WH7tPO6BxIm9Azfju/EtL+DKhj+G6wfXpoDZJD/40SPRexx2gLkniWaBaY e2cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700379392; x=1700984192; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6odN22/JdEiJcoxjK+dK6cvEZnI/HS9cQq4RKBZJ9Vo=; b=K1O76+7t81PI/o2+4a4JuaFSCiYkSrCORB5dqFQixcOspzvWsf6KweNPyAaZCZlgfF dXTbKROe07BoOe22QaixpVIsyvoFCqtPCzrXPQ4z4+0NakSb8XpXM/oqJQiozpAKfnwF xs0Vg7T2F8WbddS8SfE/CCYbyfLzfKEdl7mjbV1aNM+AtWMfGUoJgGm74jn6b1JUxmm7 9lwKrO9zAQ7TTgi/Lut9PtBs+qi+D0MRt6cRl5il8eqBiEp9778q9GwtV/Td4ExrW4rz 7HeIN5WANNn5l51/kFHQON9oqeTReK59P7PF1VLAniroiA9UjAnqtz+W1R/WD5SsJS9a weQw== X-Gm-Message-State: AOJu0YyXZqxTo2xFBZ8VtMkWbnb4Mh2R9Mb1YsQQQEH62tfF1TwHWZ6K P5MCI+8QOoy0B1+ECWHKnbw3nUVePPXTpdIy09d5Pg== X-Google-Smtp-Source: AGHT+IGed2br+iJMiFny4H697Ogp+PqaDC2HQV6KhefIbAEcny4vsSD0tRpA6Y8Ai3P2SaIhNrnxZw== X-Received: by 2002:a05:6a00:1a88:b0:6b8:780:94e5 with SMTP id e8-20020a056a001a8800b006b8078094e5mr2907889pfv.18.1700379392305; Sat, 18 Nov 2023 23:36:32 -0800 (PST) Received: from free.home ([2804:7f1:2080:51b3:d545:cbee:40c0:c7a7]) by smtp.gmail.com with ESMTPSA id f18-20020aa78b12000000b006b58af8aae3sm3960908pfd.77.2023.11.18.23.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 23:36:31 -0800 (PST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 3AJ7aNiX121864 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 19 Nov 2023 04:36:23 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Cc: David Malcolm , Rainer Orth , Mike Stump , Jason Merrill , Nathan Sidwell Subject: [PATCH] testsuite: analyzer: expect alignment warning with -fshort-enums Organization: Free thinker, does not speak for AdaCore Date: Sun, 19 Nov 2023 04:36:23 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On targets that have -fshort-enums enabled by default, the type casts in the pr108251 analyzer tests warn that the byte-aligned enums may not be sufficiently aligned to be a struct connection *. The function can't know better, the warning is reasonable, the code doesn't expected enums to be shorter and less aligned than the struct. Rather than use -fno-short-enums, I decided to embrace the warning on targets that have short_enums enabled by default. However, C++ doesn't issue the warning, because even with -fshort-enums, enumeration types are not TYPE_PACKED, and the expression is not sufficiently simplified by the C++ front-end for check_and_warn_address_or_pointer_of_packed_member to identify the insufficiently aligned pointer. So don't expect the warning there. (I've got followup patches in testing to get the same warnings in C++) Regstrapped on x86_64-linux-gnu, also tested on arm-eabi with default cpu on trunk, and with tms570 on gcc-13. Ok to install? for gcc/testsuite/ChangeLog * c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c: Expect "unaligned pointer value" warning on short_enums targets, but not in c++. * c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c: Likewise. --- ...-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c | 2 +- ...ull-deref-pr108251-smp_fetch_ssl_fc_has_early.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c index c46ffe91a6b46..aaa2031b6dca4 100644 --- a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c +++ b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c @@ -61,7 +61,7 @@ static inline enum obj_type obj_type(const enum obj_type *t) } static inline struct connection *__objt_conn(enum obj_type *t) { - return ((struct connection *)(((char *)(t)) - ((long)&((struct connection *)0)->obj_type))); + return ((struct connection *)(((char *)(t)) - ((long)&((struct connection *)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target { short_enums && { ! c++ } } } } */ } static inline struct connection *objt_conn(enum obj_type *t) { diff --git a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c index ef34a76c50d63..6c96f5a76ef1c 100644 --- a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c +++ b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c @@ -60,7 +60,7 @@ static inline enum obj_type obj_type(const enum obj_type *t) } static inline struct connection *__objt_conn(enum obj_type *t) { - return ((struct connection *)(((char *)(t)) - ((long)&((struct connection *)0)->obj_type))); + return ((struct connection *)(((char *)(t)) - ((long)&((struct connection *)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target { short_enums && { ! c++ } } } } */ } static inline struct connection *objt_conn(enum obj_type *t) { -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer More tolerance and less prejudice are key for inclusion and diversity Excluding neuro-others for not behaving ""normal"" is *not* inclusive