From df071fbd467f0cb3711119ef41d74792fc5e6c8c Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 7 Jun 2023 17:12:01 +0200 Subject: 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++. --- 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 8f20de8..23d89a3 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" } } } -- cgit v1.1