Detect conflicts between incompatible uses of the same attribute (PR c/78666).
authorMartin Sebor <msebor@redhat.com>
Wed, 16 Sep 2020 20:04:01 +0000 (14:04 -0600)
committerMartin Sebor <msebor@redhat.com>
Wed, 16 Sep 2020 20:04:01 +0000 (14:04 -0600)
commit71ad0b5dde449ee1f6b755a99f5c52152e375835
treed8aacb3f5738c5779118020e1777dae5e2e45bcd
parent31dd5cd6344bfbbe122fb512993b128e11236d35
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/c-family/c-attribs.c
gcc/testsuite/c-c++-common/builtin-has-attribute-3.c
gcc/testsuite/gcc.dg/attr-alloc_align-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-alloc_size-13.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-section.c [new file with mode: 0644]