C++: more std header hints; filter on C++ dialect (PR c++/84269)
[official-gcc.git] / gcc / testsuite / g++.dg / lookup / missing-std-include-8.C
blob68b208299f2e2482a4bf1e228f35fd57f009465e
1 /* Verify that we don't offer #include suggestions for things that
2    aren't yet available due to the C++ dialect in use.  */
3 // { dg-do compile { target c++98_only } }
5 #include <memory>
7 template<class T>
8 void test_make_shared ()
10   std::make_shared<T>(); // { dg-error "'make_shared' is not a member of 'std'" }
11   // { dg-message "'std::make_shared' is only available from C\\+\\+11 onwards" "" { target *-*-* } .-1 }
12   // { dg-error "expected primary-expression before '>' token" "" { target *-*-* } .-2 }
13   // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 }
16 void test_array ()
18   std::array a; // { dg-error "'array' is not a member of 'std'" }
19   // { dg-message "'std::array' is only available from C\\+\\+11 onwards" "" { target *-*-* } .-1 }
22 void test_tuple ()
24   std::tuple<int,float> p; // { dg-error "'tuple' is not a member of 'std'" }
25   // { dg-message "'std::tuple' is only available from C\\+\\+11 onwards" "" { target *-*-* } .-1 }
26   // { dg-error "expected primary-expression before 'int'" "" { target *-*-* } .-2 }
29 /* Since C++14.  */
30 std::shared_timed_mutex m; // { dg-error "'shared_timed_mutex' in namespace 'std' does not name a type" }
31 // { dg-message "'std::shared_timed_mutex' is only available from C\\+\\+14 onwards" "" { target *-*-* } .-1 }
33 /* Since C++17: */
34 std::string_view sv; // { dg-error "'string_view' in namespace 'std' does not name a type" }
35 // { dg-message "'std::string_view' is only available from C\\+\\+17 onwards" "" { target *-*-* } .-1 }
37 /* Verify interaction with "using namespace std;".  */
38 using namespace std;
39 void test_via_using_directive ()
41   shared_ptr<int> p; // { dg-error "'shared_ptr' was not declared in this scope" }
42   // { dg-message "'std::shared_ptr' is only available from C\\+\\+11 onwards" "" { target *-*-* } .-1 }
43   // { dg-error "expected primary-expression before 'int'" "" { target *-*-* } .-2 }