gcc/libstdc++-v3/testsuite/experimental/source_location/1.cc
Jonathan Wakely 49ba258864 Add missing dg-require-cstdint directives to tests
* testsuite/18_support/aligned_alloc/aligned_alloc.cc: Add
	dg-require-cstdint directive.
	* testsuite/20_util/allocator/overaligned.cc: Likewise.
	* testsuite/20_util/any/cons/aligned.cc: Likewise.
	* testsuite/20_util/monotonic_buffer_resource/allocate.cc: Likewise.
	* testsuite/20_util/monotonic_buffer_resource/deallocate.cc: Likewise.
	* testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc:
	Likewise.
	* testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc: Likewise.
	* testsuite/23_containers/list/modifiers/insert/25288.cc: Likewise.
	* testsuite/23_containers/set/allocator/move_assign.cc: Likewise.
	* testsuite/25_algorithms/make_heap/complexity.cc: Likewise.
	* testsuite/25_algorithms/pop_heap/complexity.cc: Require cstdint and
	random_device effective-target.
	* testsuite/25_algorithms/push_heap/complexity.cc: Likewise.
	* testsuite/25_algorithms/sample/1.cc: Require cstdint.
	* testsuite/25_algorithms/sample/2.cc: Likewise.
	* testsuite/25_algorithms/sort_heap/complexity.cc: Require cstdint
	and random_device.
	* testsuite/26_numerics/headers/random/types_std_c++0x.cc: Require
	cstdint.
	* testsuite/26_numerics/random/chi_squared_distribution/83833.cc:
	Likewise.
	* testsuite/26_numerics/random/discard_block_engine/requirements/
	constexpr_data.cc: Likewise.
	* testsuite/26_numerics/random/discard_block_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/independent_bits_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/linear_congruential_engine/requirements/
	constexpr_data.cc: Likewise.
	* testsuite/26_numerics/random/linear_congruential_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/mersenne_twister_engine/requirements/
	constexpr_data.cc: Likewise.
	* testsuite/26_numerics/random/mersenne_twister_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/pr60037-neg.cc: Likewise.
	* testsuite/26_numerics/random/seed_seq/cons/65631.cc: Likewise.
	* testsuite/26_numerics/random/shuffle_order_engine/requirements/
	constexpr_data.cc: Add dg-require-cstdint directive.
	* testsuite/26_numerics/random/shuffle_order_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/subtract_with_carry_engine/requirements/
	constexpr_data.cc: Likewise.
	* testsuite/26_numerics/random/subtract_with_carry_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/uniform_real_distribution/operators/
	64351.cc: Likewise.
	* testsuite/29_atomics/headers/atomic/types_std_c++0x.cc: Likewise.
	* testsuite/experimental/algorithm/sample-2.cc: Likewise.
	* testsuite/experimental/algorithm/sample.cc: Likewise.
	* testsuite/experimental/algorithm/search.cc: Likewise.
	* testsuite/experimental/algorithm/shuffle.cc: Likewise.
	* testsuite/experimental/any/cons/aligned.cc: Likewise.
	* testsuite/experimental/memory_resource/new_delete_resource.cc:
	Likewise.
	* testsuite/experimental/memory_resource/resource_adaptor.cc: Likewise.
	* testsuite/experimental/random/randint.cc: Likewise.
	* testsuite/experimental/source_location/1.cc: Likewise.
	* testsuite/ext/bitmap_allocator/overaligned.cc: Likewise.
	* testsuite/ext/malloc_allocator/overaligned.cc: Likewise.
	* testsuite/ext/mt_allocator/overaligned.cc: Likewise.
	* testsuite/ext/new_allocator/overaligned.cc: Likewise.
	* testsuite/ext/pb_ds/regression/hash_map_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/hash_set_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/list_update_map_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/list_update_set_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/priority_queue_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/tree_map_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/tree_set_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/trie_map_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/trie_set_rand.cc: Likewise.
	* testsuite/ext/pool_allocator/overaligned.cc: Likewise.
	* testsuite/ext/throw_allocator/check_allocate_max_size.cc: Likewise.
	* testsuite/ext/throw_allocator/check_deallocate_null.cc: Likewise.
	* testsuite/ext/throw_allocator/check_delete.cc: Likewise.
	* testsuite/ext/throw_allocator/check_new.cc: Likewise.
	* testsuite/ext/throw_allocator/deallocate_global.cc: Likewise.
	* testsuite/ext/throw_allocator/deallocate_local.cc: Likewise.
	* testsuite/ext/throw_allocator/explicit_instantiation.cc: Likewise.
	* testsuite/ext/throw_allocator/variadic_construct.cc: Likewise.
	* testsuite/tr1/8_c_compatibility/cinttypes/functions.cc: Likewise.

From-SVN: r263008
2018-07-26 15:03:28 +01:00

119 lines
3.4 KiB
C++

// Copyright (C) 2017-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-do run { target c++14 } }
// { dg-require-cstdint "" }
#include <experimental/source_location>
#include <experimental/string_view>
#include <testsuite_hooks.h>
using std::experimental::source_location;
using std::experimental::string_view;
void
test01()
{
constexpr source_location loc = source_location::current();
static_assert( loc.line() == 31 );
// static_assert( loc.column() == 35 );
VERIFY( loc.file_name() == __FILE__ );
VERIFY( loc.function_name() == string_view(__FUNCTION__) );
}
struct S {
string_view func;
source_location loc = source_location::current();
S(source_location loc = source_location::current())
: func(__FUNCTION__), loc(loc) // values of loc will be from call-site
{}
S(int)
: func(__FUNCTION__) // values of loc should be hereabouts
{}
};
void test02()
{
S s0;
VERIFY( s0.loc.line() == 53 );
// static_assert( s0.loc.column() == 7 );
VERIFY( s0.loc.file_name() == __FILE__ );
VERIFY( s0.loc.function_name() == string_view(__FUNCTION__) );
S s1(1);
VERIFY( s1.loc.line() == 47 );
VERIFY( s1.loc.file_name() == __FILE__ );
VERIFY( s1.loc.function_name() == s1.func );
}
source_location f(source_location a = source_location::current()) {
return a;
}
source_location g(string_view& func) {
source_location a = source_location::current();
func = __FUNCTION__;
return a;
}
void test03()
{
auto loc = f(); // f's first argument corresponds to this line of code
VERIFY( loc.line() == 77 );
// static_assert( loc.column() == 16 );
VERIFY( loc.file_name() == __FILE__ );
VERIFY( loc.function_name() == string_view(__FUNCTION__) );
source_location c = source_location::current();
loc = f(c); // f's first argument gets the same values as c, above
VERIFY( loc.line() == 83 );
// static_assert( loc.column() == 23 );
VERIFY( loc.file_name() == __FILE__ );
VERIFY( loc.function_name() == string_view(__FUNCTION__) );
string_view func;
loc = g(func);
VERIFY( loc.line() == 70 );
// static_assert( loc.column() == 23 );
VERIFY( loc.file_name() == __FILE__ );
VERIFY( loc.function_name() == func );
}
void
test04()
{
using std::is_same;
using std::uint_least32_t;
auto loc = source_location::current();
static_assert(is_same<decltype(loc), source_location>::value, "");
static_assert(is_same<decltype(loc.line()), uint_least32_t>::value, "");
static_assert(is_same<decltype(loc.column()), uint_least32_t>::value, "");
static_assert(is_same<decltype(loc.file_name()), const char*>::value, "");
static_assert(is_same<decltype(loc.function_name()), const char*>::value, "");
}
int
main()
{
test01();
test02();
test03();
test04();
}