From 10e3d230ddb1cf6311ece9d90d84b9d24843e718 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 14 Aug 2019 21:10:00 +0100 Subject: [PATCH] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint The std::make_unique function wasn't added until C++14, and neither was the std::complex_literals namespace. gcc/cp: PR c++/91436 * name-lookup.c (get_std_name_hint): Fix min_dialect field for complex_literals and make_unique entries. gcc/testsuite: PR c++/91436 * g++.dg/lookup/missing-std-include-5.C: Limit test to C++14 and up. * g++.dg/lookup/missing-std-include-6.C: Don't check make_unique in test that runs for C++11. * g++.dg/lookup/missing-std-include-8.C: Check make_unique here. From-SVN: r274493 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/name-lookup.c | 4 ++-- gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/g++.dg/lookup/missing-std-include-5.C | 1 + gcc/testsuite/g++.dg/lookup/missing-std-include-6.C | 9 --------- gcc/testsuite/g++.dg/lookup/missing-std-include-8.C | 9 +++++++++ 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 925341d5d473..307f1e6b032d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-08-14 Jonathan Wakely + + PR c++/91436 + * name-lookup.c (get_std_name_hint): Fix min_dialect field for + complex_literals and make_unique entries. + 2019-08-12 Tom Honermann * parser.c (cp_parser_template_declaration_after_parameters): Enable diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 4ca976c812d8..29004d920b10 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -5656,7 +5656,7 @@ get_std_name_hint (const char *name) {"bitset", "", cxx11}, /* . */ {"complex", "", cxx98}, - {"complex_literals", "", cxx98}, + {"complex_literals", "", cxx14}, /* . */ {"condition_variable", "", cxx11}, {"condition_variable_any", "", cxx11}, @@ -5718,7 +5718,7 @@ get_std_name_hint (const char *name) {"multimap", "", cxx98}, /* . */ {"make_shared", "", cxx11}, - {"make_unique", "", cxx11}, + {"make_unique", "", cxx14}, {"shared_ptr", "", cxx11}, {"unique_ptr", "", cxx11}, {"weak_ptr", "", cxx11}, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 111c5ace0651..255786692a08 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2019-08-14 Jonathan Wakely + + PR c++/91436 + * g++.dg/lookup/missing-std-include-5.C: Limit test to C++14 and up. + * g++.dg/lookup/missing-std-include-6.C: Don't check make_unique in + test that runs for C++11. + * g++.dg/lookup/missing-std-include-8.C: Check make_unique here. + 2019-08-13 Steven G. Kargl PR fortran/87991 diff --git a/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C b/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C index fe880a6263ba..3ec9abd93165 100644 --- a/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C +++ b/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C @@ -1,2 +1,3 @@ +// { dg-do compile { target c++14 } } using namespace std::complex_literals; // { dg-error "" } // { dg-message "#include " "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C b/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C index d9eeb4284e88..a8f27473e6dc 100644 --- a/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C +++ b/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C @@ -11,15 +11,6 @@ void test_make_shared () // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 } } -template -void test_make_unique () -{ - auto p = std::make_unique(); // { dg-error "'make_unique' is not a member of 'std'" } - // { dg-message "'#include '" "" { target *-*-* } .-1 } - // { dg-error "expected primary-expression before '>' token" "" { target *-*-* } .-2 } - // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 } -} - std::shared_ptr test_shared_ptr; // { dg-error "'shared_ptr' in namespace 'std' does not name a template type" } // { dg-message "'#include '" "" { target *-*-* } .-1 } 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 68b208299f2e..73532c829680 100644 --- a/gcc/testsuite/g++.dg/lookup/missing-std-include-8.C +++ b/gcc/testsuite/g++.dg/lookup/missing-std-include-8.C @@ -13,6 +13,15 @@ void test_make_shared () // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 } } +template +void test_make_unique () +{ + std::make_unique(); // { dg-error "'make_unique' is not a member of 'std'" } + // { dg-message "'std::make_unique' is only available from C\\+\\+14 onwards" "" { target *-*-* } .-1 } + // { dg-error "expected primary-expression before '>' token" "" { target *-*-* } .-2 } + // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 } +} + void test_array () { std::array a; // { dg-error "'array' is not a member of 'std'" } -- 2.47.2