gcc/libstdc++-v3/testsuite
Jonathan Wakely 7ac205673c PR libstdc++/85965 delay static assertions until types are complete
The static assertions added for PR libstdc++/48101 were at class scope
and so were evaluated too eagerly, when it might not be possible to
determine whether the function objects are invocable with the key types.
The problematic cases are where the key type is not known to be
convertible to the argument type(s) of the function object until later,
after a type has been completed. Specifically, if the key type is a
pointer to a derived class and the function object's argument type is a
pointer to a base class, then the derived-to-base conversion is only
valid once the derived type is complete.

By moving the static assertions to the destructor they will only be
evaluated when the destructor is instantiated, at which point whether
the key type can be passed to the function object should be knowable.
The ideal place to do the checks would be only when the function objects
are actually invoked, but that would mean adding the checks in numerous
places, so the destructor is used instead.

The tests need to be adjusted because the "required from here" line is
now the location of the destructor, not the point of instantiation in
the test file. For the map and multimap tests which check two
specializations, the dg-error matching the assertion text matches both
cases. Also check the diagnostic output for the template arguments, to
ensure both specializations trigger the assertion.

	PR libstdc++/85965
	* include/bits/hashtable.h (_Hashtable): Move static assertions to
	destructor so they are not evaluated until the _Key type is complete.
	* include/bits/stl_tree.h (_Rb_tree): Likewise.
	* testsuite/23_containers/set/85965.cc: New test.
	* testsuite/23_containers/unordered_set/85965.cc: New test.
	* testsuite/23_containers/map/48101_neg.cc: Replace "here" errors
	with regexp matching the corresponding _Rb_tree specialization.
	* testsuite/23_containers/multimap/48101_neg.cc: Likewise.
	* testsuite/23_containers/multiset/48101_neg.cc: Remove "here" error.
	* testsuite/23_containers/set/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_map/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_set/48101_neg.cc: Likewise.

From-SVN: r269949
2019-03-26 15:28:48 +00:00
..
17_intro PR libstdc++/89023 fix test that fails when <omp.h> not available 2019-02-11 12:56:59 +00:00
18_support P0482R5 char8_t: Updates to existing standard library tests 2019-02-22 01:16:08 +00:00
19_diagnostics Update copyright years. 2019-01-01 13:31:55 +01:00
20_util Integrate C++17 parallel algorithms 2019-03-21 23:48:49 +00:00
21_strings PR libstdc++/89446 fix null pointer dereference in char_traits 2019-02-23 03:01:59 +00:00
22_locale P0482R5 char8_t: Updates to existing standard library tests 2019-02-22 01:16:08 +00:00
23_containers PR libstdc++/85965 delay static assertions until types are complete 2019-03-26 15:28:48 +00:00
24_iterators Update copyright years. 2019-01-01 13:31:55 +01:00
25_algorithms Integrate C++17 parallel algorithms 2019-03-21 23:48:49 +00:00
26_numerics Integrate C++17 parallel algorithms 2019-03-21 23:48:49 +00:00
27_io P0482R5 char8_t: New standard library tests 2019-02-19 02:55:05 +00:00
28_regex PR libstdc++/89023 fix test that fails when <omp.h> not available 2019-02-11 12:56:59 +00:00
29_atomics Change test to use const variables instead of macros 2019-03-11 13:46:09 +00:00
30_threads Fix tests that fail in C++2a mode 2019-01-29 00:47:32 +00:00
abi Update copyright years. 2019-01-01 13:31:55 +01:00
backward Update copyright years. 2019-01-01 13:31:55 +01:00
config Update copyright years. 2019-01-01 13:31:55 +01:00
data
decimal Update copyright years. 2019-01-01 13:31:55 +01:00
experimental re PR libstdc++/89461 (FAIL: experimental/net/timer/waitable/cons.cc) 2019-03-12 23:13:36 +00:00
ext P0482R5 char8_t: New standard library tests 2019-02-19 02:55:05 +00:00
lib Integrate C++17 parallel algorithms 2019-03-21 23:48:49 +00:00
libstdc++-abi Update copyright years. 2019-01-01 13:31:55 +01:00
libstdc++-dg Update copyright years. 2019-01-01 13:31:55 +01:00
libstdc++-prettyprinters Fix failing prettyprinter test 2019-01-09 10:46:52 +00:00
libstdc++-xmethods Update copyright years. 2019-01-01 13:31:55 +01:00
performance Update copyright years. 2019-01-01 13:31:55 +01:00
special_functions PR libstdc++/86655 - std::assoc_legendre should not constrain 2019-03-06 13:38:32 +00:00
tr1 PR libstdc++/86655 - std::assoc_legendre should not constrain 2019-03-06 13:38:32 +00:00
tr2 Update copyright years. 2019-01-01 13:31:55 +01:00
util Integrate C++17 parallel algorithms 2019-03-21 23:48:49 +00:00
Makefile.am Update copyright years. 2019-01-01 13:31:55 +01:00
Makefile.in PR libstdc++/89466 avoid slow xsltproc command in configure 2019-02-27 11:25:44 +00:00