This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, Jonathan Wakely <jwakely at redhat dot com>
- Date: Fri, 19 Feb 2016 12:59:45 +0100
- Subject: Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
- Authentication-results: sourceware.org; auth=none
- References: <HE1PR07MB090548A2180950184AF65A60E4A00 at HE1PR07MB0905 dot eurprd07 dot prod dot outlook dot com> <20160219105612 dot GA3017 at tucnak dot redhat dot com> <HE1PR07MB09054F1EE94A5C0E57E41AAEE4A00 at HE1PR07MB0905 dot eurprd07 dot prod dot outlook dot com> <20160219113126 dot GB3017 at tucnak dot redhat dot com> <HE1PR07MB09050AD7717125F4428FF773E4A00 at HE1PR07MB0905 dot eurprd07 dot prod dot outlook dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Feb 19, 2016 at 11:53:03AM +0000, Bernd Edlinger wrote:
> > #ifdef __GNUC__
> > __inline
> > -#ifdef __GNUC_STDC_INLINE__
> > +#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
> > __attribute__ ((__gnu_inline__))
> > #endif
> > #endif
> >
> > Jakub
>
> Damnit!!
>
> I dont know how this file is ever supposed to compile on a C99 compiler.
> but with this change it does not even compile with -std=c90 any more:
>
> cat test.c
> #include "cfns.h"
>
> gcc -std=c90 test.c
> In file included from test.c:1:0:
> cfns.gperf:101:1: error: 'gnu_inline' attribute present on 'libc_name_p'
> cfns.gperf:26:14: error: but not here
>
> gcc -std=c99 test.c
> In file included from test.c:1:0:
> cfns.gperf:101:1: error: 'gnu_inline' attribute present on 'libc_name_p'
> cfns.gperf:26:14: error: but not here
> cfns.gperf: In function 'libc_name_p':
> cfns.gperf:328:34: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]
>
>
> So this leaves only one solution, to define neither __GNUC_STDC_INLINE__
Of course not, and that would be the wrong thing to do.
The definition spot of libc_name_p comes from gperf itself, the prototype
from cfns.gperf, which we can of course adjust.
> nor __GNUC_GNU_INLINE__ for C++, at least the inline and gnu_inline
> is completely different on C and C++. But I am anxious this will break more
> things than gperf, and I would like to fix this in a safe way.
IMNSHO we should just keep it consistent with what g++ e.g. 5.x did.
Thus,
$ g++ -E -dD -xc++ /dev/null -O2 -std=c++98 2>&1 | grep _INLINE_
#define __GNUC_GNU_INLINE__ 1
$ g++ -E -dD -xc++ /dev/null -O2 -std=c++11 2>&1 | grep _INLINE_
#define __GNUC_STDC_INLINE__ 1
$ g++ -E -dD -xc++ /dev/null -O2 -std=c++14 2>&1 | grep _INLINE_
#define __GNUC_STDC_INLINE__ 1
$ g++ -E -dD -xc++ /dev/null -O2 -std=gnu++98 2>&1 | grep _INLINE_
#define __GNUC_GNU_INLINE__ 1
$ g++ -E -dD -xc++ /dev/null -O2 -std=gnu++11 2>&1 | grep _INLINE_
#define __GNUC_STDC_INLINE__ 1
$ g++ -E -dD -xc++ /dev/null -O2 -std=gnu++14 2>&1 | grep _INLINE_
#define __GNUC_STDC_INLINE__ 1
$ g++ -E -dD -xc++ /dev/null -O2 2>&1 | grep _INLINE_
#define __GNUC_GNU_INLINE__ 1
We want to define what we did with the explicit -std= options, and just
change the output in the default case (last invocation), to
#define __GNUC_STDC_INLINE__ 1
because the default is different.
Jakub