[C++ PATCH] Fix option handling when -std=gnu++14 is not used (PR 69865)
Jakub Jelinek
jakub@redhat.com
Fri Feb 19 12:22:00 GMT 2016
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
More information about the Gcc-patches
mailing list