Re: [PATCH,libstdc++] C++-20 costexpr and

2019-05-30 Thread Ed Smith-Rowland via gcc-patches

On 5/30/19 5:05 PM, Ed Smith-Rowland via libstdc++ wrote:

Greetings,

I was not quite able to finish this in for gcc9 but here is the patch 
for:


?? Implement C++20 p0202 - Add Constexpr Modifiers to Functions
 ??in  and  Headers.
 ??Implement C++20 p1023 - constexpr comparison operators for 
std::array.


I believe I have answered peoples concerns with the last patch 
attempts [https://gcc.gnu.org/ml/libstdc++/2019-03/msg00132.html].


The patch is large because of test cases but really just boils down to 
adding constexpr for c++2a.


The patch passes for gnu++2a and pre-gnu++2a on x86_64-linux.

OK for trunk?

Ed Smith-Rowland


Actually, I got 6 excess error fails in C++20 (I keep forgetting to 
actually test that option, sorry):


FAIL: 25_algorithms/copy/58982.cc (test for excess errors)
FAIL: 25_algorithms/copy/move_iterators/69478.cc (test for excess errors)
FAIL: 25_algorithms/copy_backward/move_iterators/69478.cc (test for 
excess errors)

FAIL: 25_algorithms/copy_n/58982.cc (test for excess errors)
FAIL: 25_algorithms/move/69478.cc (test for excess errors)
FAIL: 25_algorithms/move_backward/69478.cc (test for excess errors)

These excess errors are all 'error: use of deleted function' for copy 
assignments - which is true.?? I just had the wrong prune string. My 
deja-gnu is wobbly.


The guts of the previous patch are still unchanged but here is a new 
patch with the fixed testcases.


This passes C++20 and earlier.

Sorry for the noise.

OK?

Ed


2019-05-31  Edward Smith-Rowland  <3dw...@verizon.net>

Implement C++20 p0202 - Add Constexpr Modifiers to Functions
in  and  Headers.
Implement C++20 p1023 - constexpr comparison operators for std::array.
* include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy,
copy_backward, copy_if, copy_n, equal_range, fill, fill_n, find_end,
find_if_not, includes, is_heap, is_heap_until, is_partitioned,
is_permutation, is_sorted, is_sorted_until, lower_bound, none_of,
partition_copy, partition_point, remove, remove_if, remove_copy,
remove_copy_if, replace_copy, replace_copy_if, reverse_copy,
rotate_copy, unique, upper_bound, adjacent_find, count, count_if, equal,
find, find_first_of, find_if, for_each, generate, generate_n,
lexicographical_compare, merge, mismatch, replace, replace_if, search,
search_n, set_difference, set_intersection, set_symmetric_difference,
set_union, transform, unique_copy): Mark constexpr.
Make versions of operator() const.
* include/bits/cpp_type_traits.h (__miter_base): Make constexpr.
* include/bits/predefined_ops.h (_Iter_less_val, __iter_comp_val,
_Val_less_iter, __val_less_iter, __val_comp_iter, _Iter_equal_to_iter,
__iter_equal_to_iter, _Iter_equal_to_val, __iter_equal_to_val,
_Iter_comp_val, __iter_comp_val, _Val_comp_iter, __val_comp_iter,
_Iter_equals_val, __iter_equals_val, _Iter_equals_iter,
__iter_comp_iter, __pred_iter, __iter_comp_val, __negate): Constexpr
ctors. Add const operator().
* include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n,
__search, __search_n_aux, __search_n, __find_end, find_end, all_of
none_of, any_of, find_if_not, is_partitioned, partition_point,
__remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n,
copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find,
__unique, unique, __unique_copy, reverse_copy, rotate_copy,
__unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort,
__final_insertion_sort, lower_bound, __upper_bound, upper_bound,
__equal_range, equal_range, binary_search, __includes, includes,
__next_permutation, __prev_permutation, __replace_copy_if, replace_copy,
replace_copy_if, __count_if, is_sorted, __is_sorted_until,
is_sorted_until, __is_permutation, is_permutation, for_each, find,
find_if, find_first_of, adjacent_find, count, count_if, search,
search_n, transform, replace, replace_if, generate, generate_n,
unique_copy, __merge, merge, __set_union, set_union, __set_intersection,
set_intersection, __set_difference, set_difference,
__set_symmetric_difference, set_symmetric_difference): Constexpr.
* include/bits/stl_algobase.h (__niter_base, __niter_wrap, __copy_m,
__copy_move_a, copy, move, __copy_move_backward::__copy_move_b,
__copy_move_backward_a, __copy_move_backward_a2, copy_backward,
move_backward, fill, __fill_a, __fill_n_a, fill_n, __equal::equal,
__equal_aux, __newlast1, __cnd2, __newlast1, __cnd2,
__lexicographical_compare_impl, __lexicographical_compare::__lc,
__lexicographical_compare, __lexicographical_compare_aux,
__lower_bound, lower_bound, equal, __equal4, lexicographical_compare,
__mismatch, mismatch): 

[PATCH,libstdc++] C++-20 costexpr and

2019-05-30 Thread Ed Smith-Rowland via gcc-patches

Greetings,

I was not quite able to finish this in for gcc9 but here is the patch for:

?? Implement C++20 p0202 - Add Constexpr Modifiers to Functions
 ??in  and  Headers.
 ??Implement C++20 p1023 - constexpr comparison operators for std::array.

I believe I have answered peoples concerns with the last patch attempts 
[https://gcc.gnu.org/ml/libstdc++/2019-03/msg00132.html].


The patch is large because of test cases but really just boils down to 
adding constexpr for c++2a.


The patch passes for gnu++2a and pre-gnu++2a on x86_64-linux.

OK for trunk?

Ed Smith-Rowland


2019-05-31  Edward Smith-Rowland  <3dw...@verizon.net>

Implement C++20 p0202 - Add Constexpr Modifiers to Functions
in  and  Headers.
Implement C++20 p1023 - constexpr comparison operators for std::array.
* include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy,
copy_backward, copy_if, copy_n, equal_range, fill, fill_n, find_end,
find_if_not, includes, is_heap, is_heap_until, is_partitioned,
is_permutation, is_sorted, is_sorted_until, lower_bound, none_of,
partition_copy, partition_point, remove, remove_if, remove_copy,
remove_copy_if, replace_copy, replace_copy_if, reverse_copy,
rotate_copy, unique, upper_bound, adjacent_find, count, count_if, equal,
find, find_first_of, find_if, for_each, generate, generate_n,
lexicographical_compare, merge, mismatch, replace, replace_if, search,
search_n, set_difference, set_intersection, set_symmetric_difference,
set_union, transform, unique_copy): Mark constexpr.
Make versions of operator() const.
* include/bits/cpp_type_traits.h (__miter_base): Make constexpr.
* include/bits/predefined_ops.h (_Iter_less_val, __iter_comp_val,
_Val_less_iter, __val_less_iter, __val_comp_iter, _Iter_equal_to_iter,
__iter_equal_to_iter, _Iter_equal_to_val, __iter_equal_to_val,
_Iter_comp_val, __iter_comp_val, _Val_comp_iter, __val_comp_iter,
_Iter_equals_val, __iter_equals_val, _Iter_equals_iter,
__iter_comp_iter, __pred_iter, __iter_comp_val, __negate): Constexpr
ctors. Add const operator().
* include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n,
__search, __search_n_aux, __search_n, __find_end, find_end, all_of
none_of, any_of, find_if_not, is_partitioned, partition_point,
__remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n,
copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find,
__unique, unique, __unique_copy, reverse_copy, rotate_copy,
__unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort,
__final_insertion_sort, lower_bound, __upper_bound, upper_bound,
__equal_range, equal_range, binary_search, __includes, includes,
__next_permutation, __prev_permutation, __replace_copy_if, replace_copy,
replace_copy_if, __count_if, is_sorted, __is_sorted_until,
is_sorted_until, __is_permutation, is_permutation, for_each, find,
find_if, find_first_of, adjacent_find, count, count_if, search,
search_n, transform, replace, replace_if, generate, generate_n,
unique_copy, __merge, merge, __set_union, set_union, __set_intersection,
set_intersection, __set_difference, set_difference,
__set_symmetric_difference, set_symmetric_difference): Constexpr.
* include/bits/stl_algobase.h (__niter_base, __niter_wrap, __copy_m,
__copy_move_a, copy, move, __copy_move_backward::__copy_move_b,
__copy_move_backward_a, __copy_move_backward_a2, copy_backward,
move_backward, fill, __fill_a, __fill_n_a, fill_n, __equal::equal,
__equal_aux, __newlast1, __cnd2, __newlast1, __cnd2,
__lexicographical_compare_impl, __lexicographical_compare::__lc,
__lexicographical_compare, __lexicographical_compare_aux,
__lower_bound, lower_bound, equal, __equal4, lexicographical_compare,
__mismatch, mismatch): Constexpr.
(__memmove, __memcmp): New constexpr wrappers.
* include/bits/stl_heap.h (__is_heap_until, __is_heap, is_heap_until,
is_heap): Constexpr.
* include/bits/stl_iterator.h (__niter_base, __miter_base): Constexpr.
* include/std/array: Make comparison ops constexpr.
* include/std/utility: Make exchange constexpr.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/
tuple_element_neg.cc: Adjust.
* testsuite/25_algorithms/copy_n/58982.cc: Adjust error scan.
Prune "deleted".
* testsuite/25_algorithms/copy/58982.cc: Adjust error scan.
Prune "deleted".
* testsuite/25_algorithms/copy/move_iterators/69478.cc: Prune "deleted".
* testsuite/25_algorithms/copy_backward/move_iterators/69478.cc:
Prune "deleted".