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 } }
4 
5 #include <memory>
6 
7 template<class T>
test_make_shared()8 void test_make_shared ()
9 {
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 }
14 }
15 
16 template<class T>
test_make_unique()17 void test_make_unique ()
18 {
19   std::make_unique<T>(); // { dg-error "'make_unique' is not a member of 'std'" }
20   // { dg-message "'std::make_unique' is only available from C\\+\\+14 onwards" "" { target *-*-* } .-1 }
21   // { dg-error "expected primary-expression before '>' token" "" { target *-*-* } .-2 }
22   // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 }
23 }
24 
test_array()25 void test_array ()
26 {
27   std::array a; // { dg-error "'array' is not a member of 'std'" }
28   // { dg-message "'std::array' is only available from C\\+\\+11 onwards" "" { target *-*-* } .-1 }
29 }
30 
test_tuple()31 void test_tuple ()
32 {
33   std::tuple<int,float> p; // { dg-error "'tuple' is not a member of 'std'" }
34   // { dg-message "'std::tuple' is only available from C\\+\\+11 onwards" "" { target *-*-* } .-1 }
35   // { dg-error "expected primary-expression before 'int'" "" { target *-*-* } .-2 }
36 }
37 
38 /* Since C++14.  */
39 std::shared_timed_mutex m; // { dg-error "'shared_timed_mutex' in namespace 'std' does not name a type" }
40 // { dg-message "'std::shared_timed_mutex' is only available from C\\+\\+14 onwards" "" { target *-*-* } .-1 }
41 
42 /* Since C++17: */
43 std::string_view sv; // { dg-error "'string_view' in namespace 'std' does not name a type" }
44 // { dg-message "'std::string_view' is only available from C\\+\\+17 onwards" "" { target *-*-* } .-1 }
45 
46 /* Verify interaction with "using namespace std;".  */
47 using namespace std;
test_via_using_directive()48 void test_via_using_directive ()
49 {
50   shared_ptr<int> p; // { dg-error "'shared_ptr' was not declared in this scope" }
51   // { dg-message "'std::shared_ptr' is only available from C\\+\\+11 onwards" "" { target *-*-* } .-1 }
52   // { dg-error "expected primary-expression before 'int'" "" { target *-*-* } .-2 }
53 }
54