]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/91436 fix C++ dialect for std::make_unique fix-it hint
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Aug 2019 19:52:58 +0000 (19:52 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Aug 2019 19:52:58 +0000 (19:52 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274492 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/missing-std-include-5.C
gcc/testsuite/g++.dg/lookup/missing-std-include-6.C
gcc/testsuite/g++.dg/lookup/missing-std-include-8.C

index 8fee0458fe9e5ab6fbdee50ca31044809d4f205f..9eeba3dadc337d2a8ef1d5e7a65caf17d6d6020b 100644 (file)
@@ -1,3 +1,9 @@
+2019-08-14  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR c++/91436
+       * name-lookup.c (get_std_name_hint): Fix min_dialect field for
+       complex_literals and make_unique entries.
+
 2019-08-14  Jakub Jelinek  <jakub@redhat.com>
            Marek Polacek  <polacek@redhat.com>
 
index d5e491e9072a34db0eba50b9726035794c2d4e0f..16c74287bb1c5dc10b880c9b4e179a18a7da8b17 100644 (file)
@@ -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},
index d7a3e6bfde763ae62f62f416e62ea7a4c9995bbb..33a9fc6d338356191ff725c339bbc0e42e707c56 100644 (file)
@@ -1,3 +1,11 @@
+2019-08-14  Jonathan Wakely  <jwakely@redhat.com>
+
+       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-14  Christophe Lyon  <christophe.lyon@linaro.org>
 
        * gcc.c-torture/execute/noinit-attribute.c: Fix typo.
index fe880a6263ba1e4a0587aeb92eaa0a4cb18b5daa..3ec9abd93165f771b31975fcadf461b0d6c92a82 100644 (file)
@@ -1,2 +1,3 @@
+// { dg-do compile { target c++14 } }
 using namespace std::complex_literals; // { dg-error "" }
 // { dg-message "#include <complex>" "" { target *-*-* } .-1 }
index d9eeb4284e8835244ca89303d82ab26c10ad2af4..a8f27473e6dc833da73b48027a2cd7e0c9acc788 100644 (file)
@@ -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 }
 
index 68b208299f2e2482a4bf1e228f35fd57f009465e..73532c82968099ca551a593a860ef95301948ccf 100644 (file)
@@ -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'" }