view gcc/testsuite/g++.dg/lookup/missing-std-include-8.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
line wrap: on
line source

/* 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 }
}

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'" }
  // { 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 }
}