diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-11-20 10:06:42 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2019-11-20 10:06:42 +0000 |
commit | 9f3d9a570819cb522d2ff3e36c04f742c3870537 (patch) | |
tree | 8531ed8dcb46358788a528f026095e0bee664ef7 /libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc | |
parent | 522f3b741606e806f058efcdf6474f2cdcc56718 (diff) | |
parent | c59fa98026086e9886257fce39d27dcfd16cc4f6 (diff) |
svn merge -r274943:278492 svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-9-branchredhat/gcc-9-branch
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/redhat/gcc-9-branch@278493 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc')
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc new file mode 100644 index 00000000000..db7d8d5c850 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2019 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-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include <vector> + +// PR libstdc++/89164 + +struct X +{ + X() = default; + X(const X&) = delete; +}; + +void test01() +{ + X x[1]; + // Should not be able to create vector using uninitialized_copy: + std::vector<X> v1{x, x+1}; // { dg-error "here" } + + // Should not be able to create vector using uninitialized_fill_n: + std::vector<X> v2{2u, X{}}; // { dg-error "here" } +} + +void test02() +{ +#if __cplusplus >= 201703L + // Can create initializer_list<X> with C++17 guaranteed copy elision, + // but shouldn't be able to copy from it with uninitialized_copy: + std::vector<X> v3{X{}, X{}, X{}}; // { dg-error "here" } +#endif +} +// { dg-error "constructible from value" "" { target *-*-* } 0 } +// { dg-error "constructible from input" "" { target *-*-* } 0 } |