From 71ad0b5dde449ee1f6b755a99f5c52152e375835 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Wed, 16 Sep 2020 14:04:01 -0600 Subject: Detect conflicts between incompatible uses of the same attribute (PR c/78666). Resolves: PR c/78666 - conflicting attribute alloc_size accepted PR c/96126 - conflicting attribute section accepted on redeclaration gcc/c-family/ChangeLog: PR c/78666 PR c/96126 * c-attribs.c (validate_attr_args): New function. (validate_attr_arg): Same. (handle_section_attribute): Call it. Introduce a local variable. (handle_alloc_size_attribute): Same. (handle_alloc_align_attribute): Same. gcc/testsuite/ChangeLog: PR c/78666 PR c/96126 * gcc.dg/attr-alloc_align-5.c: New test. * gcc.dg/attr-alloc_size-13.c: New test. * gcc.dg/attr-section.c: New test. * c-c++-common/builtin-has-attribute-3.c: Add xfails due to expected warnings to be cleaned up. --- gcc/testsuite/c-c++-common/builtin-has-attribute-3.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'gcc/testsuite/c-c++-common/builtin-has-attribute-3.c') diff --git a/gcc/testsuite/c-c++-common/builtin-has-attribute-3.c b/gcc/testsuite/c-c++-common/builtin-has-attribute-3.c index 2a59501..5736bab 100644 --- a/gcc/testsuite/c-c++-common/builtin-has-attribute-3.c +++ b/gcc/testsuite/c-c++-common/builtin-has-attribute-3.c @@ -75,7 +75,7 @@ void test_alloc_align (void) A (0, fnone, alloc_align (1)); /* { dg-warning "\\\[-Wattributes" } */ A (0, falloc_size_1, alloc_align (1)); A (1, falloc_align_1, alloc_align (1)); - A (0, falloc_align_2, alloc_align (1)); + A (0, falloc_align_2, alloc_align (1)); /* { dg-bogus "\\\[-Wattributes" "pr?????" { xfail *-*-* } }" */ A (1, falloc_align_2, alloc_align (2)); } @@ -88,26 +88,26 @@ void test_alloc_size_malloc (void) A (0, falloc_align_1, alloc_size (1)); A (0, falloc_align_2, alloc_size (1)); A (1, falloc_size_1, alloc_size (1)); - A (0, falloc_size_1, alloc_size (2)); - A (0, falloc_size_2, alloc_size (1)); + A (0, falloc_size_1, alloc_size (2)); /* { dg-bogus "\\\[-Wattributes" "pr?????" { xfail *-*-* } }" */ + A (0, falloc_size_2, alloc_size (1)); /* { dg-bogus "\\\[-Wattributes" "pr?????" { xfail *-*-* } }" */ A (1, falloc_size_2, alloc_size (2)); A (1, falloc_size_2_4, alloc_size); /* It would probably make more sense to have the built-in return true only when both alloc_size arguments match, not just one or the other. */ - A (0, falloc_size_2_4, alloc_size (1)); - A (1, falloc_size_2_4, alloc_size (2)); - A (0, falloc_size_2_4, alloc_size (3)); - A (1, falloc_size_2_4, alloc_size (4)); + A (0, falloc_size_2_4, alloc_size (1)); /* { dg-bogus "\\\[-Wattributes" "pr?????" { xfail *-*-* } }" */ + A (1, falloc_size_2_4, alloc_size (2)); /* { dg-bogus "\\\[-Wattributes" "pr?????" { xfail *-*-* } }" */ + A (0, falloc_size_2_4, alloc_size (3)); /* { dg-bogus "\\\[-Wattributes" "pr?????" { xfail *-*-* } }" */ + A (1, falloc_size_2_4, alloc_size (4)); /* { dg-bogus "\\\[-Wattributes" "pr?????" { xfail *-*-* } }" */ A (1, falloc_size_2_4, alloc_size (2, 4)); extern ATTR (alloc_size (3)) void* fmalloc_size_3 (int, int, int); A (1, fmalloc_size_3, alloc_size); - A (0, fmalloc_size_3, alloc_size (1)); - A (0, fmalloc_size_3, alloc_size (2)); + A (0, fmalloc_size_3, alloc_size (1)); /* { dg-bogus "\\\[-Wattributes" "pr?????" { xfail *-*-* } }" */ + A (0, fmalloc_size_3, alloc_size (2)); /* { dg-bogus "\\\[-Wattributes" "pr?????" { xfail *-*-* } }" */ A (1, fmalloc_size_3, alloc_size (3)); A (0, fmalloc_size_3, malloc); -- cgit v1.1