From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 1558A3858C2F; Thu, 15 Jun 2023 07:21:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1558A3858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686813662; bh=1tNst8gsf267HRhjcY0/5BcqV6D9XLTMCp/sDkySGJ4=; h=From:To:Subject:Date:From; b=LrRhnOODpbH6wWXUs1Izy32b26tWal9XYcv66nFeOL67rzSCTfgAnq0k9vNe9zypw /DNMP7HseY7bNtVs2Z/WiqfhY4Py5/j2FsOOI7VE+9BCXf15rpcMeBY6HN/BJgAp2X 7AWQH2w2NxJylfXaFr5aIdVAxqUpVS9ykjpViAgs= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1838] Fix 'dg-warning' in 'c-c++-common/Wfree-nonheap-object-3.c' for C++ X-Act-Checkin: gcc X-Git-Author: Thomas Schwinge X-Git-Refname: refs/heads/master X-Git-Oldrev: 43a3252c42af12ad90082e4088ea58eecd0bf582 X-Git-Newrev: df071fbd467f0cb3711119ef41d74792fc5e6c8c Message-Id: <20230615072102.1558A3858C2F@sourceware.org> Date: Thu, 15 Jun 2023 07:21:02 +0000 (GMT) List-Id: https://gcc.gnu.org/g:df071fbd467f0cb3711119ef41d74792fc5e6c8c commit r14-1838-gdf071fbd467f0cb3711119ef41d74792fc5e6c8c Author: Thomas Schwinge Date: Wed Jun 7 17:12:01 2023 +0200 Fix 'dg-warning' in 'c-c++-common/Wfree-nonheap-object-3.c' for C++ [...]/c-c++-common/Wfree-nonheap-object-3.c:57:24: warning: 'malloc (dealloc_float)' attribute ignored with deallocation functions declared 'inline' [-Wattributes] [...]/c-c++-common/Wfree-nonheap-object-3.c:51:1: note: deallocation function declared here [...]/c-c++-common/Wfree-nonheap-object-3.c: In function 'void test_nowarn_int(int)': [...]/c-c++-common/Wfree-nonheap-object-3.c:25:20: warning: 'void __builtin_free(void*)' called on pointer 'p' with nonzero offset 4 [-Wfree-nonheap-object] [...]/c-c++-common/Wfree-nonheap-object-3.c:24:24: note: returned from 'int* alloc_int(int)' [...]/c-c++-common/Wfree-nonheap-object-3.c: In function 'void test_nowarn_long(int)': [...]/c-c++-common/Wfree-nonheap-object-3.c:45:18: warning: 'void dealloc_long(long int*)' called on pointer '' with nonzero offset 8 [-Wfree-nonheap-object] [...]/c-c++-common/Wfree-nonheap-object-3.c:44:26: note: returned from 'long int* alloc_long(int)' In function 'void dealloc_float(float*)', inlined from 'void test_nowarn_float(int)' at [...]/c-c++-common/Wfree-nonheap-object-3.c:68:19: [...]/c-c++-common/Wfree-nonheap-object-3.c:53:18: warning: 'void __builtin_free(void*)' called on pointer '' with nonzero offset 8 [-Wfree-nonheap-object] [...]/c-c++-common/Wfree-nonheap-object-3.c: In function 'void test_nowarn_float(int)': [...]/c-c++-common/Wfree-nonheap-object-3.c:67:28: note: returned from 'float* alloc_float(int)' PASS: c-c++-common/Wfree-nonheap-object-3.c -std=gnu++98 (test for warnings, line 25) FAIL: c-c++-common/Wfree-nonheap-object-3.c -std=gnu++98 (test for warnings, line 45) PASS: c-c++-common/Wfree-nonheap-object-3.c -std=gnu++98 (test for warnings, line 51) PASS: c-c++-common/Wfree-nonheap-object-3.c -std=gnu++98 (test for warnings, line 53) PASS: c-c++-common/Wfree-nonheap-object-3.c -std=gnu++98 (test for warnings, line 57) FAIL: c-c++-common/Wfree-nonheap-object-3.c -std=gnu++98 (test for excess errors) Excess errors: [...]/c-c++-common/Wfree-nonheap-object-3.c:45:18: warning: 'void dealloc_long(long int*)' called on pointer '' with nonzero offset 8 [-Wfree-nonheap-object] ..., that is: decorated 'void dealloc_long(long int*)' instead of plain 'dealloc_long' -- similar to how all the other 'dg-warning's allow for the decorated function signature in addition to the plain one. This issue was latent since the test case was added in commit fe7f75cf16783589eedbab597e6d0b8d35d7e470 "Correct/improve maybe_emit_free_warning (PR middle-end/98166, PR c++/57111, PR middle-end/98160)", and was finally exposed by my recent commit 9c03391ba447ff86038d6a34c90ae737c3915b5f "Tighten 'dg-warning' alternatives in 'c-c++-common/Wfree-nonheap-object{,-2,-3}.c'". gcc/testsuite/ * c-c++-common/Wfree-nonheap-object-3.c: Fix 'dg-warning' for C++. Diff: --- gcc/testsuite/c-c++-common/Wfree-nonheap-object-3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/c-c++-common/Wfree-nonheap-object-3.c b/gcc/testsuite/c-c++-common/Wfree-nonheap-object-3.c index 8f20de8455f..23d89a31454 100644 --- a/gcc/testsuite/c-c++-common/Wfree-nonheap-object-3.c +++ b/gcc/testsuite/c-c++-common/Wfree-nonheap-object-3.c @@ -42,7 +42,7 @@ void test_nowarn_long (int n) { long *p = alloc_long (n); - dealloc_long (p + 1); // { dg-warning "'dealloc_long' called on pointer '(p|)' with nonzero offset" } + dealloc_long (p + 1); // { dg-warning "'(dealloc_long|void dealloc_long\\(long int\\*\\))' called on pointer '(p|)' with nonzero offset" } } }