diff mbox

[C++] Fix option handling when -std=gnu++14 is not used (PR 69865)

Message ID HE1PR07MB09055E200A8D3B40C6D57FE2E4A00@HE1PR07MB0905.eurprd07.prod.outlook.com
State New
Headers show

Commit Message

Bernd Edlinger Feb. 19, 2016, 3:51 p.m. UTC
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.

Comments

Jason Merrill Feb. 19, 2016, 4:03 p.m. UTC | #1
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
Jakub Jelinek Feb. 19, 2016, 4:09 p.m. UTC | #2
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
Bernd Edlinger Feb. 19, 2016, 4:19 p.m. UTC | #3
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.
Jakub Jelinek Feb. 19, 2016, 4:38 p.m. UTC | #4
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
Bernd Edlinger Feb. 19, 2016, 5:26 p.m. UTC | #5
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.
diff mbox

Patch

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";
 }