public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
@ 2016-02-19 10:50 Bernd Edlinger
  2016-02-19 10:56 ` Jakub Jelinek
  0 siblings, 1 reply; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 10:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill, Jonathan Wakely, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 1518 bytes --]


Hi,

as described in the PR 69865, some bits are not properly initialized when the -std=gnu++14
option is not present on the command line.  That includes the options -trigraphs and
-fno-extended-identifiers which are effectively overridden by the default handling.
Also the define __GNUC_GNU_INLINE__ vs. __GNUC_STDC_INLINE__ is differently
defined if -std=gnu++14 is given on the command line than when the default takes effect,
which is also supposed to be gnu++14 too.

While I think that we should probably not define __GNUC_GNU_INLINE__ at all for C++,
because it is meaningless, I am warned that this could break (already broken) header files.
I think the safest thing would be to unconditionally define __GNUC_GNU_INLINE__ for C++
and not use flag_isoc99 for that decision which is true for c++11 and above, but was undefined
previously when the -std option was not used on the command line.

Unfortunately this specific bug, cannot be tested in the test suite, especially the -trigraphs
have already test cases under c-c++common, which should have been failing all the time,
but, unfortunately the test suite always adds -std=xxx for c++ tests.  So I would like to make
an exception here to the general rule that every patch has to add a test case of its own.

I would like this patch to be considered for gcc-6 because the undefined state of the predefined
GNUC-define worries me a bit.


Boot-strapped and regression tested on x86_64-pc-linux-gnu.
OK for trunk?


Thanks
Bernd.

[-- Attachment #2: changelog-pr69865.txt --]
[-- Type: text/plain, Size: 276 bytes --]

2016-02-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR c++/69865
	* c-opts.c (c_common_post_options): Set flag_gnu89_inline for C++.
	Move call to set_std_cxx14 from here...
	(c_common_init_options): ...to here.
	(set_std_cxx98): Initialize flag_isoc94 and flag_isoc99.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: patch-pr69865.diff --]
[-- Type: text/x-patch; name="patch-pr69865.diff", Size: 1622 bytes --]

Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c	(revision 233531)
+++ gcc/c-family/c-opts.c	(working copy)
@@ -246,6 +246,10 @@ c_common_init_options (unsigned int decoded_option
 	  }
     }
 
+  /* Set C++ standard to C++14 if not specified on the command line.  */
+  if (c_dialect_cxx ())
+    set_std_cxx14 (/*ISO*/false);
+
   global_dc->colorize_source_p = true;
 }
 
@@ -786,7 +790,7 @@ c_common_post_options (const char **pfilename)
   /* By default we use C99 inline semantics in GNU99 or C99 mode.  C99
      inline semantics are not supported in GNU89 or C89 mode.  */
   if (flag_gnu89_inline == -1)
-    flag_gnu89_inline = !flag_isoc99;
+    flag_gnu89_inline = c_dialect_cxx () || !flag_isoc99;
   else if (!flag_gnu89_inline && !flag_isoc99)
     error ("-fno-gnu89-inline is only supported in GNU99 or C99 mode");
 
@@ -802,10 +806,6 @@ c_common_post_options (const char **pfilename)
       && flag_no_builtin)
     flag_tree_loop_distribute_patterns = 0;
 
-  /* Set C++ standard to C++14 if not specified on the command line.  */
-  if (c_dialect_cxx () && cxx_dialect == cxx_unset)
-    set_std_cxx14 (/*ISO*/false);
-
   /* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
      It is never enabled in C++, as the minimum limit is not normative
      in that standard.  */
@@ -1519,6 +1519,8 @@ set_std_cxx98 (int iso)
   flag_no_gnu_keywords = iso;
   flag_no_nonansi_builtin = iso;
   flag_iso = iso;
+  flag_isoc94 = 0;
+  flag_isoc99 = 0;
   cxx_dialect = cxx98;
   lang_hooks.name = "GNU C++98";
 }

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 10:50 [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865) Bernd Edlinger
@ 2016-02-19 10:56 ` Jakub Jelinek
  2016-02-19 11:09   ` Bernd Edlinger
  0 siblings, 1 reply; 24+ messages in thread
From: Jakub Jelinek @ 2016-02-19 10:56 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

On Fri, Feb 19, 2016 at 10:50:34AM +0000, Bernd Edlinger wrote:
> While I think that we should probably not define __GNUC_GNU_INLINE__ at all for C++,
> because it is meaningless, I am warned that this could break (already broken) header files.

It is not meaningless.  The various headers need to know if it is safe to
use the gnu_inline attribute in C++.

In any case, the desirable state is that e.g. the -E -dD output should be
identical if you explicitly request the default -std= version vs. if it is
set implicitly.  We should verify it is the case even for C.

	Jakub

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 10:56 ` Jakub Jelinek
@ 2016-02-19 11:09   ` Bernd Edlinger
  2016-02-19 11:31     ` Jakub Jelinek
  0 siblings, 1 reply; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 11:09 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

On 19.02.2016 11:56, Jakub Jelinek wrote:
>
> On Fri, Feb 19, 2016 at 10:50:34AM +0000, Bernd Edlinger wrote:
> > While I think that we should probably not define __GNUC_GNU_INLINE__ at all for C++,
> > because it is meaningless, I am warned that this could break (already broken) header files.
> 
> It is not meaningless.  The various headers need to know if it is safe to
> use the gnu_inline attribute in C++.
> 
> In any case, the desirable state is that e.g. the -E -dD output should be
> identical if you explicitly request the default -std= version vs. if it is
> set implicitly.  We should verify it is the case even for C.
> 
>         Jakub

I absolutely agree with you.
The correct solution is probably doing this:

--- gcc/cp/cfns.h.jj	2016-01-04 15:30:50.000000000 +0100
+++ gcc/cp/cfns.h	2016-02-19 12:00:15.730375049 +0100
@@ -124,9 +124,6 @@
 
 #ifdef __GNUC__
 __inline
-#ifdef __GNUC_STDC_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
 #endif
 const char *
 libc_name_p (register const char *str, register unsigned int len)

and remove this hunk instead:

@@ -786,7 +790,7 @@ c_common_post_options (const char **pfilename)
   /* By default we use C99 inline semantics in GNU99 or C99 mode.  C99
      inline semantics are not supported in GNU89 or C89 mode.  */
   if (flag_gnu89_inline == -1)
-    flag_gnu89_inline = !flag_isoc99;
+    flag_gnu89_inline = c_dialect_cxx () || !flag_isoc99;
   else if (!flag_gnu89_inline && !flag_isoc99)
     error ("-fno-gnu89-inline is only supported in GNU99 or C99 mode");


Would you like that better?


Thanks
Bernd.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 11:09   ` Bernd Edlinger
@ 2016-02-19 11:31     ` Jakub Jelinek
  2016-02-19 11:53       ` Bernd Edlinger
  0 siblings, 1 reply; 24+ messages in thread
From: Jakub Jelinek @ 2016-02-19 11:31 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

On Fri, Feb 19, 2016 at 11:08:48AM +0000, Bernd Edlinger wrote:
> On 19.02.2016 11:56, Jakub Jelinek wrote:
> >
> > On Fri, Feb 19, 2016 at 10:50:34AM +0000, Bernd Edlinger wrote:
> > > While I think that we should probably not define __GNUC_GNU_INLINE__ at all for C++,
> > > because it is meaningless, I am warned that this could break (already broken) header files.
> > 
> > It is not meaningless.  The various headers need to know if it is safe to
> > use the gnu_inline attribute in C++.
> > 
> > In any case, the desirable state is that e.g. the -E -dD output should be
> > identical if you explicitly request the default -std= version vs. if it is
> > set implicitly.  We should verify it is the case even for C.
> > 
> >         Jakub
> 
> I absolutely agree with you.
> The correct solution is probably doing this:
> 
> --- gcc/cp/cfns.h.jj	2016-01-04 15:30:50.000000000 +0100
> +++ gcc/cp/cfns.h	2016-02-19 12:00:15.730375049 +0100
> @@ -124,9 +124,6 @@
>  
>  #ifdef __GNUC__
>  __inline
> -#ifdef __GNUC_STDC_INLINE__
> -__attribute__ ((__gnu_inline__))
> -#endif
>  #endif
>  const char *
>  libc_name_p (register const char *str, register unsigned int len)

This is of course wrong.  cfns.h is a generated header, so you shouldn't
patch it.
If it is regenerated with a newer gperf (I have 3.0.4 installed), you get there:
@@ -124,7 +124,7 @@ hash (register const char *str, register
 
 #ifdef __GNUC__
 __inline
-#ifdef __GNUC_STDC_INLINE__
+#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
 __attribute__ ((__gnu_inline__))
 #endif
 #endif

	Jakub

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 11:31     ` Jakub Jelinek
@ 2016-02-19 11:53       ` Bernd Edlinger
  2016-02-19 11:59         ` Jakub Jelinek
  0 siblings, 1 reply; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 11:53 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

On 19.02.2016 12:31, Jakub Jelinek wrote:
> On Fri, Feb 19, 2016 at 11:08:48AM +0000, Bernd Edlinger wrote:
> > On 19.02.2016 11:56, Jakub Jelinek wrote:
> > >
> > > On Fri, Feb 19, 2016 at 10:50:34AM +0000, Bernd Edlinger wrote:
> > > > While I think that we should probably not define __GNUC_GNU_INLINE__ at all for C++,
> > > > because it is meaningless, I am warned that this could break (already broken) header files.
> > >
> > > It is not meaningless.  The various headers need to know if it is safe to
> > > use the gnu_inline attribute in C++.
> > >
> > > In any case, the desirable state is that e.g. the -E -dD output should be
> > > identical if you explicitly request the default -std= version vs. if it is
> > > set implicitly.  We should verify it is the case even for C.
> > >
> > >         Jakub
> >
> > I absolutely agree with you.
> > The correct solution is probably doing this:
> >
> > --- gcc/cp/cfns.h.jj  2016-01-04 15:30:50.000000000 +0100
> > +++ gcc/cp/cfns.h     2016-02-19 12:00:15.730375049 +0100
> > @@ -124,9 +124,6 @@
> >
> >  #ifdef __GNUC__
> >  __inline
> > -#ifdef __GNUC_STDC_INLINE__
> > -__attribute__ ((__gnu_inline__))
> > -#endif
> >  #endif
> >  const char *
> >  libc_name_p (register const char *str, register unsigned int len)
> 
> This is of course wrong.  cfns.h is a generated header, so you shouldn't
> patch it.
> If it is regenerated with a newer gperf (I have 3.0.4 installed), you get there:
> @@ -124,7 +124,7 @@ hash (register const char *str, register
> 
>  #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__
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.


Bernd.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 11:53       ` Bernd Edlinger
@ 2016-02-19 11:59         ` Jakub Jelinek
  2016-02-19 12:10           ` Bernd Edlinger
  2016-02-19 12:22           ` Jakub Jelinek
  0 siblings, 2 replies; 24+ messages in thread
From: Jakub Jelinek @ 2016-02-19 11:59 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 11:59         ` Jakub Jelinek
@ 2016-02-19 12:10           ` Bernd Edlinger
  2016-02-19 12:22           ` Jakub Jelinek
  1 sibling, 0 replies; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 12:10 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

On 19.02.2016 12:59, Jakub Jelinek wrote:
> 
> 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.
>

Yes, now I understand.  Thanks.
 
>
> 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

OK. I can do that.
I will send a new patch in the evening.


Thanks
Bernd.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 11:59         ` Jakub Jelinek
  2016-02-19 12:10           ` Bernd Edlinger
@ 2016-02-19 12:22           ` Jakub Jelinek
  2016-02-19 12:26             ` Jakub Jelinek
  2016-02-19 13:07             ` Bernd Edlinger
  1 sibling, 2 replies; 24+ messages in thread
From: Jakub Jelinek @ 2016-02-19 12:22 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

Hi!

On Fri, Feb 19, 2016 at 12:59:45PM +0100, Jakub Jelinek wrote:
> 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.

This is related to
https://gcc.gnu.org/ml/gcc-patches/2015-08/msg00375.html
But, as we use it in a header, in C++ and don't provide an out of line
definition for it, we really don't want the gnu_inline attribute in this
case, because unlike in C, where gnu_inline attribute has one meaning when
applied to inline and another when applied to extern inline, in C++
it always means the extern inline GNU inline semantics.  And gperf clearly
wants the C inline __attribute__((gnu_inline)) semantics.
IMHO gperf should be fixed to only use __attribute__((gnu_inline)) for C++.

BTW, the prototypes aren't really needed anymore in cfns.gperf, we use it
in C++ only and C++ doesn't have -Wstrict-prototypes -Wmissing-prototypes.

So, for cfns.* I think we should use until gperf is fixed:

2016-02-19  Jakub Jelinek  <jakub@redhat.com>

	* cfns.gperf: Remove prototypes for hash and libc_name_p
	inlines.  Undefine __GNUC_STDC_INLINE__ and
	__GNUC_GNU_INLINE__ for C++.
	* cfns.h: Regenerated.

--- gcc/cp/cfns.gperf.jj	2016-01-04 14:55:57.000000000 +0100
+++ gcc/cp/cfns.gperf	2016-02-19 13:16:50.374311181 +0100
@@ -16,14 +16,13 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
+
+/* Don't use gnu_inline attribute that gperf 3.0.3 and later emits
+   for C++.  */
+#if defined(__cplusplus) && defined(__GNUC__)
+#  undef __GNUC_STDC_INLINE__
+#  undef __GNUC_GNU_INLINE__
 #endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
-const char * libc_name_p (const char *, unsigned int);
 %}
 %%
 # The standard C library functions, for feeding to gperf; the result is used
--- gcc/cp/cfns.h.jj	2016-01-04 14:55:57.000000000 +0100
+++ gcc/cp/cfns.h	2016-02-19 13:17:02.458142071 +0100
@@ -1,4 +1,4 @@
-/* ANSI-C code produced by gperf version 3.0.3 */
+/* ANSI-C code produced by gperf version 3.0.4 */
 /* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C cfns.gperf  */
 
 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -47,14 +47,13 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
-#endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
+
+/* Don't use gnu_inline attribute that gperf 3.0.3 and later emits
+   for C++.  */
+#if defined(__cplusplus) && defined(__GNUC__)
+#  undef __GNUC_STDC_INLINE__
+#  undef __GNUC_GNU_INLINE__
 #endif
-const char * libc_name_p (const char *, unsigned int);
 /* maximum key range = 391, duplicates = 0 */
 
 #ifdef __GNUC__
@@ -124,7 +123,7 @@ hash (register const char *str, register
 
 #ifdef __GNUC__
 __inline
-#ifdef __GNUC_STDC_INLINE__
+#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
 __attribute__ ((__gnu_inline__))
 #endif
 #endif

	Jakub

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 12:22           ` Jakub Jelinek
@ 2016-02-19 12:26             ` Jakub Jelinek
  2016-02-19 15:09               ` Bernd Edlinger
  2016-02-19 15:09               ` Bernd Edlinger
  2016-02-19 13:07             ` Bernd Edlinger
  1 sibling, 2 replies; 24+ messages in thread
From: Jakub Jelinek @ 2016-02-19 12:26 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

On Fri, Feb 19, 2016 at 01:22:12PM +0100, Jakub Jelinek wrote:
> wants the C inline __attribute__((gnu_inline)) semantics.
> IMHO gperf should be fixed to only use __attribute__((gnu_inline)) for C++.

For C of course.
Thus emit
#ifndef __cplusplus
#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
or something similar.

	Jakub

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 12:22           ` Jakub Jelinek
  2016-02-19 12:26             ` Jakub Jelinek
@ 2016-02-19 13:07             ` Bernd Edlinger
  1 sibling, 0 replies; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 13:07 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

On 19.02.2016 13:22, Jakub Jelinek wrote:
> Hi!
>
> On Fri, Feb 19, 2016 at 12:59:45PM +0100, Jakub Jelinek wrote:
>> 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.
>
> This is related to
> https://gcc.gnu.org/ml/gcc-patches/2015-08/msg00375.html
> But, as we use it in a header, in C++ and don't provide an out of line
> definition for it, we really don't want the gnu_inline attribute in this
> case, because unlike in C, where gnu_inline attribute has one meaning when
> applied to inline and another when applied to extern inline, in C++
> it always means the extern inline GNU inline semantics.  And gperf clearly
> wants the C inline __attribute__((gnu_inline)) semantics.
> IMHO gperf should be fixed to only use __attribute__((gnu_inline)) for C++.
>
> BTW, the prototypes aren't really needed anymore in cfns.gperf, we use it
> in C++ only and C++ doesn't have -Wstrict-prototypes -Wmissing-prototypes.
>
> So, for cfns.* I think we should use until gperf is fixed:
>

Yeah, that is ugly, but we don't have any alternatives.
So please commit then I can continue with my new patch.

Thanks
Bernd.

> 2016-02-19  Jakub Jelinek  <jakub@redhat.com>
>
> 	* cfns.gperf: Remove prototypes for hash and libc_name_p
> 	inlines.  Undefine __GNUC_STDC_INLINE__ and
> 	__GNUC_GNU_INLINE__ for C++.
> 	* cfns.h: Regenerated.
>
> --- gcc/cp/cfns.gperf.jj	2016-01-04 14:55:57.000000000 +0100
> +++ gcc/cp/cfns.gperf	2016-02-19 13:16:50.374311181 +0100
> @@ -16,14 +16,13 @@ for more details.
>   You should have received a copy of the GNU General Public License
>   along with GCC; see the file COPYING3.  If not see
>   <http://www.gnu.org/licenses/>.  */
> -#ifdef __GNUC__
> -__inline
> +
> +/* Don't use gnu_inline attribute that gperf 3.0.3 and later emits
> +   for C++.  */
> +#if defined(__cplusplus) && defined(__GNUC__)
> +#  undef __GNUC_STDC_INLINE__
> +#  undef __GNUC_GNU_INLINE__
>   #endif
> -static unsigned int hash (const char *, unsigned int);
> -#ifdef __GNUC__
> -__inline
> -#endif
> -const char * libc_name_p (const char *, unsigned int);
>   %}
>   %%
>   # The standard C library functions, for feeding to gperf; the result is used
> --- gcc/cp/cfns.h.jj	2016-01-04 14:55:57.000000000 +0100
> +++ gcc/cp/cfns.h	2016-02-19 13:17:02.458142071 +0100
> @@ -1,4 +1,4 @@
> -/* ANSI-C code produced by gperf version 3.0.3 */
> +/* ANSI-C code produced by gperf version 3.0.4 */
>   /* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C cfns.gperf  */
>
>   #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
> @@ -47,14 +47,13 @@ for more details.
>   You should have received a copy of the GNU General Public License
>   along with GCC; see the file COPYING3.  If not see
>   <http://www.gnu.org/licenses/>.  */
> -#ifdef __GNUC__
> -__inline
> -#endif
> -static unsigned int hash (const char *, unsigned int);
> -#ifdef __GNUC__
> -__inline
> +
> +/* Don't use gnu_inline attribute that gperf 3.0.3 and later emits
> +   for C++.  */
> +#if defined(__cplusplus) && defined(__GNUC__)
> +#  undef __GNUC_STDC_INLINE__
> +#  undef __GNUC_GNU_INLINE__
>   #endif
> -const char * libc_name_p (const char *, unsigned int);
>   /* maximum key range = 391, duplicates = 0 */
>
>   #ifdef __GNUC__
> @@ -124,7 +123,7 @@ hash (register const char *str, register
>
>   #ifdef __GNUC__
>   __inline
> -#ifdef __GNUC_STDC_INLINE__
> +#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
>   __attribute__ ((__gnu_inline__))
>   #endif
>   #endif
>
> 	Jakub
>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 12:26             ` Jakub Jelinek
  2016-02-19 15:09               ` Bernd Edlinger
@ 2016-02-19 15:09               ` Bernd Edlinger
  2016-02-19 15:22                 ` Jakub Jelinek
  1 sibling, 1 reply; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 15:09 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]

On 19.02.2016 13:26, Jakub Jelinek wrote:
> On Fri, Feb 19, 2016 at 01:22:12PM +0100, Jakub Jelinek wrote:
>> wants the C inline __attribute__((gnu_inline)) semantics.
>> IMHO gperf should be fixed to only use __attribute__((gnu_inline)) for C++.
>
> For C of course.
> Thus emit
> #ifndef __cplusplus
> #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
> __attribute__ ((__gnu_inline__))
> #endif
> #endif
> or something similar.
>
> 	Jakub
>

Hmm... wait a moment.
How about that?



Bernd.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-cfns.diff --]
[-- Type: text/x-patch; name="patch-cfns.diff", Size: 3307 bytes --]

Index: gcc/cp/Make-lang.in
===================================================================
--- gcc/cp/Make-lang.in	(revision 233557)
+++ gcc/cp/Make-lang.in	(working copy)
@@ -112,7 +112,7 @@ else
 # deleting the $(srcdir)/cp/cfns.h file.
 $(srcdir)/cp/cfns.h:
 endif
-	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \
+	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \
 		$(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
 
 #\f
Index: gcc/cp/cfns.gperf
===================================================================
--- gcc/cp/cfns.gperf	(revision 233557)
+++ gcc/cp/cfns.gperf	(working copy)
@@ -16,14 +16,7 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
-#endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
-const char * libc_name_p (const char *, unsigned int);
+#define libc_name_p Perfect_Hash::libc_name_p
 %}
 %%
 # The standard C library functions, for feeding to gperf; the result is used
Index: gcc/cp/cfns.h
===================================================================
--- gcc/cp/cfns.h	(revision 233557)
+++ gcc/cp/cfns.h	(working copy)
@@ -1,5 +1,5 @@
-/* ANSI-C code produced by gperf version 3.0.3 */
-/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C cfns.gperf  */
+/* C++ code produced by gperf version 3.0.4 */
+/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L C++ --output-file cfns.h cfns.gperf  */
 
 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -47,26 +47,20 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
-#endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
-const char * libc_name_p (const char *, unsigned int);
+#define libc_name_p Perfect_Hash::libc_name_p
 /* maximum key range = 391, duplicates = 0 */
 
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static unsigned int
-hash (register const char *str, register unsigned int len)
+class Perfect_Hash
 {
+private:
+  static inline unsigned int hash (const char *str, unsigned int len);
+public:
+  static const char *libc_name_p (const char *str, unsigned int len);
+};
+
+inline unsigned int
+Perfect_Hash::hash (register const char *str, register unsigned int len)
+{
   static const unsigned short asso_values[] =
     {
       400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
@@ -122,14 +116,8 @@ along with GCC; see the file COPYING3.  If not see
   return hval + asso_values[(unsigned char)str[len - 1]];
 }
 
-#ifdef __GNUC__
-__inline
-#ifdef __GNUC_STDC_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
 const char *
-libc_name_p (register const char *str, register unsigned int len)
+Perfect_Hash::libc_name_p (register const char *str, register unsigned int len)
 {
   enum
     {

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 12:26             ` Jakub Jelinek
@ 2016-02-19 15:09               ` Bernd Edlinger
  2016-02-19 15:09               ` Bernd Edlinger
  1 sibling, 0 replies; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 15:09 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]

On 19.02.2016 13:26, Jakub Jelinek wrote:
> On Fri, Feb 19, 2016 at 01:22:12PM +0100, Jakub Jelinek wrote:
>> wants the C inline __attribute__((gnu_inline)) semantics.
>> IMHO gperf should be fixed to only use __attribute__((gnu_inline)) for C++.
>
> For C of course.
> Thus emit
> #ifndef __cplusplus
> #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
> __attribute__ ((__gnu_inline__))
> #endif
> #endif
> or something similar.
>
> 	Jakub
>

Hmm... wait a moment.
How about that?



Berns.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-cfns.diff --]
[-- Type: text/x-patch; name="patch-cfns.diff", Size: 3307 bytes --]

Index: gcc/cp/Make-lang.in
===================================================================
--- gcc/cp/Make-lang.in	(revision 233557)
+++ gcc/cp/Make-lang.in	(working copy)
@@ -112,7 +112,7 @@ else
 # deleting the $(srcdir)/cp/cfns.h file.
 $(srcdir)/cp/cfns.h:
 endif
-	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \
+	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \
 		$(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
 
 #\f
Index: gcc/cp/cfns.gperf
===================================================================
--- gcc/cp/cfns.gperf	(revision 233557)
+++ gcc/cp/cfns.gperf	(working copy)
@@ -16,14 +16,7 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
-#endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
-const char * libc_name_p (const char *, unsigned int);
+#define libc_name_p Perfect_Hash::libc_name_p
 %}
 %%
 # The standard C library functions, for feeding to gperf; the result is used
Index: gcc/cp/cfns.h
===================================================================
--- gcc/cp/cfns.h	(revision 233557)
+++ gcc/cp/cfns.h	(working copy)
@@ -1,5 +1,5 @@
-/* ANSI-C code produced by gperf version 3.0.3 */
-/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C cfns.gperf  */
+/* C++ code produced by gperf version 3.0.4 */
+/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L C++ --output-file cfns.h cfns.gperf  */
 
 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -47,26 +47,20 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
-#endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
-const char * libc_name_p (const char *, unsigned int);
+#define libc_name_p Perfect_Hash::libc_name_p
 /* maximum key range = 391, duplicates = 0 */
 
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static unsigned int
-hash (register const char *str, register unsigned int len)
+class Perfect_Hash
 {
+private:
+  static inline unsigned int hash (const char *str, unsigned int len);
+public:
+  static const char *libc_name_p (const char *str, unsigned int len);
+};
+
+inline unsigned int
+Perfect_Hash::hash (register const char *str, register unsigned int len)
+{
   static const unsigned short asso_values[] =
     {
       400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
@@ -122,14 +116,8 @@ along with GCC; see the file COPYING3.  If not see
   return hval + asso_values[(unsigned char)str[len - 1]];
 }
 
-#ifdef __GNUC__
-__inline
-#ifdef __GNUC_STDC_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
 const char *
-libc_name_p (register const char *str, register unsigned int len)
+Perfect_Hash::libc_name_p (register const char *str, register unsigned int len)
 {
   enum
     {

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 15:09               ` Bernd Edlinger
@ 2016-02-19 15:22                 ` Jakub Jelinek
  2016-02-19 15:31                   ` Bernd Edlinger
  2016-02-19 15:51                   ` Bernd Edlinger
  0 siblings, 2 replies; 24+ messages in thread
From: Jakub Jelinek @ 2016-02-19 15:22 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

On Fri, Feb 19, 2016 at 03:09:25PM +0000, Bernd Edlinger wrote:
> Hmm... wait a moment.
> How about that?

Guess it is mostly reasonable (still, this is C++ FE, so I'd prefer
Jason to ack it), except for:

> +#define libc_name_p Perfect_Hash::libc_name_p

this.  Doesn't that cause
Perfect_Hash::libc_name_p (register const char *str, register unsigned int len)
to expand as
Perfect_Hash:: Perfect_Hash::libc_name_p (register const char *str, register unsigned int len)
?

So, I think better might be something like:

--- gcc/cp/Make-lang.in.jj	2016-01-04 14:55:57.000000000 +0100
+++ gcc/cp/Make-lang.in	2016-02-19 16:21:11.538734055 +0100
@@ -112,7 +112,7 @@ else
 # deleting the $(srcdir)/cp/cfns.h file.
 $(srcdir)/cp/cfns.h:
 endif
-	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \
+	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \
 		$(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
 
 #\f
--- gcc/cp/except.c.jj	2016-01-04 14:55:57.000000000 +0100
+++ gcc/cp/except.c	2016-02-19 16:20:37.134205968 +0100
@@ -1040,7 +1040,8 @@ nothrow_libfn_p (const_tree fn)
      unless the system headers are playing rename tricks, and if
      they are, we don't want to be confused by them.  */
   id = DECL_NAME (fn);
-  return !!libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
+  return !!libc_name::libc_name_p (IDENTIFIER_POINTER (id),
+				   IDENTIFIER_LENGTH (id));
 }
 
 /* Returns nonzero if an exception of type FROM will be caught by a
--- gcc/cp/cfns.gperf.jj	2016-02-19 14:41:14.000000000 +0100
+++ gcc/cp/cfns.gperf	2016-02-19 16:19:34.841060418 +0100
@@ -1,3 +1,5 @@
+%language=C++
+%define class-name libc_name
 %{
 /* Copyright (C) 2000-2016 Free Software Foundation, Inc.
 
@@ -16,14 +18,6 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
-#endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
-const char * libc_name_p (const char *, unsigned int);
 %}
 %%
 # The standard C library functions, for feeding to gperf; the result is used
--- gcc/cp/cfns.h.jj	2016-02-19 14:41:14.000000000 +0100
+++ gcc/cp/cfns.h	2016-02-19 16:19:53.533804017 +0100
@@ -1,5 +1,5 @@
-/* ANSI-C code produced by gperf version 3.0.3 */
-/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C cfns.gperf  */
+/* C++ code produced by gperf version 3.0.4 */
+/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L C++ cfns.gperf  */
 
 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -28,7 +28,7 @@
 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
 #endif
 
-#line 1 "cfns.gperf"
+#line 3 "cfns.gperf"
 
 /* Copyright (C) 2000-2016 Free Software Foundation, Inc.
 
@@ -47,25 +47,18 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
-#endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
-const char * libc_name_p (const char *, unsigned int);
 /* maximum key range = 391, duplicates = 0 */
 
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static unsigned int
-hash (register const char *str, register unsigned int len)
+class libc_name
+{
+private:
+  static inline unsigned int hash (const char *str, unsigned int len);
+public:
+  static const char *libc_name_p (const char *str, unsigned int len);
+};
+
+inline unsigned int
+libc_name::hash (register const char *str, register unsigned int len)
 {
   static const unsigned short asso_values[] =
     {
@@ -122,14 +115,8 @@ hash (register const char *str, register
   return hval + asso_values[(unsigned char)str[len - 1]];
 }
 
-#ifdef __GNUC__
-__inline
-#ifdef __GNUC_STDC_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
 const char *
-libc_name_p (register const char *str, register unsigned int len)
+libc_name::libc_name_p (register const char *str, register unsigned int len)
 {
   enum
     {

	Jakub

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 15:22                 ` Jakub Jelinek
@ 2016-02-19 15:31                   ` Bernd Edlinger
  2016-02-19 15:51                   ` Bernd Edlinger
  1 sibling, 0 replies; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 15:31 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

On 19.02.2016 16:22, Jakub Jelinek wrote:
> On Fri, Feb 19, 2016 at 03:09:25PM +0000, Bernd Edlinger wrote:
>> Hmm... wait a moment.
>> How about that?
>
> Guess it is mostly reasonable (still, this is C++ FE, so I'd prefer
> Jason to ack it), except for:
>
>> +#define libc_name_p Perfect_Hash::libc_name_p
>

Yeee. Right.

> this.  Doesn't that cause
> Perfect_Hash::libc_name_p (register const char *str, register unsigned int len)
> to expand as
> Perfect_Hash:: Perfect_Hash::libc_name_p (register const char *str, register unsigned int len)
> ?
>
> So, I think better might be something like:
>
> --- gcc/cp/Make-lang.in.jj	2016-01-04 14:55:57.000000000 +0100
> +++ gcc/cp/Make-lang.in	2016-02-19 16:21:11.538734055 +0100
> @@ -112,7 +112,7 @@ else
>   # deleting the $(srcdir)/cp/cfns.h file.
>   $(srcdir)/cp/cfns.h:
>   endif
> -	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \
> +	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \
>   		$(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
>
>   #\f
> --- gcc/cp/except.c.jj	2016-01-04 14:55:57.000000000 +0100
> +++ gcc/cp/except.c	2016-02-19 16:20:37.134205968 +0100
> @@ -1040,7 +1040,8 @@ nothrow_libfn_p (const_tree fn)
>        unless the system headers are playing rename tricks, and if
>        they are, we don't want to be confused by them.  */
>     id = DECL_NAME (fn);
> -  return !!libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
> +  return !!libc_name::libc_name_p (IDENTIFIER_POINTER (id),
> +				   IDENTIFIER_LENGTH (id));
>   }
>
>   /* Returns nonzero if an exception of type FROM will be caught by a
> --- gcc/cp/cfns.gperf.jj	2016-02-19 14:41:14.000000000 +0100
> +++ gcc/cp/cfns.gperf	2016-02-19 16:19:34.841060418 +0100
> @@ -1,3 +1,5 @@
> +%language=C++
> +%define class-name libc_name
>   %{

I like this idea with class-name.
Will post an updated patch in a minute.


Thanks
Bernd.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 15:22                 ` Jakub Jelinek
  2016-02-19 15:31                   ` Bernd Edlinger
@ 2016-02-19 15:51                   ` Bernd Edlinger
  2016-02-19 16:03                     ` Jason Merrill
  2016-02-19 16:39                     ` Jakub Jelinek
  1 sibling, 2 replies; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 15:51 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

[-- Attachment #1: Type: text/plain, Size: 306 bytes --]

On 19.02.2016 16:22, Jakub Jelinek wrote:
>
> Guess it is mostly reasonable (still, this is C++ FE, so I'd prefer
> Jason to ack it), except for:
>

Here are updated versions of the cfns-patch and the pr69856-patch.
Are they OK for trunk when boot-strap and reg-testing succeeds?

Thanks
Bernd.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-cfns.diff --]
[-- Type: text/x-patch; name="patch-cfns.diff", Size: 4502 bytes --]

2016-02-19  Jakub Jelinek  <jakub@redhat.com>
	    Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* Make-lang.in: Invoke gpref with -L C++.
 	* cfns.gperf: Remove prototypes for hash and libc_name_p
 	inlines.
 	* cfns.h: Regenerated.
	* except.c (nothrow_libfn_p): Adjust.

Index: gcc/cp/Make-lang.in
===================================================================
--- gcc/cp/Make-lang.in	(revision 233557)
+++ gcc/cp/Make-lang.in	(working copy)
@@ -112,7 +112,7 @@ else
 # deleting the $(srcdir)/cp/cfns.h file.
 $(srcdir)/cp/cfns.h:
 endif
-	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \
+	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \
 		$(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
 
 #\f
Index: gcc/cp/cfns.gperf
===================================================================
--- gcc/cp/cfns.gperf	(revision 233557)
+++ gcc/cp/cfns.gperf	(working copy)
@@ -1,3 +1,5 @@
+%language=C++
+%define class-name libc_name
 %{
 /* Copyright (C) 2000-2016 Free Software Foundation, Inc.
 
@@ -16,14 +18,6 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
-#endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
-const char * libc_name_p (const char *, unsigned int);
 %}
 %%
 # The standard C library functions, for feeding to gperf; the result is used
Index: gcc/cp/cfns.h
===================================================================
--- gcc/cp/cfns.h	(revision 233557)
+++ gcc/cp/cfns.h	(working copy)
@@ -1,5 +1,5 @@
-/* ANSI-C code produced by gperf version 3.0.3 */
-/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C cfns.gperf  */
+/* C++ code produced by gperf version 3.0.4 */
+/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L C++ --output-file cfns.h cfns.gperf  */
 
 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -28,7 +28,7 @@
 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
 #endif
 
-#line 1 "cfns.gperf"
+#line 3 "cfns.gperf"
 
 /* Copyright (C) 2000-2016 Free Software Foundation, Inc.
 
@@ -47,26 +47,19 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
-#endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
-const char * libc_name_p (const char *, unsigned int);
 /* maximum key range = 391, duplicates = 0 */
 
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static unsigned int
-hash (register const char *str, register unsigned int len)
+class libc_name
 {
+private:
+  static inline unsigned int hash (const char *str, unsigned int len);
+public:
+  static const char *libc_name_p (const char *str, unsigned int len);
+};
+
+inline unsigned int
+libc_name::hash (register const char *str, register unsigned int len)
+{
   static const unsigned short asso_values[] =
     {
       400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
@@ -122,14 +115,8 @@ along with GCC; see the file COPYING3.  If not see
   return hval + asso_values[(unsigned char)str[len - 1]];
 }
 
-#ifdef __GNUC__
-__inline
-#ifdef __GNUC_STDC_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
 const char *
-libc_name_p (register const char *str, register unsigned int len)
+libc_name::libc_name_p (register const char *str, register unsigned int len)
 {
   enum
     {
Index: gcc/cp/except.c
===================================================================
--- gcc/cp/except.c	(revision 233557)
+++ gcc/cp/except.c	(working copy)
@@ -1040,7 +1040,7 @@ nothrow_libfn_p (const_tree fn)
      unless the system headers are playing rename tricks, and if
      they are, we don't want to be confused by them.  */
   id = DECL_NAME (fn);
-  return !!libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
+  return !!libc_name::libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
 }
 
 /* Returns nonzero if an exception of type FROM will be caught by a

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: patch-pr69865.diff --]
[-- Type: text/x-patch; name="patch-pr69865.diff", Size: 1452 bytes --]

2016-02-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR c++/69865
	* c-opts.c (c_common_post_options): Move call to set_std_cxx14 from
	here...
	(c_common_init_options): ...to here.
	(set_std_cxx98): Initialize flag_isoc94 and flag_isoc99.

Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c	(revision 233557)
+++ gcc/c-family/c-opts.c	(working copy)
@@ -246,6 +246,10 @@ c_common_init_options (unsigned int decoded_option
 	  }
     }
 
+  /* Set C++ standard to C++14 if not specified on the command line.  */
+  if (c_dialect_cxx ())
+    set_std_cxx14 (/*ISO*/false);
+
   global_dc->colorize_source_p = true;
 }
 
@@ -802,10 +806,6 @@ c_common_post_options (const char **pfilename)
       && flag_no_builtin)
     flag_tree_loop_distribute_patterns = 0;
 
-  /* Set C++ standard to C++14 if not specified on the command line.  */
-  if (c_dialect_cxx () && cxx_dialect == cxx_unset)
-    set_std_cxx14 (/*ISO*/false);
-
   /* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
      It is never enabled in C++, as the minimum limit is not normative
      in that standard.  */
@@ -1519,6 +1519,8 @@ set_std_cxx98 (int iso)
   flag_no_gnu_keywords = iso;
   flag_no_nonansi_builtin = iso;
   flag_iso = iso;
+  flag_isoc94 = 0;
+  flag_isoc99 = 0;
   cxx_dialect = cxx98;
   lang_hooks.name = "GNU C++98";
 }

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 15:51                   ` Bernd Edlinger
@ 2016-02-19 16:03                     ` Jason Merrill
  2016-02-19 16:10                       ` Jakub Jelinek
  2016-02-19 19:37                       ` Bernd Edlinger
  2016-02-19 16:39                     ` Jakub Jelinek
  1 sibling, 2 replies; 24+ messages in thread
From: Jason Merrill @ 2016-02-19 16:03 UTC (permalink / raw)
  To: Bernd Edlinger, Jakub Jelinek; +Cc: gcc-patches, Jonathan Wakely

On 02/19/2016 10:51 AM, Bernd Edlinger wrote:
> +  flag_isoc94 = 0;
> +  flag_isoc99 = 0;

Why?  These flags are global variables, so they're already zero-initialized.

Otherwise the changes look good to me.

Jason

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 16:03                     ` Jason Merrill
@ 2016-02-19 16:10                       ` Jakub Jelinek
  2016-02-19 16:19                         ` Bernd Edlinger
  2016-02-19 19:37                       ` Bernd Edlinger
  1 sibling, 1 reply; 24+ messages in thread
From: Jakub Jelinek @ 2016-02-19 16:10 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Bernd Edlinger, gcc-patches, Jonathan Wakely

On Fri, Feb 19, 2016 at 11:03:23AM -0500, Jason Merrill wrote:
> On 02/19/2016 10:51 AM, Bernd Edlinger wrote:
> >+  flag_isoc94 = 0;
> >+  flag_isoc99 = 0;
> 
> Why?  These flags are global variables, so they're already zero-initialized.

That is true, but those global variables could have changed earlier.
Don't they e.g. get set if you do:
-std=c++14 -std=c++98
?

	Jakub

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 16:10                       ` Jakub Jelinek
@ 2016-02-19 16:19                         ` Bernd Edlinger
  0 siblings, 0 replies; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 16:19 UTC (permalink / raw)
  To: Jakub Jelinek, Jason Merrill; +Cc: gcc-patches, Jonathan Wakely

On 19.02.2016 17:09, Jakub Jelinek wrote:
> On Fri, Feb 19, 2016 at 11:03:23AM -0500, Jason Merrill wrote:
>> On 02/19/2016 10:51 AM, Bernd Edlinger wrote:
>>> +  flag_isoc94 = 0;
>>> +  flag_isoc99 = 0;
>>
>> Why?  These flags are global variables, so they're already zero-initialized.
>
> That is true, but those global variables could have changed earlier.
> Don't they e.g. get set if you do:
> -std=c++14 -std=c++98
> ?
>
> 	Jakub
>

These are zero-initialized, but this:

@@ -246,6 +246,10 @@ c_common_init_options (unsigned int decoded_option
           }
      }

+  /* Set C++ standard to C++14 if not specified on the command line.  */
+  if (c_dialect_cxx ())
+    set_std_cxx14 (/*ISO*/false);
+
    global_dc->colorize_source_p = true;
  }


.. initializes them to 1, which is the default until we see
a -std=c++03.

I got 2 test cases FAIL without that hunk.

c-c++common/Wshift-negative-value-6.c and another similar one,
which I don't remember in the moment.


Bernd.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 15:51                   ` Bernd Edlinger
  2016-02-19 16:03                     ` Jason Merrill
@ 2016-02-19 16:39                     ` Jakub Jelinek
  2016-02-19 17:26                       ` Bernd Edlinger
  1 sibling, 1 reply; 24+ messages in thread
From: Jakub Jelinek @ 2016-02-19 16:39 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

On Fri, Feb 19, 2016 at 03:51:08PM +0000, Bernd Edlinger wrote:
> --- gcc/cp/except.c	(revision 233557)
> +++ gcc/cp/except.c	(working copy)
> @@ -1040,7 +1040,7 @@ nothrow_libfn_p (const_tree fn)
>       unless the system headers are playing rename tricks, and if
>       they are, we don't want to be confused by them.  */
>    id = DECL_NAME (fn);
> -  return !!libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
> +  return !!libc_name::libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));

Too long line.

	Jakub

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 16:39                     ` Jakub Jelinek
@ 2016-02-19 17:26                       ` Bernd Edlinger
  0 siblings, 0 replies; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 17:26 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Jason Merrill, Jonathan Wakely

On 19.02.2016 17:38, Jakub Jelinek wrote:
> > -  return !!libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
> > +  return !!libc_name::libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
> 
> Too long line.
> 
>         Jakub

Oh, thanks.  Consider it fixed.
Also the typo in the ChangeLog:

> 2016-02-19  Jakub Jelinek  <jakub@redhat.com>
> 	    Bernd Edlinger  <bernd.edlinger@hotmail.de>
> 
> 	* Make-lang.in: Invoke gpref with -L C++.

We invoke gperf of course.

Bernd.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 16:03                     ` Jason Merrill
  2016-02-19 16:10                       ` Jakub Jelinek
@ 2016-02-19 19:37                       ` Bernd Edlinger
  2016-02-19 19:47                         ` Jason Merrill
  1 sibling, 1 reply; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-19 19:37 UTC (permalink / raw)
  To: Jason Merrill, Jakub Jelinek; +Cc: gcc-patches, Jonathan Wakely

On 19.02.2016 17:03, Jason Merrill wrote:
> On 02/19/2016 10:51 AM, Bernd Edlinger wrote:
>> +  flag_isoc94 = 0;
>> +  flag_isoc99 = 0;
>
> Why?  These flags are global variables, so they're already
> zero-initialized.
>
> Otherwise the changes look good to me.
>
> Jason
>

Hi Jason,

This hunk is really needed.

I can prove it:

Index: gcc/testsuite/c-c++-common/Wshift-negative-value-6.c
===================================================================
--- gcc/testsuite/c-c++-common/Wshift-negative-value-6.c	(revision 233557)
+++ gcc/testsuite/c-c++-common/Wshift-negative-value-6.c	(working copy)
@@ -1,7 +1,7 @@
  /* PR c/65179 */
  /* { dg-do compile } */
  /* { dg-options "-O -Wextra" } */
-/* { dg-additional-options "-std=c++03" { target c++ } } */
+/* { dg-additional-options "-std=c++11 -std=c++03" { target c++ } } */
  /* { dg-additional-options "-std=c90" { target c } } */

  enum E {


unpatched gcc gives:

                 === g++ tests ===


Running target unix
FAIL: c-c++-common/Wshift-negative-value-6.c    (test for bogus 
messages, line 10)
FAIL: c-c++-common/Wshift-negative-value-6.c    (test for bogus 
messages, line 26)
FAIL: c-c++-common/Wshift-negative-value-6.c    (test for bogus 
messages, line 29)


Would you like me to commit the above test case change together with
both parts of the patch?

Do you think the patch is OK now?


Thanks
Bernd.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 19:37                       ` Bernd Edlinger
@ 2016-02-19 19:47                         ` Jason Merrill
  2016-02-20  6:38                           ` Bernd Edlinger
  0 siblings, 1 reply; 24+ messages in thread
From: Jason Merrill @ 2016-02-19 19:47 UTC (permalink / raw)
  To: Bernd Edlinger, Jakub Jelinek; +Cc: gcc-patches, Jonathan Wakely

On 02/19/2016 02:37 PM, Bernd Edlinger wrote:
> On 19.02.2016 17:03, Jason Merrill wrote:
>> On 02/19/2016 10:51 AM, Bernd Edlinger wrote:
>>> +  flag_isoc94 = 0;
>>> +  flag_isoc99 = 0;
>>
>> Why?  These flags are global variables, so they're already
>> zero-initialized.
>>
>> Otherwise the changes look good to me.
>>
>> Jason
>>
>
> Hi Jason,
>
> This hunk is really needed.
>
> I can prove it:
>
> Index: gcc/testsuite/c-c++-common/Wshift-negative-value-6.c
> ===================================================================
> --- gcc/testsuite/c-c++-common/Wshift-negative-value-6.c	(revision 233557)
> +++ gcc/testsuite/c-c++-common/Wshift-negative-value-6.c	(working copy)
> @@ -1,7 +1,7 @@
>    /* PR c/65179 */
>    /* { dg-do compile } */
>    /* { dg-options "-O -Wextra" } */
> -/* { dg-additional-options "-std=c++03" { target c++ } } */
> +/* { dg-additional-options "-std=c++11 -std=c++03" { target c++ } } */
>    /* { dg-additional-options "-std=c90" { target c } } */
>
>    enum E {
>
>
> unpatched gcc gives:
>
>                   === g++ tests ===
>
>
> Running target unix
> FAIL: c-c++-common/Wshift-negative-value-6.c    (test for bogus
> messages, line 10)
> FAIL: c-c++-common/Wshift-negative-value-6.c    (test for bogus
> messages, line 26)
> FAIL: c-c++-common/Wshift-negative-value-6.c    (test for bogus
> messages, line 29)
>
>
> Would you like me to commit the above test case change together with
> both parts of the patch?
>
> Do you think the patch is OK now?

OK.

Jason


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-19 19:47                         ` Jason Merrill
@ 2016-02-20  6:38                           ` Bernd Edlinger
  2016-02-25 15:27                             ` Jakub Jelinek
  0 siblings, 1 reply; 24+ messages in thread
From: Bernd Edlinger @ 2016-02-20  6:38 UTC (permalink / raw)
  To: Jason Merrill, Jakub Jelinek; +Cc: gcc-patches, Jonathan Wakely

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

Hi,

as almost expected r233572 needs to be back-ported to gcc-5 and gcc-4.9
branches in order to be built by gcc-6.  It applies cleanly to both
branches.  But unfortunately PR 69881 prevents boot-strapping gcc-4.9
in the moment.

Boot-strap and regression-test of gcc-5 on x86_64-pc-linux-gnu.
OK for gcc-5 and gcc-4.9 when PR 69881 is resolved?


Thanks
Bernd.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-cfns.diff --]
[-- Type: text/x-patch; name="patch-cfns.diff", Size: 4599 bytes --]

2016-02-20  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	Backported from mainline
	2016-02-19  Jakub Jelinek  <jakub@redhat.com>
		    Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* Make-lang.in: Invoke gperf with -L C++.
 	* cfns.gperf: Remove prototypes for hash and libc_name_p
 	inlines.
 	* cfns.h: Regenerated.
	* except.c (nothrow_libfn_p): Adjust.

Index: gcc/cp/Make-lang.in
===================================================================
--- gcc/cp/Make-lang.in	(revision 233574)
+++ gcc/cp/Make-lang.in	(working copy)
@@ -111,7 +111,7 @@ else
 # deleting the $(srcdir)/cp/cfns.h file.
 $(srcdir)/cp/cfns.h:
 endif
-	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \
+	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L C++ \
 		$(srcdir)/cp/cfns.gperf --output-file $(srcdir)/cp/cfns.h
 
 #\f
Index: gcc/cp/cfns.gperf
===================================================================
--- gcc/cp/cfns.gperf	(revision 233574)
+++ gcc/cp/cfns.gperf	(working copy)
@@ -1,3 +1,5 @@
+%language=C++
+%define class-name libc_name
 %{
 /* Copyright (C) 2000-2015 Free Software Foundation, Inc.
 
@@ -16,14 +18,6 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
-#endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
-const char * libc_name_p (const char *, unsigned int);
 %}
 %%
 # The standard C library functions, for feeding to gperf; the result is used
Index: gcc/cp/cfns.h
===================================================================
--- gcc/cp/cfns.h	(revision 233574)
+++ gcc/cp/cfns.h	(working copy)
@@ -1,5 +1,5 @@
-/* ANSI-C code produced by gperf version 3.0.3 */
-/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C cfns.gperf  */
+/* C++ code produced by gperf version 3.0.4 */
+/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L C++ --output-file cfns.h cfns.gperf  */
 
 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -28,7 +28,7 @@
 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
 #endif
 
-#line 1 "cfns.gperf"
+#line 3 "cfns.gperf"
 
 /* Copyright (C) 2000-2015 Free Software Foundation, Inc.
 
@@ -47,26 +47,19 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
-#ifdef __GNUC__
-__inline
-#endif
-static unsigned int hash (const char *, unsigned int);
-#ifdef __GNUC__
-__inline
-#endif
-const char * libc_name_p (const char *, unsigned int);
 /* maximum key range = 391, duplicates = 0 */
 
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static unsigned int
-hash (register const char *str, register unsigned int len)
+class libc_name
 {
+private:
+  static inline unsigned int hash (const char *str, unsigned int len);
+public:
+  static const char *libc_name_p (const char *str, unsigned int len);
+};
+
+inline unsigned int
+libc_name::hash (register const char *str, register unsigned int len)
+{
   static const unsigned short asso_values[] =
     {
       400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
@@ -122,14 +115,8 @@ along with GCC; see the file COPYING3.  If not see
   return hval + asso_values[(unsigned char)str[len - 1]];
 }
 
-#ifdef __GNUC__
-__inline
-#ifdef __GNUC_STDC_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
 const char *
-libc_name_p (register const char *str, register unsigned int len)
+libc_name::libc_name_p (register const char *str, register unsigned int len)
 {
   enum
     {
Index: gcc/cp/except.c
===================================================================
--- gcc/cp/except.c	(revision 233574)
+++ gcc/cp/except.c	(working copy)
@@ -1040,7 +1040,8 @@ nothrow_libfn_p (const_tree fn)
      unless the system headers are playing rename tricks, and if
      they are, we don't want to be confused by them.  */
   id = DECL_NAME (fn);
-  return !!libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
+  return !!libc_name::libc_name_p (IDENTIFIER_POINTER (id),
+				   IDENTIFIER_LENGTH (id));
 }
 
 /* Returns nonzero if an exception of type FROM will be caught by a

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
  2016-02-20  6:38                           ` Bernd Edlinger
@ 2016-02-25 15:27                             ` Jakub Jelinek
  0 siblings, 0 replies; 24+ messages in thread
From: Jakub Jelinek @ 2016-02-25 15:27 UTC (permalink / raw)
  To: Bernd Edlinger; +Cc: Jason Merrill, gcc-patches, Jonathan Wakely

On Sat, Feb 20, 2016 at 06:38:05AM +0000, Bernd Edlinger wrote:
> Hi,
> 
> as almost expected r233572 needs to be back-ported to gcc-5 and gcc-4.9
> branches in order to be built by gcc-6.  It applies cleanly to both
> branches.  But unfortunately PR 69881 prevents boot-strapping gcc-4.9
> in the moment.
> 
> Boot-strap and regression-test of gcc-5 on x86_64-pc-linux-gnu.
> OK for gcc-5 and gcc-4.9 when PR 69881 is resolved?

Ok for 5/4.9.

> 2016-02-20  Bernd Edlinger  <bernd.edlinger@hotmail.de>
> 
> 	Backported from mainline
> 	2016-02-19  Jakub Jelinek  <jakub@redhat.com>
> 		    Bernd Edlinger  <bernd.edlinger@hotmail.de>
> 
> 	* Make-lang.in: Invoke gperf with -L C++.
>  	* cfns.gperf: Remove prototypes for hash and libc_name_p
>  	inlines.
>  	* cfns.h: Regenerated.
> 	* except.c (nothrow_libfn_p): Adjust.

	Jakub

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2016-02-25 15:27 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-19 10:50 [C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865) Bernd Edlinger
2016-02-19 10:56 ` Jakub Jelinek
2016-02-19 11:09   ` Bernd Edlinger
2016-02-19 11:31     ` Jakub Jelinek
2016-02-19 11:53       ` Bernd Edlinger
2016-02-19 11:59         ` Jakub Jelinek
2016-02-19 12:10           ` Bernd Edlinger
2016-02-19 12:22           ` Jakub Jelinek
2016-02-19 12:26             ` Jakub Jelinek
2016-02-19 15:09               ` Bernd Edlinger
2016-02-19 15:09               ` Bernd Edlinger
2016-02-19 15:22                 ` Jakub Jelinek
2016-02-19 15:31                   ` Bernd Edlinger
2016-02-19 15:51                   ` Bernd Edlinger
2016-02-19 16:03                     ` Jason Merrill
2016-02-19 16:10                       ` Jakub Jelinek
2016-02-19 16:19                         ` Bernd Edlinger
2016-02-19 19:37                       ` Bernd Edlinger
2016-02-19 19:47                         ` Jason Merrill
2016-02-20  6:38                           ` Bernd Edlinger
2016-02-25 15:27                             ` Jakub Jelinek
2016-02-19 16:39                     ` Jakub Jelinek
2016-02-19 17:26                       ` Bernd Edlinger
2016-02-19 13:07             ` Bernd Edlinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).