diff gcc/testsuite/g++.dg/lookup/missing-std-include-8.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children 1830386684a0
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/g++.dg/lookup/missing-std-include-8.C	Thu Oct 25 07:37:49 2018 +0900
@@ -0,0 +1,44 @@
+/* Verify that we don't offer #include suggestions for things that
+   aren't yet available due to the C++ dialect in use.  */
+// { dg-do compile { target c++98_only } }
+
+#include <memory>
+
+template<class T>
+void test_make_shared ()
+{
+  std::make_shared<T>(); // { dg-error "'make_shared' is not a member of 'std'" }
+  // { dg-message "'std::make_shared' is only available from C\\+\\+11 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'" }
+  // { dg-message "'std::array' is only available from C\\+\\+11 onwards" "" { target *-*-* } .-1 }
+}
+
+void test_tuple ()
+{
+  std::tuple<int,float> p; // { dg-error "'tuple' is not a member of 'std'" }
+  // { dg-message "'std::tuple' is only available from C\\+\\+11 onwards" "" { target *-*-* } .-1 }
+  // { dg-error "expected primary-expression before 'int'" "" { target *-*-* } .-2 }
+}
+
+/* Since C++14.  */
+std::shared_timed_mutex m; // { dg-error "'shared_timed_mutex' in namespace 'std' does not name a type" }
+// { dg-message "'std::shared_timed_mutex' is only available from C\\+\\+14 onwards" "" { target *-*-* } .-1 }
+
+/* Since C++17: */
+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 }
+
+/* Verify interaction with "using namespace std;".  */
+using namespace std;
+void test_via_using_directive ()
+{
+  shared_ptr<int> p; // { dg-error "'shared_ptr' was not declared in this scope" }
+  // { dg-message "'std::shared_ptr' is only available from C\\+\\+11 onwards" "" { target *-*-* } .-1 }
+  // { dg-error "expected primary-expression before 'int'" "" { target *-*-* } .-2 }
+}