* [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint
@ 2019-08-13 13:39 Jonathan Wakely
2019-08-13 13:43 ` [PATCH 2/2] Add more entries to the C++ get_std_name_hint array Jonathan Wakely
2019-08-13 20:20 ` [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint Jason Merrill
0 siblings, 2 replies; 11+ messages in thread
From: Jonathan Wakely @ 2019-08-13 13:39 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill, Nathan Sidwell, David Malcolm
[-- Attachment #1: Type: text/plain, Size: 476 bytes --]
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.
Tested x86_64-linux. OK for trunk?
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3109 bytes --]
commit b58e771fe21ae380200fdec00aa899d4b15b73d5
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Aug 13 13:25:39 2019 +0100
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.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 9f278220df3..96b2d90540d 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -5557,7 +5557,7 @@ get_std_name_hint (const char *name)
{"bitset", "<bitset>", cxx11},
/* <complex>. */
{"complex", "<complex>", cxx98},
- {"complex_literals", "<complex>", cxx98},
+ {"complex_literals", "<complex>", cxx14},
/* <condition_variable>. */
{"condition_variable", "<condition_variable>", cxx11},
{"condition_variable_any", "<condition_variable>", cxx11},
@@ -5619,7 +5619,7 @@ get_std_name_hint (const char *name)
{"multimap", "<map>", cxx98},
/* <memory>. */
{"make_shared", "<memory>", cxx11},
- {"make_unique", "<memory>", cxx11},
+ {"make_unique", "<memory>", cxx14},
{"shared_ptr", "<memory>", cxx11},
{"unique_ptr", "<memory>", cxx11},
{"weak_ptr", "<memory>", cxx11},
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 fe880a6263b..3ec9abd9316 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 <complex>" "" { 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 d9eeb4284e8..a8f27473e6d 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<class T>
-void test_make_unique ()
-{
- auto p = std::make_unique<T>(); // { dg-error "'make_unique' is not a member of 'std'" }
- // { dg-message "'#include <memory>'" "" { target *-*-* } .-1 }
- // { dg-error "expected primary-expression before '>' token" "" { target *-*-* } .-2 }
- // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 }
-}
-
std::shared_ptr<int> test_shared_ptr; // { dg-error "'shared_ptr' in namespace 'std' does not name a template type" }
// { dg-message "'#include <memory>'" "" { target *-*-* } .-1 }
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/2] Add more entries to the C++ get_std_name_hint array
2019-08-13 13:39 [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint Jonathan Wakely
@ 2019-08-13 13:43 ` Jonathan Wakely
2019-08-13 20:44 ` Jason Merrill
2019-08-13 20:20 ` [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint Jason Merrill
1 sibling, 1 reply; 11+ messages in thread
From: Jonathan Wakely @ 2019-08-13 13:43 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill, Nathan Sidwell, David Malcolm
[-- Attachment #1: Type: text/plain, Size: 293 bytes --]
This adds some commonly-used C++11/14 names, and some new C++17/20
names. The latter aren't available when using the -std=gnu++14
default, so the fix-it suggesting to use a newer dialect is helpful.
* name-lookup.c (get_std_name_hint): Add more entries.
Tested x86_64-linux. OK for trunk?
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 3894 bytes --]
commit 0c12d092e5659689951b5e134b84c5b506b543d5
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Aug 13 13:42:40 2019 +0100
Add more entries to the C++ get_std_name_hint array
* name-lookup.c (get_std_name_hint): Add more entries.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 96b2d90540d..68ebd7655c7 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -5550,9 +5550,11 @@ get_std_name_hint (const char *name)
{"make_any", "<any>", cxx17},
/* <array>. */
{"array", "<array>", cxx11},
+ {"to_array", "<array>", cxx2a},
/* <atomic>. */
{"atomic", "<atomic>", cxx11},
{"atomic_flag", "<atomic>", cxx11},
+ {"atomic_ref", "<atomic>", cxx2a},
/* <bitset>. */
{"bitset", "<bitset>", cxx11},
/* <complex>. */
@@ -5575,9 +5577,17 @@ get_std_name_hint (const char *name)
{"ofstream", "<fstream>", cxx98},
/* <functional>. */
{"bind", "<functional>", cxx11},
+ {"bind_front", "<functional>", cxx2a},
{"function", "<functional>", cxx11},
{"hash", "<functional>", cxx11},
+ {"invoke", "<functional>", cxx17},
{"mem_fn", "<functional>", cxx11},
+ {"not_fn", "<functional>", cxx17},
+ {"reference_wrapper", "<functional>", cxx11},
+ {"unwrap_reference", "<functional>", cxx2a},
+ {"unwrap_reference_t", "<functional>", cxx2a},
+ {"unwrap_ref_decay", "<functional>", cxx2a},
+ {"unwrap_ref_decay_t", "<functional>", cxx2a},
/* <future>. */
{"async", "<future>", cxx11},
{"future", "<future>", cxx11},
@@ -5618,11 +5628,16 @@ get_std_name_hint (const char *name)
{"map", "<map>", cxx98},
{"multimap", "<map>", cxx98},
/* <memory>. */
+ {"allocate_shared", "<memory>", cxx11},
+ {"allocator", "<memory>", cxx98},
+ {"allocator_traits", "<memory>", cxx11},
{"make_shared", "<memory>", cxx11},
{"make_unique", "<memory>", cxx14},
{"shared_ptr", "<memory>", cxx11},
{"unique_ptr", "<memory>", cxx11},
{"weak_ptr", "<memory>", cxx11},
+ /* <memory_resource>. */
+ {"pmr", "<memory_resource>", cxx17},
/* <mutex>. */
{"mutex", "<mutex>", cxx11},
{"timed_mutex", "<mutex>", cxx11},
@@ -5672,14 +5687,39 @@ get_std_name_hint (const char *name)
{"u16string", "<string>", cxx11},
{"u32string", "<string>", cxx11},
/* <string_view>. */
+ {"basic_string_view", "<string_view>", cxx17},
{"string_view", "<string_view>", cxx17},
/* <thread>. */
{"thread", "<thread>", cxx11},
+ {"this_thread", "<thread>", cxx11},
/* <tuple>. */
+ {"apply", "<tuple>", cxx17},
+ {"forward_as_tuple", "<tuple>", cxx11},
+ {"make_from_tuple", "<tuple>", cxx17},
{"make_tuple", "<tuple>", cxx11},
+ {"tie", "<tuple>", cxx11},
{"tuple", "<tuple>", cxx11},
+ {"tuple_cat", "<tuple>", cxx11},
{"tuple_element", "<tuple>", cxx11},
+ {"tuple_element_t", "<tuple>", cxx14},
{"tuple_size", "<tuple>", cxx11},
+ {"tuple_size_v", "<tuple>", cxx17},
+ /* <type_traits>. */
+ {"enable_if", "<type_traits>", cxx11},
+ {"enable_if_t", "<type_traits>", cxx14},
+ {"invoke_result", "<type_traits>", cxx17},
+ {"invoke_result_t", "<type_traits>", cxx17},
+ {"remove_cvref", "<type_traits>", cxx17},
+ {"remove_cvref_t", "<type_traits>", cxx17},
+ {"type_identity", "<type_traits>", cxx2a},
+ {"type_identity_t", "<type_traits>", cxx2a},
+ {"void_t", "<type_traits>", cxx17},
+ {"conjunction", "<type_traits>", cxx17},
+ {"conjunction_v", "<type_traits>", cxx17},
+ {"disjunction", "<type_traits>", cxx17},
+ {"disjunction_v", "<type_traits>", cxx17},
+ {"negation", "<type_traits>", cxx17},
+ {"negation_v", "<type_traits>", cxx17},
/* <unordered_map>. */
{"unordered_map", "<unordered_map>", cxx11},
{"unordered_multimap", "<unordered_map>", cxx11},
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint
2019-08-13 13:39 [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint Jonathan Wakely
2019-08-13 13:43 ` [PATCH 2/2] Add more entries to the C++ get_std_name_hint array Jonathan Wakely
@ 2019-08-13 20:20 ` Jason Merrill
2019-08-14 11:16 ` Jonathan Wakely
1 sibling, 1 reply; 11+ messages in thread
From: Jason Merrill @ 2019-08-13 20:20 UTC (permalink / raw)
To: Jonathan Wakely, gcc-patches; +Cc: Nathan Sidwell, David Malcolm
On 8/13/19 9:32 AM, Jonathan Wakely wrote:
> Â Â Â Â * g++.dg/lookup/missing-std-include-6.C: Don't check make_unique in
> Â Â Â Â test that runs for C++11.
I'm not comfortable removing this test coverage entirely. Doesn't it
give a useful diagnostic in C++11 mode as well?
Jason
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] Add more entries to the C++ get_std_name_hint array
2019-08-13 13:43 ` [PATCH 2/2] Add more entries to the C++ get_std_name_hint array Jonathan Wakely
@ 2019-08-13 20:44 ` Jason Merrill
2019-08-14 10:50 ` Jonathan Wakely
0 siblings, 1 reply; 11+ messages in thread
From: Jason Merrill @ 2019-08-13 20:44 UTC (permalink / raw)
To: Jonathan Wakely, gcc-patches; +Cc: Nathan Sidwell, David Malcolm
On 8/13/19 9:36 AM, Jonathan Wakely wrote:
> This adds some commonly-used C++11/14 names, and some new C++17/20
> names. The latter aren't available when using the -std=gnu++14
> default, so the fix-it suggesting to use a newer dialect is helpful.
>
> Â Â Â Â * name-lookup.c (get_std_name_hint): Add more entries.
>
> Tested x86_64-linux. OK for trunk?
>
OK.
Jason
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] Add more entries to the C++ get_std_name_hint array
2019-08-13 20:44 ` Jason Merrill
@ 2019-08-14 10:50 ` Jonathan Wakely
0 siblings, 0 replies; 11+ messages in thread
From: Jonathan Wakely @ 2019-08-14 10:50 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches, Nathan Sidwell, David Malcolm
On 13/08/19 16:08 -0400, Jason Merrill wrote:
>On 8/13/19 9:36 AM, Jonathan Wakely wrote:
>>This adds some commonly-used C++11/14 names, and some new C++17/20
>>names. The latter aren't available when using the -std=gnu++14
>>default, so the fix-it suggesting to use a newer dialect is helpful.
>>
>> Â Â Â Â * name-lookup.c (get_std_name_hint): Add more entries.
>>
>>Tested x86_64-linux. OK for trunk?
>>
>OK.
I realised as I was about to commit it that cxx17 is the wrong dialect
for remove_cvref and remove_cvref_t, so I corrected them to cxx2a
before committing it.
(I've tried to use remove_cvref_t in C++17 a few times, so this
diagnostic should help me!)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint
2019-08-13 20:20 ` [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint Jason Merrill
@ 2019-08-14 11:16 ` Jonathan Wakely
2019-08-14 14:40 ` Jason Merrill
2019-08-14 14:42 ` David Malcolm
0 siblings, 2 replies; 11+ messages in thread
From: Jonathan Wakely @ 2019-08-14 11:16 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches, Nathan Sidwell, David Malcolm
[-- Attachment #1: Type: text/plain, Size: 983 bytes --]
On 13/08/19 16:07 -0400, Jason Merrill wrote:
>On 8/13/19 9:32 AM, Jonathan Wakely wrote:
>> Â Â Â Â * g++.dg/lookup/missing-std-include-6.C: Don't check make_unique in
>> Â Â Â Â test that runs for C++11.
>
>I'm not comfortable removing this test coverage entirely. Doesn't it
>give a useful diagnostic in C++11 mode as well?
It does:
mu.cc:3:15: error: 'make_unique' is not a member of 'std'
3 | auto p = std::make_unique<int>();
| ^~~~~~~~~~~
mu.cc:3:15: note: 'std::make_unique' is only available from C++14 onwards
mu.cc:3:27: error: expected primary-expression before 'int'
3 | auto p = std::make_unique<int>();
| ^~~
So we can add it to g++.dg/lookup/missing-std-include-8.C instead,
which runs for c++98_only and checks for the "is only available for"
cases. Here's a patch doing that.
Tested x86_64-linux.
OK for trunk?
OK for gcc-9-branch and gcc-8-branch too, since PR c++/91436 affects
those branches?
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 4144 bytes --]
commit 5ad7b3202e4818f2d6d84e22e7e489b39a65c851
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Aug 13 13:25:39 2019 +0100
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.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index d5e491e9072..16c74287bb1 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -5559,7 +5559,7 @@ get_std_name_hint (const char *name)
{"bitset", "<bitset>", cxx11},
/* <complex>. */
{"complex", "<complex>", cxx98},
- {"complex_literals", "<complex>", cxx98},
+ {"complex_literals", "<complex>", cxx14},
/* <condition_variable>. */
{"condition_variable", "<condition_variable>", cxx11},
{"condition_variable_any", "<condition_variable>", cxx11},
@@ -5632,7 +5632,7 @@ get_std_name_hint (const char *name)
{"allocator", "<memory>", cxx98},
{"allocator_traits", "<memory>", cxx11},
{"make_shared", "<memory>", cxx11},
- {"make_unique", "<memory>", cxx11},
+ {"make_unique", "<memory>", cxx14},
{"shared_ptr", "<memory>", cxx11},
{"unique_ptr", "<memory>", cxx11},
{"weak_ptr", "<memory>", cxx11},
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 fe880a6263b..3ec9abd9316 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 <complex>" "" { 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 d9eeb4284e8..a8f27473e6d 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<class T>
-void test_make_unique ()
-{
- auto p = std::make_unique<T>(); // { dg-error "'make_unique' is not a member of 'std'" }
- // { dg-message "'#include <memory>'" "" { target *-*-* } .-1 }
- // { dg-error "expected primary-expression before '>' token" "" { target *-*-* } .-2 }
- // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 }
-}
-
std::shared_ptr<int> test_shared_ptr; // { dg-error "'shared_ptr' in namespace 'std' does not name a template type" }
// { dg-message "'#include <memory>'" "" { 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 68b208299f2..73532c82968 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<class T>
+void test_make_unique ()
+{
+ std::make_unique<T>(); // { 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'" }
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint
2019-08-14 11:16 ` Jonathan Wakely
@ 2019-08-14 14:40 ` Jason Merrill
2019-08-14 14:42 ` David Malcolm
1 sibling, 0 replies; 11+ messages in thread
From: Jason Merrill @ 2019-08-14 14:40 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: gcc-patches List, Nathan Sidwell, David Malcolm
On Wed, Aug 14, 2019 at 7:02 AM Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On 13/08/19 16:07 -0400, Jason Merrill wrote:
> >On 8/13/19 9:32 AM, Jonathan Wakely wrote:
> >> * g++.dg/lookup/missing-std-include-6.C: Don't check make_unique in
> >> test that runs for C++11.
> >
> >I'm not comfortable removing this test coverage entirely. Doesn't it
> >give a useful diagnostic in C++11 mode as well?
>
> It does:
>
> mu.cc:3:15: error: 'make_unique' is not a member of 'std'
> 3 | auto p = std::make_unique<int>();
> | ^~~~~~~~~~~
> mu.cc:3:15: note: 'std::make_unique' is only available from C++14 onwards
> mu.cc:3:27: error: expected primary-expression before 'int'
> 3 | auto p = std::make_unique<int>();
> | ^~~
>
> So we can add it to g++.dg/lookup/missing-std-include-8.C instead,
> which runs for c++98_only and checks for the "is only available for"
> cases. Here's a patch doing that.
>
> Tested x86_64-linux.
>
> OK for trunk?
>
> OK for gcc-9-branch and gcc-8-branch too, since PR c++/91436 affects
> those branches?
OK.
Jason
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint
2019-08-14 11:16 ` Jonathan Wakely
2019-08-14 14:40 ` Jason Merrill
@ 2019-08-14 14:42 ` David Malcolm
2019-08-14 15:06 ` Jason Merrill
2019-08-14 16:02 ` Jonathan Wakely
1 sibling, 2 replies; 11+ messages in thread
From: David Malcolm @ 2019-08-14 14:42 UTC (permalink / raw)
To: Jonathan Wakely, Jason Merrill; +Cc: gcc-patches, Nathan Sidwell
On Wed, 2019-08-14 at 12:02 +0100, Jonathan Wakely wrote:
> On 13/08/19 16:07 -0400, Jason Merrill wrote:
> > On 8/13/19 9:32 AM, Jonathan Wakely wrote:
> > > * g++.dg/lookup/missing-std-include-6.C: Don't check
> > > make_unique in
> > > test that runs for C++11.
> >
> > I'm not comfortable removing this test coverage entirely. Doesn't
> > it
> > give a useful diagnostic in C++11 mode as well?
>
> It does:
>
> mu.cc:3:15: error: 'make_unique' is not a member of 'std'
> 3 | auto p = std::make_unique<int>();
> | ^~~~~~~~~~~
> mu.cc:3:15: note: 'std::make_unique' is only available from C++14
> onwards
> mu.cc:3:27: error: expected primary-expression before 'int'
> 3 | auto p = std::make_unique<int>();
> | ^~~
>
> So we can add it to g++.dg/lookup/missing-std-include-8.C instead,
> which runs for c++98_only and checks for the "is only available for"
> cases. Here's a patch doing that.
FWIW this eliminates the testing that when we do have C++14 onwards,
that including <memory> is suggested.
Maybe we need a C++14-onwards missing-std-include-* test, and to move
the existing test there? (and to add the new test for before-C++-14)
> Tested x86_64-linux.
>
> OK for trunk?
>
> OK for gcc-9-branch and gcc-8-branch too, since PR c++/91436 affects
> those branches?
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint
2019-08-14 14:42 ` David Malcolm
@ 2019-08-14 15:06 ` Jason Merrill
2019-08-14 16:02 ` Jonathan Wakely
1 sibling, 0 replies; 11+ messages in thread
From: Jason Merrill @ 2019-08-14 15:06 UTC (permalink / raw)
To: David Malcolm, Jonathan Wakely; +Cc: gcc-patches, Nathan Sidwell
On 8/14/19 10:39 AM, David Malcolm wrote:
> On Wed, 2019-08-14 at 12:02 +0100, Jonathan Wakely wrote:
>> On 13/08/19 16:07 -0400, Jason Merrill wrote:
>>> On 8/13/19 9:32 AM, Jonathan Wakely wrote:
>>>> * g++.dg/lookup/missing-std-include-6.C: Don't check
>>>> make_unique in
>>>> test that runs for C++11.
>>>
>>> I'm not comfortable removing this test coverage entirely. Doesn't
>>> it
>>> give a useful diagnostic in C++11 mode as well?
>>
>> It does:
>>
>> mu.cc:3:15: error: 'make_unique' is not a member of 'std'
>> 3 | auto p = std::make_unique<int>();
>> | ^~~~~~~~~~~
>> mu.cc:3:15: note: 'std::make_unique' is only available from C++14
>> onwards
>> mu.cc:3:27: error: expected primary-expression before 'int'
>> 3 | auto p = std::make_unique<int>();
>> | ^~~
>>
>> So we can add it to g++.dg/lookup/missing-std-include-8.C instead,
>> which runs for c++98_only and checks for the "is only available for"
>> cases. Here's a patch doing that.
>
> FWIW this eliminates the testing that when we do have C++14 onwards,
> that including <memory> is suggested.
>
> Maybe we need a C++14-onwards missing-std-include-* test, and to move
> the existing test there? (and to add the new test for before-C++-14)
We can also check for different messages in different std modes, i.e.
{ dg-message "one" "" { target c++11_down } .-1 }
{ dg-message "two" "" { target c++14 } .-2 }
Jason
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint
2019-08-14 14:42 ` David Malcolm
2019-08-14 15:06 ` Jason Merrill
@ 2019-08-14 16:02 ` Jonathan Wakely
2019-08-14 17:58 ` David Malcolm
1 sibling, 1 reply; 11+ messages in thread
From: Jonathan Wakely @ 2019-08-14 16:02 UTC (permalink / raw)
To: David Malcolm; +Cc: Jason Merrill, gcc-patches, Nathan Sidwell
On 14/08/19 10:39 -0400, David Malcolm wrote:
>On Wed, 2019-08-14 at 12:02 +0100, Jonathan Wakely wrote:
>> On 13/08/19 16:07 -0400, Jason Merrill wrote:
>> > On 8/13/19 9:32 AM, Jonathan Wakely wrote:
>> > > * g++.dg/lookup/missing-std-include-6.C: Don't check
>> > > make_unique in
>> > > test that runs for C++11.
>> >
>> > I'm not comfortable removing this test coverage entirely. Doesn't
>> > it
>> > give a useful diagnostic in C++11 mode as well?
>>
>> It does:
>>
>> mu.cc:3:15: error: 'make_unique' is not a member of 'std'
>> 3 | auto p = std::make_unique<int>();
>> | ^~~~~~~~~~~
>> mu.cc:3:15: note: 'std::make_unique' is only available from C++14
>> onwards
>> mu.cc:3:27: error: expected primary-expression before 'int'
>> 3 | auto p = std::make_unique<int>();
>> | ^~~
>>
>> So we can add it to g++.dg/lookup/missing-std-include-8.C instead,
>> which runs for c++98_only and checks for the "is only available for"
>> cases. Here's a patch doing that.
>
>FWIW this eliminates the testing that when we do have C++14 onwards,
>that including <memory> is suggested.
Do we really care?
Are we testing that *every* entry in the array gives the right answer
for both missing-header and bad-std-option, or are we just testing a
subset of them to be sure the logic works as expected?
Because if we're testing every entry then:
1) we're missing LOTS of tests, and
2) we're just as likely to test the wrong thing and not actually catch
bugs (as was already happening for both make_unique and
complex_literals).
>Maybe we need a C++14-onwards missing-std-include-* test, and to move
>the existing test there? (and to add the new test for before-C++-14)
We could, but is it worth it?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint
2019-08-14 16:02 ` Jonathan Wakely
@ 2019-08-14 17:58 ` David Malcolm
0 siblings, 0 replies; 11+ messages in thread
From: David Malcolm @ 2019-08-14 17:58 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Jason Merrill, gcc-patches, Nathan Sidwell
On Wed, 2019-08-14 at 16:53 +0100, Jonathan Wakely wrote:
> On 14/08/19 10:39 -0400, David Malcolm wrote:
> > On Wed, 2019-08-14 at 12:02 +0100, Jonathan Wakely wrote:
> > > On 13/08/19 16:07 -0400, Jason Merrill wrote:
> > > > On 8/13/19 9:32 AM, Jonathan Wakely wrote:
> > > > > * g++.dg/lookup/missing-std-include-6.C: Don't check
> > > > > make_unique in
> > > > > test that runs for C++11.
> > > >
> > > > I'm not comfortable removing this test coverage
> > > > entirely. Doesn't
> > > > it
> > > > give a useful diagnostic in C++11 mode as well?
> > >
> > > It does:
> > >
> > > mu.cc:3:15: error: 'make_unique' is not a member of 'std'
> > > 3 | auto p = std::make_unique<int>();
> > > | ^~~~~~~~~~~
> > > mu.cc:3:15: note: 'std::make_unique' is only available from C++14
> > > onwards
> > > mu.cc:3:27: error: expected primary-expression before 'int'
> > > 3 | auto p = std::make_unique<int>();
> > > | ^~~
> > >
> > > So we can add it to g++.dg/lookup/missing-std-include-8.C
> > > instead,
> > > which runs for c++98_only and checks for the "is only available
> > > for"
> > > cases. Here's a patch doing that.
> >
> > FWIW this eliminates the testing that when we do have C++14
> > onwards,
> > that including <memory> is suggested.
>
> Do we really care?
>
> Are we testing that *every* entry in the array gives the right answer
> for both missing-header and bad-std-option, or are we just testing a
> subset of them to be sure the logic works as expected?
>
> Because if we're testing every entry then:
>
> 1) we're missing LOTS of tests, and
>
> 2) we're just as likely to test the wrong thing and not actually
> catch
> bugs (as was already happening for both make_unique and
> complex_literals).
>
> > Maybe we need a C++14-onwards missing-std-include-* test, and to
> > move
> > the existing test there? (and to add the new test for before-C++-
> > 14)
>
> We could, but is it worth it?
Fair enough.
Dave
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-08-14 17:48 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-13 13:39 [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint Jonathan Wakely
2019-08-13 13:43 ` [PATCH 2/2] Add more entries to the C++ get_std_name_hint array Jonathan Wakely
2019-08-13 20:44 ` Jason Merrill
2019-08-14 10:50 ` Jonathan Wakely
2019-08-13 20:20 ` [PATCH 1/2] PR c++/91436 fix C++ dialect for std::make_unique fix-it hint Jason Merrill
2019-08-14 11:16 ` Jonathan Wakely
2019-08-14 14:40 ` Jason Merrill
2019-08-14 14:42 ` David Malcolm
2019-08-14 15:06 ` Jason Merrill
2019-08-14 16:02 ` Jonathan Wakely
2019-08-14 17:58 ` David Malcolm
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).