Commit Graph

12 Commits

Author SHA1 Message Date
Jakub Jelinek
99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
Jakub Jelinek
8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
Jonathan Wakely
209ee62421 Remove redundant static assertions in [meta.unary.prop] traits
The type property predicates that are implemented by a compiler builtin
already do the right checks in the compiler. The checks for complete
type or unbounded arrays were wrong for these types anyway.

	* include/std/type_traits (is_empty, is_polymorphic, is_final)
	(is_abstract, is_aggregate): Remove static_assert.
	* testsuite/20_util/is_abstract/incomplete_neg.cc: Check for error
	from builtin only.
	* testsuite/20_util/is_aggregate/incomplete_neg.cc: Likewise. Add
	missing -std=gnu++17 option.
	* testsuite/20_util/is_empty/incomplete_neg.cc: New test.
	* testsuite/20_util/is_final/incomplete_neg.cc: New test.
	* testsuite/20_util/is_polymorphic/incomplete_neg.cc: Check for error
	from builtin only.

From-SVN: r272000
2019-06-06 13:13:47 +01:00
Antony Polukhin
608a080c3f PR libstdc++/71579 assert that type traits are not misused with incomplete types
This patch adds static asserts for type traits misuse with incomplete
classes and unions. This gives a nice readable error message instead
of an UB and odr-violations.

Some features of the patch:
* each type trait has it's own static_assert inside. This gives better
diagnostics than the approach with putting the assert into a helper
structure and using it in each trait.
* the result of completeness check is not memorized by the compiler.
This gives no false positive after the first failed check.
* some of the compiler builtins already implement the check. But not
all of them! So the asserts are in all the type_traits that may
benefit from the check. This also makes the behavior of libstdc++ more
consistent across different (non GCC) compilers.
* std::is_base_of does not have the assert as it works well in many
cases with incomplete types

2019-05-31  Antony Polukhin  <antoshkka@gmail.com>

	PR libstdc++/71579
	* include/std/type_traits __type_identity, __is_complete_or_unbounded):
	New helpers for checking preconditions in traits.
	(is_trivial, is_trivially_copyable, is_standard_layout, is_pod)
	(is_literal_type, is_empty, is_polymorphic, is_final, is_abstract)
	(is_destructible, is_nothrow_destructible, is_constructible)
	(is_default_constructible, is_copy_constructible)
	(is_move_constructible, is_nothrow_default_constructible)
	(is_nothrow_constructible, is_nothrow_copy_constructible)
	(is_nothrow_move_constructible, is_copy_assignable, is_move_assignable)
	(is_nothrow_assignable, is_nothrow_copy_assignable)
	(is_nothrow_move_assignable, is_trivially_constructible)
	(is_trivially_copy_constructible, is_trivially_move_constructible)
	is_trivially_assignable, is_trivially_copy_assignable)
	(is_trivially_move_assignable, is_trivially_destructible)
	(alignment_of, is_swappable, is_nothrow_swappable, is_invocable)
	(is_invocable_r, is_nothrow_invocable)
	(has_unique_object_representations, is_aggregate): Add static_asserts
	to make sure that type traits are not misused with incomplete types.
	(__is_constructible_impl, __is_nothrow_default_constructible_impl)
	(__is_nothrow_constructible_impl, __is_nothrow_assignable_impl): New
	base characteristics without assertions that can be reused in other
	traits.
	* testsuite/20_util/is_complete_or_unbounded/memoization.cc: New test.
	* testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc: New
	test.
	* testsuite/20_util/is_complete_or_unbounded/value.cc: New test.
	* testsuite/20_util/is_abstract/incomplete_neg.cc: New test.
	* testsuite/20_util/is_aggregate/incomplete_neg.cc: New test.
	* testsuite/20_util/is_class/value.cc: Check incomplete type.
	* testsuite/20_util/is_function/value.cc: Likewise.
	* testsuite/20_util/is_move_constructible/incomplete_neg.cc: New test.
	* testsuite/20_util/is_nothrow_move_assignable/incomplete_neg.cc: New
	test.
	* testsuite/20_util/is_polymorphic/incomplete_neg.cc: New test.
	* testsuite/20_util/is_reference/value.cc: Check incomplete types.
	* testsuite/20_util/is_unbounded_array/value.cc: Likewise.
	* testsuite/20_util/is_union/value.cc: Likewise.
	* testsuite/20_util/is_void/value.cc: Likewise.
	* testsuite/util/testsuite_tr1.h: Add incomplete union type.

From-SVN: r271806
2019-05-31 11:35:03 +01:00
Jakub Jelinek
a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00
Jakub Jelinek
85ec4feb11 Update copyright years.
From-SVN: r256169
2018-01-03 11:03:58 +01:00
Jakub Jelinek
cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Jonathan Wakely
52066eae5d Use effective-target instead of -std options
* testsuite/*: Use { target c++11 } or { target c++14 } instead of
	using -std in dg-options.

From-SVN: r239777
2016-08-26 12:41:37 +01:00
Jakub Jelinek
818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Jakub Jelinek
5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Richard Sandiford
aa118a03c4 Update copyright years in libstdc++-v3/
From-SVN: r206301
2014-01-02 22:30:10 +00:00
Paolo Carlini
ae29d0253f explicit_instantiation.cc: New.
2013-12-08  Paolo Carlini  <paolo.carlini@oracle.com>

	* testsuite/20_util/add_const/requirements/explicit_instantiation.cc:
	New.
	* testsuite/20_util/add_const/value.cc: Likewise.
	* testsuite/20_util/add_cv/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/add_cv/value.cc: Likewise.
	* testsuite/20_util/add_pointer/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/add_pointer/value.cc: Likewise.
	* testsuite/20_util/add_volatile/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/add_volatile/value.cc: Likewise.
	* testsuite/20_util/alignment_of/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/alignment_of/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/alignment_of/value.cc: Likewise.
	* testsuite/20_util/extent/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/extent/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/extent/value.cc: Likewise.
	* testsuite/20_util/has_virtual_destructor/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/has_virtual_destructor/requirements/
	typedefs.cc: Likewise.
	* testsuite/20_util/has_virtual_destructor/value.cc: Likewise.
	* testsuite/20_util/is_abstract/requirements/explicit_instantiation.cc:
 	Likewise.
	* testsuite/20_util/is_abstract/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_abstract/value.cc: Likewise.
	* testsuite/20_util/is_arithmetic/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/is_arithmetic/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_arithmetic/value.cc: Likewise.
	* testsuite/20_util/is_array/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_array/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_array/value.cc: Likewise.
	* testsuite/20_util/is_base_of/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_base_of/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_base_of/value.cc: Likewise.
	* testsuite/20_util/is_class/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_class/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_class/value.cc: Likewise.
	* testsuite/20_util/is_const/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_const/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_const/value.cc: Likewise.
	* testsuite/20_util/is_empty/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_empty/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_empty/value.cc: Likewise.
	* testsuite/20_util/is_enum/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_enum/requirements/typedefs.cc
	* testsuite/20_util/is_enum/value.cc: Likewise.
	* testsuite/20_util/is_pointer/requirements/explicit_instantiation.cc
	* testsuite/20_util/is_pointer/value.cc: Likewise.
	* testsuite/20_util/is_polymorphic/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/is_polymorphic/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_polymorphic/value.cc: Likewise.
	* testsuite/20_util/is_same/requirements/explicit_instantiation.cc
	* testsuite/20_util/is_same/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_same/value.cc: Likewise.
	* testsuite/20_util/is_union/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/is_union/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_union/value.cc: Likewise.
	* testsuite/20_util/is_void/requirements/explicit_instantiation.cc
	* testsuite/20_util/is_void/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_void/value.cc: Likewise.
	* testsuite/20_util/is_volatile/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/is_volatile/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_volatile/value.cc: Likewise.
	* testsuite/20_util/rank/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/rank/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/rank/value.cc: Likewise.
	* testsuite/20_util/remove_all_extents/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/remove_all_extents/value.cc: Likewise.
	* testsuite/20_util/remove_const/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/remove_const/value.cc: Likewise.
	* testsuite/20_util/remove_cv/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/remove_cv/value.cc: Likewise.
	* testsuite/20_util/remove_extent/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/remove_extent/value.cc: Likewise.
	* testsuite/20_util/remove_pointer/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/remove_pointer/value.cc: Likewise.
	* testsuite/20_util/remove_volatile/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/remove_volatile/value.cc: Likewise.

From-SVN: r205789
2013-12-08 09:44:48 +00:00