From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31209 invoked by alias); 16 Dec 2014 17:00:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 31184 invoked by uid 55); 16 Dec 2014 16:59:56 -0000 From: "a3at.mail at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/64332] gcc/g++ handles system_header differently Date: Tue, 16 Dec 2014 17:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: a3at.mail at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-12/txt/msg01910.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D64332 --- Comment #3 from Azat --- On Tue, Dec 16, 2014 at 07:50:48PM +0300, Azat Khuzhin wrote: > > --- Comment #1 from Andrew Pinski --- > > I don't think it is system header which is being handled differently, r= ather I > > think it is warning for attribute is being handled differently. >=20 > Maybe... I didn't check this. I've checked this and you are right: $ head main.c c-impl.h # the same is in attach =3D=3D> main.c <=3D=3D #include "c-impl.h" =3D=3D> c-impl.h <=3D=3D #pragma GCC system_header static inline int foo(int foo) { } $ gcc -Wall -Wextra -Wpedantic -Wattributes -c main.c $ g++ -Wall -Wextra -Wpedantic -Wattributes -c main.c Now drop system_header: $ head main.c c-impl.h=20 =3D=3D> main.c <=3D=3D #include "c-impl.h" =3D=3D> c-impl.h <=3D=3D static inline int foo(int foo) { } $ gcc -Wall -Wextra -Wpedantic -Wattributes -c main.c In file included from main.c:1:0: c-impl.h: In function =E2=80=98foo=E2=80=99: c-impl.h:3:1: warning: no return statement in function returning non-void [-Wreturn-type] } ^ c-impl.h:1:27: warning: unused parameter =E2=80=98foo=E2=80=99 [-Wunused-pa= rameter] static inline int foo(int foo) ^ $ g++ -Wall -Wextra -Wpedantic -Wattributes -c main.c In file included from main.c:1:0: c-impl.h: In function =E2=80=98int foo(int)=E2=80=99: c-impl.h:3:1: warning: no return statement in function returning non-void [-Wreturn-type] } ^ c-impl.h: At global scope: c-impl.h:1:27: warning: unused parameter =E2=80=98foo=E2=80=99 [-Wunused-pa= rameter] static inline int foo(int foo) ^ >>From gcc-bugs-return-470904-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Dec 16 17:16:46 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 8323 invoked by alias); 16 Dec 2014 17:16:46 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 8301 invoked by uid 48); 16 Dec 2014 17:16:41 -0000 From: "manu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/64332] wrong location for Wattributes warning Date: Tue, 16 Dec 2014 17:16:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.9.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: manu at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords bug_status cf_reconfirmed_on cc component short_desc everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-12/txt/msg01911.txt.bz2 Content-length: 2084 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D64332 Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Status|UNCONFIRMED |NEW Last reconfirmed| |2014-12-16 CC| |manu at gcc dot gnu.org Component|c++ |c Summary|gcc/g++ handles |wrong location for |system_header differently |Wattributes warning Ever confirmed|0 |1 --- Comment #4 from Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez --- The difference that you see is because of macro expansion and bad location = info in the C FE. This testcase makes it clear: $ cat test.c #define __constructor __attribute__((constructor)) typedef void (*__cb_type)(void *); int foo(__cb_type __constructor); $ cc1 -Wattributes test.c test.c:3:1: warning: =E2=80=98constructor=E2=80=99 attribute ignored [-Watt= ributes] int foo(__cb_type __constructor); ^ $ cc1plus -Wattributes test.c test.c:1:50: warning: =E2=80=98constructor=E2=80=99 attribute ignored [-Wat= tributes] #define __constructor __attribute__((constructor)) ^ test.c:3:19: note: in expansion of macro =E2=80=98__constructor=E2=80=99 int foo(__cb_type __constructor); ^ The C FE does not point to __constructor (3:1 vs 3:19), thus it doesn't rea= lize this comes from a macro expansion, thus (in your testcase) the system_heade= r is applied. The C++ FE sees that the attribute actually appears in 1:50 and not 3:19, thus in your testcase the pragma system_header does not apply. Whether the correct behavior is that the system_header applies to the definition or to the expansion location, I am not sure. However, the bad location of the C FE is clearly a bug. >>From gcc-bugs-return-470905-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Dec 16 17:20:45 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 12389 invoked by alias); 16 Dec 2014 17:20:45 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 12194 invoked by uid 55); 16 Dec 2014 17:20:38 -0000 From: "a3at.mail at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/64332] wrong location for Wattributes warning Date: Tue, 16 Dec 2014 17:20:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.9.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: a3at.mail at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-12/txt/msg01912.txt.bz2 Content-length: 783 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64332 --- Comment #5 from Azat --- On Tue, Dec 16, 2014 at 05:16:41PM +0000, manu at gcc dot gnu.org wrote: > The C FE does not point to __constructor (3:1 vs 3:19), thus it doesn't realize > this comes from a macro expansion, thus (in your testcase) the system_header is > applied. The C++ FE sees that the attribute actually appears in 1:50 and not > 3:19, thus in your testcase the pragma system_header does not apply. Hm.. good to know, thanks for pointing me out! > Whether the correct behavior is that the system_header applies to the > definition or to the expansion location, I am not sure. However, the bad > location of the C FE is clearly a bug. Maybe gcc will behave like clang in this case?