Bug 71024 - Missing warning for contradictory attributes
Summary: Missing warning for contradictory attributes
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: 7.0
Assignee: Marek Polacek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-09 13:58 UTC by Marek Polacek
Modified: 2016-05-11 17:11 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-05-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Polacek 2016-05-09 13:58:28 UTC
Observe that on 

void __attribute ((always_inline)) foo (void);
void __attribute ((noinline)) foo (void);

$ ./cc1 -quiet q.cc 
q.cc:2:31: warning: declaration of ‘foo’ with attribute ‘noinline’ follows declaration with attribute ‘always_inline’ [-Wattributes]
 void __attribute ((noinline)) foo (void);
                               ^~~
q.cc:1:36: note: previous declaration of ‘foo’ was here
 void __attribute ((always_inline)) foo (void);
                                    ^~~
but cc1plus is silent.  I think we need to factor out some code out of diagnose_mismatched_decls.
Comment 1 Marek Polacek 2016-05-11 13:01:19 UTC
Testing a patch.
Comment 2 Marek Polacek 2016-05-11 17:08:09 UTC
Author: mpolacek
Date: Wed May 11 17:07:37 2016
New Revision: 236129

URL: https://gcc.gnu.org/viewcvs?rev=236129&root=gcc&view=rev
Log:
	PR c++/71024
	* c-common.c (diagnose_mismatched_attributes): New function.
	* c-common.h (diagnose_mismatched_attributes): Declare.

	* c-decl.c (diagnose_mismatched_decls): Factor out code to
	diagnose_mismatched_attributes and call it.

	* decl.c (duplicate_decls): Call diagnose_mismatched_decls.

	* c-c++-common/attributes-3.c: New test.

Added:
    trunk/gcc/testsuite/c-c++-common/attributes-3.c
Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/c-family/c-common.h
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Marek Polacek 2016-05-11 17:11:19 UTC
Fixed.