From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by sourceware.org (Postfix) with ESMTPS id 64E313858D1E for ; Fri, 10 Nov 2023 20:43:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 64E313858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 64E313858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699649010; cv=none; b=Q826wGAh/6uQPmjiVSntZr13cYkMY4+rE2/vAM7toO+jnGlWwRvbDNvzZBbbK+uN/KrnqHTt7vyOjtpU1IGbIRj6Dva+6tCgXERO+3akC/aio6emQy+bSPZ0aNxp+IIVKYVJxWISzc7dxRYaPVIHOX6LUO9Jf4hbspsB+Lz+Bq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699649010; c=relaxed/simple; bh=0rmeiHUxBSMNdJoP5WNGgkhMls+j62xiJvZVcSgBvBg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=HxirOk06NbaSHyAuozB83Hl+VSgrBbQ9WjTqpOHbcnJXIg5F6YBPTskdj8Zbv2ohajkJ118pQNowDt9eszACvqEpAKdJb3iKUIwfEATW2RDC56A7lvhzu09L+2h4QamFXsn7uvjYxgVk40+dxzL6Vt601CshB+PDWH2MNbwsNXs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7a9857c14c5so85023239f.3 for ; Fri, 10 Nov 2023 12:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699649008; x=1700253808; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=tpkdyEG79aZ7+/lHK4p5AlAkWsAH9lCXyfDlvEf7WjE=; b=VVCIBpCUHZ1IZX0R0RVxoYzJ3xuCiaKAjHr4AVfRMIrPpTgL3Whb5iBt+BDRwtG1Ok TS+ZW+OjJ8eb0CUt6iNmP3BMEvEK491aJ0ijbYMQiqUPZ0f8SSySiLRNFzaqXmFerozS LUhMZEOUSIHn1/AbI/oqj2A4MFYEiBCWrZPhsJf/8S3LKZ77VtgJt9l+4IQ2zUwhzi35 JRKkNsKvO7N3a88ns1TmtNFugETED/3zSwJWX+mEacPar2Yb97gRXr0nsvDYvGjADbGp D5vsFoUkq59yc76cUgD8S5EJIxMo5NVok105a8YMwL4m03dDfdC8znVYQS7p0N+VJU+b 8U5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699649008; x=1700253808; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tpkdyEG79aZ7+/lHK4p5AlAkWsAH9lCXyfDlvEf7WjE=; b=oUaZywsvr6wLpj9CVgP4xwbF9UsQ8dqXVb7fTA7VVZI5kxGCorb0yetKtvCSxBC9JC b6PF+c6ErgnWLQhXNOXXXUQhLvN3QxgjBwpKnINmYD1pw7rQiMQZYfKNgdj2j9hh4qHf ydzCh6VvqbnjUpoAnvanQFQ4A1O/AzUZpWJMEs8ataZ441lvVyzoCdjQmJGs2AFniTqm ZPokEVKVBawYcUH6DWODDZLYTbXnzvca1c2/21bX4XihE+UcjonXJxFW3O6p2SOAEn6F LAEHR8z+DuJviKjjn9XIIDOITnCkvMy8WszAGFWGd06GaZlM75nmjO4Pol6/+rGS2lcS MinA== X-Gm-Message-State: AOJu0YxatIl2gwafnkME8ooSqBr2C3CR0Iab8svarG3xiSA/xWe9ieu6 3PIyYSQSbnnE66PD4yKq45A= X-Google-Smtp-Source: AGHT+IFNH6HmbzWQOGDrwxd7bfWq7xRdqML9Q1P1+MulJNqK6Jkt8KIg15L21YeCa4bM/MWXisEzDg== X-Received: by 2002:a05:6602:234e:b0:7a9:44af:ca5c with SMTP id r14-20020a056602234e00b007a944afca5cmr465941iot.12.1699649008561; Fri, 10 Nov 2023 12:43:28 -0800 (PST) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id b17-20020a05663801b100b004564b193674sm46324jaq.160.2023.11.10.12.43.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Nov 2023 12:43:28 -0800 (PST) Message-ID: <9b97edba-36b3-48b5-a5df-047b2ac41d2e@gmail.com> Date: Fri, 10 Nov 2023 13:43:27 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PING 2] [C PATCH] Synthesize nonnull attribute for parameters declared with static Content-Language: en-US To: Martin Uecker , gcc-patches@gcc.gnu.org Cc: Joseph Myers , jakub Jelinek References: <564177ba373bb73cfc2c2b106b7e57b4bcbc512e.camel@tugraz.at> From: Jeff Law In-Reply-To: <564177ba373bb73cfc2c2b106b7e57b4bcbc512e.camel@tugraz.at> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 10/21/23 05:09, Martin Uecker wrote: >> >> C programmers increasingly use static to indicate that >> pointer parameters are non-null. Clang can exploit this >> for warnings and optimizations. GCC has some warnings >> but not all warnings it has for nonnull. Below is a >> patch to add a nonnull attribute automatically for such >> arguments and to remove the special and more limited >> nonnull warnings for static. This patch found some >> misplaced annotationsĀ in one of my projects via >> -Wnonnull-compare which clang does not seem to have, >> so IĀ think this could be useful. > > c: Synthesize nonnull attribute for parameters declared with static [PR110815] > > Parameters declared with `static` are nonnull. We synthesize > an artifical nonnull attribute for such parameters to get the > same warnings and optimizations. > > Bootstrapped and regression tested on x86. > > PR c/102558 > PR 102556 > PR c/110815 > > gcc/c-family: > * c-attribs.cc (build_attr_access_from_parms): Synthesize > nonnull attribute for parameters declared with `static`. > > gcc: > * gimple-ssa-warn-access.cc (pass_waccess::maybe_check_access_sizes): > remove warning for parameters declared with `static`. > > gcc/testsuite: > * gcc.dg/Wnonnull-8.c: Adapt test. > * gcc.dg/Wnonnull-9.c: New test. This is OK -- assuming you did the usual bootstrap & regression test cycle. Jeff