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

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).