diff options
| author | H.J. Lu <hjl.tools@gmail.com> | 2025-10-26 08:42:20 +0800 |
|---|---|---|
| committer | H.J. Lu <hjl.tools@gmail.com> | 2025-10-28 06:46:35 +0800 |
| commit | dcf69bdcd49bccd901bfb01db7c15530e9a70dc0 (patch) | |
| tree | 3ce12375d22c293d289b06720f6e695abaae6fc8 /contrib/gcc-changelog/git_commit.py | |
| parent | 76943639ddd861dce3886d1def2a353ccfcdd585 (diff) | |
| download | gcc-dcf69bdcd49bccd901bfb01db7c15530e9a70dc0.zip gcc-dcf69bdcd49bccd901bfb01db7c15530e9a70dc0.tar.gz gcc-dcf69bdcd49bccd901bfb01db7c15530e9a70dc0.tar.bz2 | |
c: Try the type with the previous function attributes
When there are 2 conflicting function declarations, try the new type
with the previous TYPE_ATTRIBUTES if the current declaration has no
TYPE_ATTRIBUTES to support
extern void foo (void) __attribute__((nocf_check));
void
foo (void)
{
}
instead of issuing an error:
$ gcc -O2 -fcf-protection -S x.c
x.c:4:1: error: conflicting types for ‘foo’; have ‘void(void)’
4 | foo (void)
| ^~~
x.c:1:13: note: previous declaration of ‘foo’ with type ‘void(void)’
1 | extern void foo (void) __attribute__((nocf_check));
| ^~~
The resulting function definition is compatible with the previous
declaration.
gcc/c/
PR c/122427
* c-decl.cc (diagnose_mismatched_decls): For FUNCTION_DECL, if
OLDDECL has TYPE_ATTRIBUTES and NEWDECL doesn't, try the type
with the OLDDECL attributes.
gcc/testsuite/
PR c/122427
* g++.target/i386/cf_check-1.C: New test.
* g++.target/i386/cf_check-2.C: Likewise.
* g++.target/i386/cf_check-3.C: Likewise.
* g++.target/i386/cf_check-4.C: Likewise.
* gcc.target/i386/cf_check-7.c: Likewise.
* gcc.target/i386/cf_check-8.c: Likewise.
* gcc.target/i386/cf_check-9.c: Likewise.
* gcc.target/i386/cf_check-10.c: Likewise.
* gcc.target/i386/cf_check-11.c: Likewise.
* gcc.target/i386/no-callee-saved-12.c: Remove dg-error.
* gcc.target/i386/preserve-none-17.c: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Diffstat (limited to 'contrib/gcc-changelog/git_commit.py')
0 files changed, 0 insertions, 0 deletions
