On Sat, 2020-02-15 at 22:21 +0100, Jason Merrill wrote:
> It's probably past time for this, but definitely now that we're done
> with
> the final committee meeting of C++20.  This patch only adds the
> option and
> adjusts the testsuite to recognize it; more extensive changes can
> wait for
> the published standard.

I don't know if this is premature, or too piecemeal, but this patch
improves hints such as:
  note: 'std::source_location' is only available from C++2a onwards
to
  note: 'std::source_location' is only available from C++20 onwards

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.

OK for master?

gcc/cp/ChangeLog:
        * name-lookup.c (get_cxx_dialect_name): Return "C++20" for cxx2a.

gcc/testsuite/ChangeLog:
        * g++.dg/lookup/missing-std-include-8.C: Add test coverage for
        C++20 hints.
---
 gcc/cp/name-lookup.c                                | 2 +-
 gcc/testsuite/g++.dg/lookup/missing-std-include-8.C | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index e5638d2df91..7a87c3d2eb5 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -5856,7 +5856,7 @@ get_cxx_dialect_name (enum cxx_dialect dialect)
     case cxx17:
       return "C++17";
     case cxx2a:
-      return "C++2a";
+      return "C++20";
     }
 }
 
diff --git a/gcc/testsuite/g++.dg/lookup/missing-std-include-8.C 
b/gcc/testsuite/g++.dg/lookup/missing-std-include-8.C
index 73532c82968..716479761b4 100644
--- a/gcc/testsuite/g++.dg/lookup/missing-std-include-8.C
+++ b/gcc/testsuite/g++.dg/lookup/missing-std-include-8.C
@@ -43,6 +43,10 @@ std::shared_timed_mutex m; // { dg-error 
"'shared_timed_mutex' in namespace 'std
 std::string_view sv; // { dg-error "'string_view' in namespace 'std' does not 
name a type" }
 // { dg-message "'std::string_view' is only available from C\\+\\+17 onwards" 
"" { target *-*-* } .-1 }
 
+/* Since C++20: */
+std::source_location loc; // { dg-error "'source_location' in namespace 'std' 
does not name a type" }
+// { dg-message "'std::source_location' is only available from C\\+\\+20 
onwards" "" { target *-*-* } .-1 }
+
 /* Verify interaction with "using namespace std;".  */
 using namespace std;
 void test_via_using_directive ()
-- 
2.21.0

Reply via email to