On 5/19/20 7:34 PM, Marek Polacek wrote:
On Mon, May 18, 2020 at 03:51:36PM -0400, Jason Merrill wrote:
On 5/16/20 6:34 PM, Marek Polacek wrote:
Since GCC 9, C++17 support is no longer experimental.  It was too late
to change the default C++ dialect to C++17 in GCC 10, but I think now
it's time to pull the trigger (C++14 was made the default in GCC 6.1).
We're still missing two C++17 library features, but that shouldn't stop
us.  See
<https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017>
and
<https://gcc.gnu.org/projects/cxx-status.html#cxx17>
for the C++17 status.

I won't list all C++17 features here, but just a few heads-up:

- trigraphs were removed (hardly anyone cares, unless your keyboard is
    missing the # key),
- operator++(bool) was removed (so some tests now run in C++14 and down
    only),
- the keyword register was removed (some legacy code might trip on
    this),
- noexcept specification is now part of the type system and C++17 does
    not allow dynamic exception specifications anymore (the empty throw
    specification is still available, but it is deprecated),
- the evaluation order rules are different in C++17,
- static constexpr data members are now implicitly inline (which makes
    them definitions),
- C++17 requires guaranteed copy elision, meaning that a copy/move
    constructor call might be elided completely.  That means that if
    something relied on a constructor being instantiated via e.g. copying
    a function parameter, it might now fail.

Jakub, the last point is actually what I encountered in for-27.C and it
looks like an OpenMP issue, in that it wrongly depends on an implicit
instantiation.  Am I mistaken?

Due to the 'register' removal, this patch depends on the regenerated
cfns.h version I posted earlier today.

I'll post an update for cxx-status.html and add a new caveat to changes.html
once this is in.

Bootstrapped/regtested on x86_64-pc-linux-gnu, aarch64-unknown-linux-gnu,
and powerpc64le-unknown-linux-gnu.  Ok for trunk?

        * doc/invoke.texi (C Dialect Options): Adjust -std default for C++.
        * doc/standards.texi (C Language): Correct the default dialect.
        (C++ Language): Update the default for C++ to gnu++17.

        * c-opts.c (c_common_init_options): Default to gnu++17.

        * c-c++-common/torture/vector-subscript-3.c: Remove the register
        keywords.
        * g++.dg/cpp1z/attributes-enum-1a.C: Update for C++17.
        * g++.dg/cpp1z/fold7a.C: Likewise.
        * g++.dg/cpp1z/nontype3a.C: Likewise.
        * g++.dg/cpp1z/utf8-2a.C: Likewise.
        * g++.dg/parse/error11.C: Use c++14_down.
        * g++.dg/torture/pr34850.C: Add -Wno-attribute-warning.
        * g++.dg/torture/pr49394.C: Add dg-warning.
        * g++.dg/torture/pr82154.C: Use -std=c++14.
        * g++.dg/ubsan/pr85029.C: Use -Wno-register.
        * g++.dg/ubsan/vptr-12.C: Use -fstrong-eval-order=some.
        * lib/target-supports.exp: Set to C++17.
        * obj-c++.dg/try-catch-9.mm: Use -Wno-register.

        * testsuite/libgomp.c++/atomic-3.C: Use -std=gnu++14.
        * testsuite/libgomp.c++/for-27.C: Explicitly instantiate the
        copy constructor for I<int>.
---
   gcc/c-family/c-opts.c                                   | 4 ++--
   gcc/doc/invoke.texi                                     | 2 +-
   gcc/doc/standards.texi                                  | 4 ++--
   gcc/testsuite/c-c++-common/torture/vector-subscript-3.c | 6 +++---
   gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C         | 4 ++--
   gcc/testsuite/g++.dg/cpp1z/fold7a.C                     | 4 ++--
   gcc/testsuite/g++.dg/cpp1z/nontype3a.C                  | 4 ++--
   gcc/testsuite/g++.dg/cpp1z/utf8-2a.C                    | 4 ++--
   gcc/testsuite/g++.dg/parse/error11.C                    | 5 +++--
   gcc/testsuite/g++.dg/torture/pr34850.C                  | 2 +-
   gcc/testsuite/g++.dg/torture/pr49394.C                  | 2 +-
   gcc/testsuite/g++.dg/torture/pr82154.C                  | 3 ++-
   gcc/testsuite/g++.dg/ubsan/pr85029.C                    | 2 +-
   gcc/testsuite/g++.dg/ubsan/vptr-12.C                    | 2 +-
   gcc/testsuite/lib/target-supports.exp                   | 2 +-
   gcc/testsuite/obj-c++.dg/try-catch-9.mm                 | 2 +-
   libgomp/testsuite/libgomp.c++/atomic-3.C                | 3 ++-
   libgomp/testsuite/libgomp.c++/for-27.C                  | 6 ++++++
   18 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 7695e88c130..5b266c06f3b 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -256,9 +256,9 @@ c_common_init_options (unsigned int decoded_options_count,
          }
       }
-  /* Set C++ standard to C++14 if not specified on the command line.  */
+  /* Set C++ standard to C++17 if not specified on the command line.  */
     if (c_dialect_cxx ())
-    set_std_cxx14 (/*ISO*/false);
+    set_std_cxx17 (/*ISO*/false);
     global_dc->colorize_source_p = true;
   }
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 850aeac033d..97e13421323 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2057,7 +2057,6 @@ The name @samp{c++1y} is deprecated.
   @item gnu++14
   @itemx gnu++1y
   GNU dialect of @option{-std=c++14}.
-This is the default for C++ code.
   The name @samp{gnu++1y} is deprecated.
   @item c++17
@@ -2068,6 +2067,7 @@ The name @samp{c++1z} is deprecated.
   @item gnu++17
   @itemx gnu++1z
   GNU dialect of @option{-std=c++17}.
+This is the default for C++ code.
   The name @samp{gnu++1z} is deprecated.
   @item c++20
diff --git a/gcc/doc/standards.texi b/gcc/doc/standards.texi
index f39d8b378f1..fc5016028dd 100644
--- a/gcc/doc/standards.texi
+++ b/gcc/doc/standards.texi
@@ -130,7 +130,7 @@ select an extended version of the C language explicitly with
   extensions).
   The default, if no C language dialect options are given,
-is @option{-std=gnu11}.
+is @option{-std=gnu17}.

I don't think you mean to change the default C dialect.

The current default C dialect already is gnu17, here I was just correcting that
as a drive-by.  I can commit it separately if you prefer.

   The ISO C standard defines (in clause 4) two classes of conforming
   implementation.  A @dfn{conforming hosted implementation} supports the
@@ -246,7 +246,7 @@ select an extended version of the C++ language explicitly 
with
   @option{-std=gnu++17} (for C++17 with GNU extensions).
   The default, if
-no C++ language dialect options are given, is @option{-std=gnu++14}.
+no C++ language dialect options are given, is @option{-std=gnu++17}.
   @section Objective-C and Objective-C++ Languages
   @cindex Objective-C
diff --git a/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c 
b/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c
index bb5c91485d7..12779af5438 100644
--- a/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c
+++ b/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c
@@ -12,9 +12,9 @@ struct vec_s {
   int main () {
-  register short vector v0 = {1,2,3,4,5,6,7};
-  register myvec_t v1 = {1,2,3,4,5,6,7};
-  register struct vec_s v2;
+  short vector v0 = {1,2,3,4,5,6,7};
+  myvec_t v1 = {1,2,3,4,5,6,7};
+  struct vec_s v2;

I'd be careful about changing a c-c++-common torture test like this. Maybe
#define away register for C++17 and up, or add -Wno-register in C++ mode
like you do for other testcases?

Done.

     v2.member = v1;
diff --git a/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C 
b/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C
index aacfac875b1..4d7e547920f 100644
--- a/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C
+++ b/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C
@@ -1,5 +1,5 @@
-// This macro should not be defined without -std=c++17.
+// This macro should be defined with -std=c++17.
-#ifdef __cpp_enumerator_attributes
+#ifndef __cpp_enumerator_attributes

You're turning this file into the same test as attributes-enum-1.C, and it's
intended to be the complementary test.  Instead, restrict the test to
pre-C++17.

Indeed, that was sloppy.  This test (and the other) is now c++14_down.  It was
annoying to find out that only adding the target didn't suffice -- it seems
that dejagnu's proc check-flags happily accepts -std flags in comments too, so
it thought that we specified -std=c++17 and it didn't run the test in any other
mode.  Fixed by tweaking the comment...

   #error __cpp_enumerator_attributes defined
   #endif
diff --git a/gcc/testsuite/g++.dg/cpp1z/fold7a.C 
b/gcc/testsuite/g++.dg/cpp1z/fold7a.C
index 5c782ff0969..530741d3907 100644
--- a/gcc/testsuite/g++.dg/cpp1z/fold7a.C
+++ b/gcc/testsuite/g++.dg/cpp1z/fold7a.C
@@ -1,5 +1,5 @@
-// This macro should not be defined without -std=c++17.
+// This macro should be defined with -std=c++17.
-#ifdef __cpp_fold_expressions
+#ifndef __cpp_fold_expressions

Likewise.

^

   #error __cpp_fold_expressions defined
   #endif
diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype3a.C 
b/gcc/testsuite/g++.dg/cpp1z/nontype3a.C
index a704e5045b6..7b640e551b6 100644
--- a/gcc/testsuite/g++.dg/cpp1z/nontype3a.C
+++ b/gcc/testsuite/g++.dg/cpp1z/nontype3a.C
@@ -1,5 +1,5 @@
-// This macro should not be defined without -std=c++17.
+// This macro should be defined with -std=c++17.
-#ifdef __cpp_nontype_template_args
+#ifndef __cpp_nontype_template_args

Likewise.

^

   #error __cpp_nontype_template_args defined
   #endif
diff --git a/gcc/testsuite/g++.dg/cpp1z/utf8-2a.C 
b/gcc/testsuite/g++.dg/cpp1z/utf8-2a.C
index 0e243d68a75..c4a8f46fb7d 100644
--- a/gcc/testsuite/g++.dg/cpp1z/utf8-2a.C
+++ b/gcc/testsuite/g++.dg/cpp1z/utf8-2a.C
@@ -1,5 +1,5 @@
-// This macro should not be 201411 without -std=c++17.
+// This macro should be 201411 with -std=c++17.
-#if __cpp_unicode_characters == 201411
+#if __cpp_unicode_characters != 201411

Likewise.

^

   #error Wrong value for __cpp_unicode_characters
   #endif
diff --git a/gcc/testsuite/g++.dg/parse/error11.C 
b/gcc/testsuite/g++.dg/parse/error11.C
index 1a49d6edb12..4e2a7f8b75f 100644
--- a/gcc/testsuite/g++.dg/parse/error11.C
+++ b/gcc/testsuite/g++.dg/parse/error11.C
@@ -1,5 +1,6 @@
-// { dg-do compile }
-// { dg-options "-fshow-column" }"
+// { dg-do compile { target c++14_down } }
+// C++17 removed trigraphs.

There are no trigraphs in this testcase, and digraphs are still part of
C++20.

True.  In C++17 we issue slightly different diagnostics for lines 51 and 52,
and I thought it was so because trigraphs had been removed.

I think it's because of CTAD making a template-name without arguments potentially valid.

I've updated the expected error messages instead.  Is that acceptable?

I'm not sure they need to be so specific, but that's fine.

+// { dg-options "-fshow-column" }
   // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
   // Try to find out when the digraph '<:' is used as a mistake, and parse it
   //  correctly to avoid cascaded errors.
diff --git a/gcc/testsuite/g++.dg/torture/pr34850.C 
b/gcc/testsuite/g++.dg/torture/pr34850.C
index c4d808c5a0d..59dd5dfde7d 100644
--- a/gcc/testsuite/g++.dg/torture/pr34850.C
+++ b/gcc/testsuite/g++.dg/torture/pr34850.C
@@ -1,6 +1,6 @@
   /* { dg-do compile } */
   /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
-/* { dg-options "-ffat-lto-objects -Wno-return-type" } */
+/* { dg-options "-ffat-lto-objects -Wno-return-type -Wno-attribute-warning" } 
*/

Why?

Sorry, this was non-obvious.

This boils down to

void __warn_memset_zero_len() __attribute__((__warning__("")));
long b;
void foo() throw()
{
   if (__builtin_constant_p(b))
     __warn_memset_zero_len();
}
int bar() { foo(); }

In C++17, with -O2, we give

t.C:6:27: warning: call to '__warn_memset_zero_len' declared with attribute 
warning:  [-Wattribute-warning]
     6 |     __warn_memset_zero_len();

while in C++14 we don't.  We behave differently due to...

26006   /* In C++17, throw() is equivalent to noexcept (true).  throw()
26007      is deprecated in C++11 and above as well, but is still widely used,
26008      so don't warn about it yet.  */
26009   else if (cxx_dialect >= cxx17)
26010     type_id_list = noexcept_true_spec;
26011   else
26012     type_id_list = empty_except_spec;

...and different optimizations based on that.  In C++17, we inline foo, and
then CCP folds the __builtin_constant_p call and we end up with

bar () {
   __warn_memset_zero_len ();
   __builtin_unreachable ();
}

and since __warn_memset_zero_len is marked with the warning attribute,
expand_expr_real_1 warns.

In C++14 we don't inline foo, but VRP removes the code inside foo, DCE then
elides the call to foo completely, and we end up without the call to
__warn_memset_zero_len so we don't warn.

Note that bar misses a return statement, which can be UB at runtime.  This
doesn't strike me as a C++ FE issue.
   typedef unsigned char uint8_t;
   typedef unsigned int uint32_t;
diff --git a/gcc/testsuite/g++.dg/torture/pr49394.C 
b/gcc/testsuite/g++.dg/torture/pr49394.C
index 7bd8fd4dc72..32e1a98ce05 100644
--- a/gcc/testsuite/g++.dg/torture/pr49394.C
+++ b/gcc/testsuite/g++.dg/torture/pr49394.C
@@ -10,7 +10,7 @@ struct Mutex
   #endif
     {
       if (locked)
-      throw 0;
+      throw 0; // { dg-warning ".throw. will always call .terminate." "" { 
target c++17 } }

Instead, the destructor should be noexcept(false) in C++17 and up.

Fixed.

     }
     void lock ()
     {
diff --git a/gcc/testsuite/g++.dg/torture/pr82154.C 
b/gcc/testsuite/g++.dg/torture/pr82154.C
index e229c3e640e..698340d8c65 100644
--- a/gcc/testsuite/g++.dg/torture/pr82154.C
+++ b/gcc/testsuite/g++.dg/torture/pr82154.C
@@ -1,5 +1,6 @@
   // { dg-do compile }
-// { dg-additional-options "-Wno-deprecated" }
+// { dg-additional-options "-std=c++14 -Wno-deprecated" }
+// C++17 does not allow dynamic exception specification.
   namespace a {
   int b;
diff --git a/gcc/testsuite/g++.dg/ubsan/pr85029.C 
b/gcc/testsuite/g++.dg/ubsan/pr85029.C
index 07472af16a5..836ce69cc15 100644
--- a/gcc/testsuite/g++.dg/ubsan/pr85029.C
+++ b/gcc/testsuite/g++.dg/ubsan/pr85029.C
@@ -1,7 +1,7 @@
   // PR sanitizer/85029
   // { dg-do compile }
   // { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } }
-// { dg-options "-fsanitize=undefined" }
+// { dg-options "-fsanitize=undefined -Wno-register" }
   struct B {
     virtual B bar ();
diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-12.C 
b/gcc/testsuite/g++.dg/ubsan/vptr-12.C
index f23bbc3fd10..ce57ba87db0 100644
--- a/gcc/testsuite/g++.dg/ubsan/vptr-12.C
+++ b/gcc/testsuite/g++.dg/ubsan/vptr-12.C
@@ -1,6 +1,6 @@
   // { dg-do run }
   // { dg-shouldfail "ubsan" }
-// { dg-options "-fsanitize=vptr -fno-sanitize-recover=vptr" }
+// { dg-options "-fsanitize=vptr -fno-sanitize-recover=vptr 
-fstrong-eval-order=some" }

Why?  I can't see anything in this testcase that should be affected by
-fstrong-eval-order.

I think this points to a bug; I'd been meaning to come back to it but
apparently I never did.

I've investigated more now and opened https://gcc.gnu.org/PR95221 along with
my initial analysis.  I'm uncertain if this one should be a blocker for the
default change -- valid code should never hit it, after all --, though...

Fixed, you shouldn't need changes to the ubsan tests anymore.

   struct MyClass
   {
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 3e91a81dd5a..4191600fcd9 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -9018,7 +9018,7 @@ proc check_effective_target_c++ { } {
    return 0
   }
-set cxx_default "c++14"
+set cxx_default "c++17"
   # Check whether the current active language standard supports the features
   # of C++11/C++14 by checking for the presence of one of the -std flags.
   # This assumes that the default for the compiler is $cxx_default, and that
diff --git a/gcc/testsuite/obj-c++.dg/try-catch-9.mm 
b/gcc/testsuite/obj-c++.dg/try-catch-9.mm
index 73c7c991709..b2dc61b9989 100644
--- a/gcc/testsuite/obj-c++.dg/try-catch-9.mm
+++ b/gcc/testsuite/obj-c++.dg/try-catch-9.mm
@@ -6,7 +6,7 @@
   /* { dg-xfail-run-if "PR23616" { *-*-* } { "-fgnu-runtime" } { 
"-fnext-runtime" } } */
   /* { dg-xfail-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" 
"-fgnu-runtime" } { "" } }
   /* { dg-prune-output ".*internal compiler error.*" } */
-/* { dg-options "-fobjc-exceptions -O2" } */
+/* { dg-options "-fobjc-exceptions -O2 -Wno-register" } */
   #include "../objc-obj-c++-shared/TestsuiteObject.m"
   #include <stdlib.h>
diff --git a/libgomp/testsuite/libgomp.c++/atomic-3.C 
b/libgomp/testsuite/libgomp.c++/atomic-3.C
index f957b2fece5..c02532d3206 100644
--- a/libgomp/testsuite/libgomp.c++/atomic-3.C
+++ b/libgomp/testsuite/libgomp.c++/atomic-3.C
@@ -1,5 +1,6 @@
   // { dg-do run }
-// { dg-options "-Wno-deprecated" }
+// C++17 forbids ++ on bool.
+// { dg-options "-Wno-deprecated -std=gnu++14" }
   extern "C" void abort (void);
   bool v, x1, x2, x3, x4, x5, x6;
diff --git a/libgomp/testsuite/libgomp.c++/for-27.C 
b/libgomp/testsuite/libgomp.c++/for-27.C
index 7dca4305f85..d286346e63a 100644
--- a/libgomp/testsuite/libgomp.c++/for-27.C
+++ b/libgomp/testsuite/libgomp.c++/for-27.C
@@ -151,6 +151,12 @@ f4 (const I<int> &x, const I<int> &y)
       else if (results[i])                             \
         abort ()
+// FIXME: OpenMP seems to count on this being instantiated; the copy
+// constructor is called in functions fn2/fn3/fn4.  But in C++17 we
+// elide this copy constructor, so it's never been instantiated.  For
+// now instantiate it explicitly.

This sounds like a bug that needs to be fixed before the default can change.
I guess the openmp code needs to mark_used the copy constructor or the like.

...this makes sense.  I've opened https://gcc.gnu.org/PR95197 to handle this;
I think either Jakub or I should be able to fix it before long.

Bootstrapped/regtested on x86_64-pc-linux-gnu.

OK without the ubsan test changes once 95197 is fixed.

-- >8 --
Since GCC 9, C++17 support is no longer experimental.  It was too late
to change the default C++ dialect to C++17 in GCC 10, but I think now
it's time to pull the trigger (C++14 was made the default in GCC 6.1).
We're still missing two C++17 library features, but that shouldn't stop
us.  See
<https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017>
and
<https://gcc.gnu.org/projects/cxx-status.html#cxx17>
for the C++17 status.

I won't list all C++17 features here, but just a few heads-up:

- trigraphs were removed (hardly anyone cares, unless your keyboard is
   missing the # key),
- operator++(bool) was removed (so some tests now run in C++14 and down
   only),
- the keyword register was removed (some legacy code might trip on
   this),
- noexcept specification is now part of the type system and C++17 does
   not allow dynamic exception specifications anymore (the empty throw
   specification is still available, but it is deprecated),
- the evaluation order rules are different in C++17,
- static constexpr data members are now implicitly inline (which makes
   them definitions),
- C++17 requires guaranteed copy elision, meaning that a copy/move
   constructor call might be elided completely.  That means that if
   something relied on a constructor being instantiated via e.g. copying
   a function parameter, it might now fail.

I'll post an update for cxx-status.html and add a new caveat to changes.html
once this is in.

        * doc/invoke.texi (C Dialect Options): Adjust -std default for C++.
        * doc/standards.texi (C Language): Correct the default dialect.
        (C++ Language): Update the default for C++ to gnu++17.

        * c-opts.c (c_common_init_options): Default to gnu++17.

        * c-c++-common/torture/vector-subscript-3.c: In C++17, define away
        the keyword register.
        * g++.dg/cpp1z/attributes-enum-1a.C: Only run pre-C++17.
        * g++.dg/cpp1z/fold7a.C: Likewise.
        * g++.dg/cpp1z/nontype3a.C: Likewise.
        * g++.dg/cpp1z/utf8-2a.C: Likewise.
        * g++.dg/parse/error11.C: Update expected diagnostics for C++17.
        * g++.dg/torture/pr34850.C: Add -Wno-attribute-warning.
        * g++.dg/torture/pr49394.C: In C++17, use noexcept(false).
        * g++.dg/torture/pr82154.C: Use -std=c++14.
        * g++.dg/ubsan/pr85029.C: Use -Wno-register.
        * g++.dg/ubsan/vptr-12.C: Use -fstrong-eval-order=some.  Adjust
        dg-output.
        * lib/target-supports.exp: Set to C++17.
        * obj-c++.dg/try-catch-9.mm: Use -Wno-register.

        * testsuite/libgomp.c++/atomic-3.C: Use -std=gnu++14.
---
  gcc/c-family/c-opts.c                          |  4 ++--
  gcc/doc/invoke.texi                            |  2 +-
  gcc/doc/standards.texi                         |  4 ++--
  .../c-c++-common/torture/vector-subscript-3.c  |  3 +++
  .../g++.dg/cpp1z/attributes-enum-1a.C          |  3 ++-
  gcc/testsuite/g++.dg/cpp1z/fold7a.C            |  3 ++-
  gcc/testsuite/g++.dg/cpp1z/nontype3a.C         |  3 ++-
  gcc/testsuite/g++.dg/cpp1z/utf8-2a.C           |  3 ++-
  gcc/testsuite/g++.dg/parse/error11.C           | 18 +++++++++++-------
  gcc/testsuite/g++.dg/torture/pr34850.C         |  2 +-
  gcc/testsuite/g++.dg/torture/pr49394.C         |  2 ++
  gcc/testsuite/g++.dg/torture/pr82154.C         |  3 ++-
  gcc/testsuite/g++.dg/ubsan/pr85029.C           |  2 +-
  gcc/testsuite/g++.dg/ubsan/vptr-12.C           |  5 +++--
  gcc/testsuite/lib/target-supports.exp          |  2 +-
  gcc/testsuite/obj-c++.dg/try-catch-9.mm        |  2 +-
  libgomp/testsuite/libgomp.c++/atomic-3.C       |  3 ++-
  17 files changed, 40 insertions(+), 24 deletions(-)

diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 7695e88c130..5b266c06f3b 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -256,9 +256,9 @@ c_common_init_options (unsigned int decoded_options_count,
          }
      }
- /* Set C++ standard to C++14 if not specified on the command line. */
+  /* Set C++ standard to C++17 if not specified on the command line.  */
    if (c_dialect_cxx ())
-    set_std_cxx14 (/*ISO*/false);
+    set_std_cxx17 (/*ISO*/false);
global_dc->colorize_source_p = true;
  }
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 7217e27151d..c1acb8a70c2 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2057,7 +2057,6 @@ The name @samp{c++1y} is deprecated.
  @item gnu++14
  @itemx gnu++1y
  GNU dialect of @option{-std=c++14}.
-This is the default for C++ code.
  The name @samp{gnu++1y} is deprecated.
@item c++17
@@ -2068,6 +2067,7 @@ The name @samp{c++1z} is deprecated.
  @item gnu++17
  @itemx gnu++1z
  GNU dialect of @option{-std=c++17}.
+This is the default for C++ code.
  The name @samp{gnu++1z} is deprecated.
@item c++20
diff --git a/gcc/doc/standards.texi b/gcc/doc/standards.texi
index f39d8b378f1..fc5016028dd 100644
--- a/gcc/doc/standards.texi
+++ b/gcc/doc/standards.texi
@@ -130,7 +130,7 @@ select an extended version of the C language explicitly with
  extensions).
The default, if no C language dialect options are given,
-is @option{-std=gnu11}.
+is @option{-std=gnu17}.
The ISO C standard defines (in clause 4) two classes of conforming
  implementation.  A @dfn{conforming hosted implementation} supports the
@@ -246,7 +246,7 @@ select an extended version of the C++ language explicitly 
with
  @option{-std=gnu++17} (for C++17 with GNU extensions).
The default, if
-no C++ language dialect options are given, is @option{-std=gnu++14}.
+no C++ language dialect options are given, is @option{-std=gnu++17}.
@section Objective-C and Objective-C++ Languages
  @cindex Objective-C
diff --git a/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c 
b/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c
index bb5c91485d7..05d24f49011 100644
--- a/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c
+++ b/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c
@@ -10,6 +10,9 @@ struct vec_s {
      vector short member;
  };
+#if defined(__cplusplus) && __cplusplus >= 201703L
+#define register /* nothing */
+#endif
int main () {
    register short vector v0 = {1,2,3,4,5,6,7};
diff --git a/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C 
b/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C
index aacfac875b1..20f0b1d8876 100644
--- a/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C
+++ b/gcc/testsuite/g++.dg/cpp1z/attributes-enum-1a.C
@@ -1,4 +1,5 @@
-// This macro should not be defined without -std=c++17.
+// { dg-do compile { target c++14_down } }
+// This macro should not be defined without c++17.
#ifdef __cpp_enumerator_attributes
  #error __cpp_enumerator_attributes defined
diff --git a/gcc/testsuite/g++.dg/cpp1z/fold7a.C 
b/gcc/testsuite/g++.dg/cpp1z/fold7a.C
index 5c782ff0969..8cca8792709 100644
--- a/gcc/testsuite/g++.dg/cpp1z/fold7a.C
+++ b/gcc/testsuite/g++.dg/cpp1z/fold7a.C
@@ -1,4 +1,5 @@
-// This macro should not be defined without -std=c++17.
+// { dg-do compile { target c++14_down } }
+// This macro should not be defined without c++17.
#ifdef __cpp_fold_expressions
  #error __cpp_fold_expressions defined
diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype3a.C 
b/gcc/testsuite/g++.dg/cpp1z/nontype3a.C
index a704e5045b6..b3ffe037904 100644
--- a/gcc/testsuite/g++.dg/cpp1z/nontype3a.C
+++ b/gcc/testsuite/g++.dg/cpp1z/nontype3a.C
@@ -1,4 +1,5 @@
-// This macro should not be defined without -std=c++17.
+// { dg-do compile { target c++14_down } }
+// This macro should not be defined without c++17.
#ifdef __cpp_nontype_template_args
  #error __cpp_nontype_template_args defined
diff --git a/gcc/testsuite/g++.dg/cpp1z/utf8-2a.C 
b/gcc/testsuite/g++.dg/cpp1z/utf8-2a.C
index 0e243d68a75..b2a99a99023 100644
--- a/gcc/testsuite/g++.dg/cpp1z/utf8-2a.C
+++ b/gcc/testsuite/g++.dg/cpp1z/utf8-2a.C
@@ -1,4 +1,5 @@
-// This macro should not be 201411 without -std=c++17.
+// { dg-do compile { target c++14_down } }
+// This macro should not be 201411 without c++17.
#if __cpp_unicode_characters == 201411
  #error Wrong value for __cpp_unicode_characters
diff --git a/gcc/testsuite/g++.dg/parse/error11.C 
b/gcc/testsuite/g++.dg/parse/error11.C
index 1a49d6edb12..4baf97e531d 100644
--- a/gcc/testsuite/g++.dg/parse/error11.C
+++ b/gcc/testsuite/g++.dg/parse/error11.C
@@ -1,5 +1,5 @@
  // { dg-do compile }
-// { dg-options "-fshow-column" }"
+// { dg-options "-fshow-column" }
  // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
  // Try to find out when the digraph '<:' is used as a mistake, and parse it
  //  correctly to avoid cascaded errors.
@@ -50,12 +50,16 @@ void func(void)
    //  the special error message.
    Foo<: :B> k2;     // { dg-bogus "cannot begin|alternate spelling" "smart error 
should not be triggered here" }
    Foo[:B> k1;       // { dg-bogus "cannot begin|alternate spelling" "smart error 
should not be triggered here" }
-// { dg-error "6:missing template arguments before" "template" { target *-*-* 
} 51 }
-// { dg-error "9:expected primary-expression before ':' token" "primary" { 
target *-*-* } 51 }
-// { dg-error "8:expected '\]' before ':' token" "backslash" { target *-*-* } 
51 }
-// { dg-error "6:missing template arguments before" "template" { target *-*-* 
} 52 }
-// { dg-error "7:expected primary-expression before ':' token" "primary" { 
target *-*-* } 52 }
-// { dg-error "7:expected '\]' before ':' token" "backslash" { target *-*-* } 
52 }
+// { dg-error "6:missing template arguments before" "template" { target 
c++14_down } .-2 }
+// { dg-error "9:expected primary-expression before ':' token" "primary" { 
target c++14_down } .-3 }
+// { dg-error "8:expected '\]' before ':' token" "backslash" { target 
c++14_down } .-4 }
+// { dg-error "6:missing template arguments before" "template" { target 
c++14_down } .-4 }
+// { dg-error "7:expected primary-expression before ':' token" "primary" { 
target c++14_down } .-5 }
+// { dg-error "7:expected '\]' before ':' token" "backslash" { target 
c++14_down } .-6 }
+// { dg-error "9:expected identifier" "" { target c++17 } .-8 }
+// { dg-error "8:expected" "" { target c++17 } .-9 }
+// { dg-error "7:expected identifier" "" { target c++17 } .-9 }
+// { dg-error "7:expected" "" { target c++17 } .-10 }
  //
    int Foo[2];
    Foo[::value] = 0;
diff --git a/gcc/testsuite/g++.dg/torture/pr34850.C 
b/gcc/testsuite/g++.dg/torture/pr34850.C
index c4d808c5a0d..59dd5dfde7d 100644
--- a/gcc/testsuite/g++.dg/torture/pr34850.C
+++ b/gcc/testsuite/g++.dg/torture/pr34850.C
@@ -1,6 +1,6 @@
  /* { dg-do compile } */
  /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
-/* { dg-options "-ffat-lto-objects -Wno-return-type" } */
+/* { dg-options "-ffat-lto-objects -Wno-return-type -Wno-attribute-warning" } 
*/
typedef unsigned char uint8_t;
  typedef unsigned int uint32_t;
diff --git a/gcc/testsuite/g++.dg/torture/pr49394.C 
b/gcc/testsuite/g++.dg/torture/pr49394.C
index 7bd8fd4dc72..75901a5d668 100644
--- a/gcc/testsuite/g++.dg/torture/pr49394.C
+++ b/gcc/testsuite/g++.dg/torture/pr49394.C
@@ -7,6 +7,8 @@ struct Mutex
    ~Mutex ()
  #if __cplusplus <= 201402L
    throw(int)                  // { dg-warning "deprecated" "" { target { c++11 
&& { ! c++17 } } } }
+#else
+  noexcept(false)
  #endif
    {
      if (locked)
diff --git a/gcc/testsuite/g++.dg/torture/pr82154.C 
b/gcc/testsuite/g++.dg/torture/pr82154.C
index e229c3e640e..698340d8c65 100644
--- a/gcc/testsuite/g++.dg/torture/pr82154.C
+++ b/gcc/testsuite/g++.dg/torture/pr82154.C
@@ -1,5 +1,6 @@
  // { dg-do compile }
-// { dg-additional-options "-Wno-deprecated" }
+// { dg-additional-options "-std=c++14 -Wno-deprecated" }
+// C++17 does not allow dynamic exception specification.
namespace a {
  int b;
diff --git a/gcc/testsuite/g++.dg/ubsan/pr85029.C 
b/gcc/testsuite/g++.dg/ubsan/pr85029.C
index 07472af16a5..836ce69cc15 100644
--- a/gcc/testsuite/g++.dg/ubsan/pr85029.C
+++ b/gcc/testsuite/g++.dg/ubsan/pr85029.C
@@ -1,7 +1,7 @@
  // PR sanitizer/85029
  // { dg-do compile }
  // { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } }
-// { dg-options "-fsanitize=undefined" }
+// { dg-options "-fsanitize=undefined -Wno-register" }
struct B {
    virtual B bar ();
diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-12.C 
b/gcc/testsuite/g++.dg/ubsan/vptr-12.C
index f23bbc3fd10..79d4290754e 100644
--- a/gcc/testsuite/g++.dg/ubsan/vptr-12.C
+++ b/gcc/testsuite/g++.dg/ubsan/vptr-12.C
@@ -1,6 +1,7 @@
  // { dg-do run }
  // { dg-shouldfail "ubsan" }
-// { dg-options "-fsanitize=vptr -fno-sanitize-recover=vptr" }
+// { dg-options "-fsanitize=vptr -fno-sanitize-recover=vptr 
-fstrong-eval-order=some" }
+// FIXME: See PR95221 for why we use a specific eval order.
struct MyClass
  {
@@ -18,5 +19,5 @@ main ()
    return 0;
  }
-// { dg-output "\[^\n\r]*vptr-12.C:16:\[0-9]*: runtime error: member call on address 0x\[0-9a-fA-F]* which does not point to an object of type 'MyClass'(\n|\r\n|\r)" }
+// { dg-output "\[^\n\r]*vptr-12.C:17:\[0-9]*: runtime error: member call on 
address 0x\[0-9a-fA-F]* which does not point to an object of type 
'MyClass'(\n|\r\n|\r)" }
  // { dg-output "0x\[0-9a-fA-F]*: note: object has invalid vptr" }
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index b335108358d..58638a3e189 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -9046,7 +9046,7 @@ proc check_effective_target_c++ { } {
   return 0
  }
-set cxx_default "c++14"
+set cxx_default "c++17"
  # Check whether the current active language standard supports the features
  # of C++11/C++14 by checking for the presence of one of the -std flags.
  # This assumes that the default for the compiler is $cxx_default, and that
diff --git a/gcc/testsuite/obj-c++.dg/try-catch-9.mm 
b/gcc/testsuite/obj-c++.dg/try-catch-9.mm
index 73c7c991709..b2dc61b9989 100644
--- a/gcc/testsuite/obj-c++.dg/try-catch-9.mm
+++ b/gcc/testsuite/obj-c++.dg/try-catch-9.mm
@@ -6,7 +6,7 @@
  /* { dg-xfail-run-if "PR23616" { *-*-* } { "-fgnu-runtime" } { 
"-fnext-runtime" } } */
  /* { dg-xfail-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" 
"-fgnu-runtime" } { "" } }
  /* { dg-prune-output ".*internal compiler error.*" } */
-/* { dg-options "-fobjc-exceptions -O2" } */
+/* { dg-options "-fobjc-exceptions -O2 -Wno-register" } */
#include "../objc-obj-c++-shared/TestsuiteObject.m"
  #include <stdlib.h>
diff --git a/libgomp/testsuite/libgomp.c++/atomic-3.C 
b/libgomp/testsuite/libgomp.c++/atomic-3.C
index f957b2fece5..c02532d3206 100644
--- a/libgomp/testsuite/libgomp.c++/atomic-3.C
+++ b/libgomp/testsuite/libgomp.c++/atomic-3.C
@@ -1,5 +1,6 @@
  // { dg-do run }
-// { dg-options "-Wno-deprecated" }
+// C++17 forbids ++ on bool.
+// { dg-options "-Wno-deprecated -std=gnu++14" }
extern "C" void abort (void);
  bool v, x1, x2, x3, x4, x5, x6;

base-commit: a2d196e75cef95c2b70734ad02e94f9da0e769fe


Reply via email to