]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/is_trivially_constructible/value.cc
PR c++/90532 Ensure __is_constructible(T[]) is false
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / is_trivially_constructible / value.cc
CommitLineData
be58e01d 1// { dg-do compile { target c++11 } }
285dc591 2//
3// 2014-10-09 Ville Voutilainen <ville.voutilainen@gmail.com>
4//
fbd26352 5// Copyright (C) 2014-2019 Free Software Foundation, Inc.
285dc591 6//
7// This file is part of the GNU ISO C++ Library. This library is free
8// software; you can redistribute it and/or modify it under the
9// terms of the GNU General Public License as published by the
10// Free Software Foundation; either version 3, or (at your option)
11// any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License along
19// with this library; see the file COPYING3. If not see
20// <http://www.gnu.org/licenses/>.
21
22#include <type_traits>
23#include <testsuite_tr1.h>
24
25struct HasTemplateCCtor
26{
27 HasTemplateCCtor(const HasTemplateCCtor&) = default;
28 template <class T>
29 HasTemplateCCtor(T&&);
30};
31
32struct MoveOnly
33{
34 MoveOnly(MoveOnly&&) = default;
35};
36
37struct MoveOnly2
38{
39 MoveOnly2(MoveOnly2&&) = delete;
40};
41
42void test01()
43{
44 using std::is_trivially_constructible;
45 using namespace __gnu_test;
46
811f9a1c 47 static_assert(test_property<is_trivially_constructible,
285dc591 48 int>(true), "");
811f9a1c 49 static_assert(test_property<is_trivially_constructible,
285dc591 50 int, int>(true), "");
811f9a1c 51 static_assert(test_property<is_trivially_constructible,
285dc591 52 int, int&>(true), "");
811f9a1c 53 static_assert(test_property<is_trivially_constructible,
285dc591 54 int, int&&>(true), "");
811f9a1c 55 static_assert(test_property<is_trivially_constructible,
285dc591 56 int, const int&>(true), "");
811f9a1c 57 static_assert(test_property<is_trivially_constructible,
58 int, void*>(false), "PR 86398");
59 static_assert(test_property<is_trivially_constructible,
60 int, int*>(false), "PR 86398");
61 static_assert(test_property<is_trivially_constructible,
62 int, const int*>(false), "PR 86398");
63 static_assert(test_property<is_trivially_constructible,
64 int*, void*>(false), "PR 86398");
65 static_assert(test_property<is_trivially_constructible,
66 int*, const int*>(false), "PR 86398");
67 static_assert(test_property<is_trivially_constructible,
68 int&, const int>(false), "");
69 static_assert(test_property<is_trivially_constructible,
70 const int&, int>(true), "");
71 static_assert(test_property<is_trivially_constructible,
72 const int&, int&>(true), "");
73 static_assert(test_property<is_trivially_constructible,
74 const int*, int*>(true), "");
75 static_assert(test_property<is_trivially_constructible,
285dc591 76 PolymorphicClass>(false), "");
811f9a1c 77 static_assert(test_property<is_trivially_constructible,
285dc591 78 PolymorphicClass, PolymorphicClass>(false), "");
811f9a1c 79 static_assert(test_property<is_trivially_constructible,
285dc591 80 PolymorphicClass, PolymorphicClass&>(false), "");
811f9a1c 81 static_assert(test_property<is_trivially_constructible,
285dc591 82 PolymorphicClass, PolymorphicClass&&>(false), "");
811f9a1c 83 static_assert(test_property<is_trivially_constructible,
285dc591 84 PolymorphicClass, const PolymorphicClass&>(false), "");
811f9a1c 85 static_assert(test_property<is_trivially_constructible,
285dc591 86 TType>(true), "");
811f9a1c 87 static_assert(test_property<is_trivially_constructible,
285dc591 88 TType, TType>(true), "");
811f9a1c 89 static_assert(test_property<is_trivially_constructible,
285dc591 90 TType, TType&>(true), "");
811f9a1c 91 static_assert(test_property<is_trivially_constructible,
285dc591 92 TType, TType&&>(true), "");
811f9a1c 93 static_assert(test_property<is_trivially_constructible,
285dc591 94 TType, const TType&>(true), "");
811f9a1c 95 static_assert(test_property<is_trivially_constructible,
285dc591 96 TType, int, int>(false), "");
811f9a1c 97 static_assert(test_property<is_trivially_constructible,
285dc591 98 PODType>(true), "");
811f9a1c 99 static_assert(test_property<is_trivially_constructible,
285dc591 100 PODType, PODType>(true), "");
811f9a1c 101 static_assert(test_property<is_trivially_constructible,
285dc591 102 PODType, PODType&>(true), "");
811f9a1c 103 static_assert(test_property<is_trivially_constructible,
285dc591 104 PODType, PODType&&>(true), "");
811f9a1c 105 static_assert(test_property<is_trivially_constructible,
285dc591 106 PODType, const PODType&>(true), "");
811f9a1c 107 static_assert(test_property<is_trivially_constructible,
285dc591 108 PODType, int, int>(false), "");
811f9a1c 109 static_assert(test_property<is_trivially_constructible,
285dc591 110 NType>(false), "");
811f9a1c 111 static_assert(test_property<is_trivially_constructible,
285dc591 112 SLType>(false), "");
811f9a1c 113 static_assert(test_property<is_trivially_constructible,
285dc591 114 LType>(false), "");
811f9a1c 115 static_assert(test_property<is_trivially_constructible,
285dc591 116 LType, int>(false), "");
811f9a1c 117 static_assert(test_property<is_trivially_constructible,
285dc591 118 construct::DelDef>(false), "");
811f9a1c 119 static_assert(test_property<is_trivially_constructible,
285dc591 120 construct::Abstract>(false), "");
811f9a1c 121 static_assert(test_property<is_trivially_constructible,
285dc591 122 construct::Ellipsis>(false), "");
811f9a1c 123 static_assert(test_property<is_trivially_constructible,
285dc591 124 construct::DelEllipsis>(false), "");
811f9a1c 125 static_assert(test_property<is_trivially_constructible,
285dc591 126 construct::Any>(false), "");
811f9a1c 127 static_assert(test_property<is_trivially_constructible,
285dc591 128 construct::DelCopy>(false), "");
811f9a1c 129 static_assert(test_property<is_trivially_constructible,
285dc591 130 construct::DelCopy, const construct::DelCopy&>(false), "");
811f9a1c 131 static_assert(test_property<is_trivially_constructible,
285dc591 132 construct::DelDtor>(false), "");
811f9a1c 133 static_assert(test_property<is_trivially_constructible,
285dc591 134 construct::Nontrivial>(false), "");
811f9a1c 135 static_assert(test_property<is_trivially_constructible,
285dc591 136 construct::UnusualCopy>(false), "");
811f9a1c 137 static_assert(test_property<is_trivially_constructible,
285dc591 138 CopyConsOnlyType>(false), "");
811f9a1c 139 static_assert(test_property<is_trivially_constructible,
285dc591 140 CopyConsOnlyType, CopyConsOnlyType>(false), "");
811f9a1c 141 static_assert(test_property<is_trivially_constructible,
285dc591 142 CopyConsOnlyType, CopyConsOnlyType&>(true), "");
811f9a1c 143 static_assert(test_property<is_trivially_constructible,
285dc591 144 CopyConsOnlyType, CopyConsOnlyType&&>(false), "");
811f9a1c 145 static_assert(test_property<is_trivially_constructible,
285dc591 146 CopyConsOnlyType, const CopyConsOnlyType&>(true), "");
811f9a1c 147 static_assert(test_property<is_trivially_constructible,
285dc591 148 MoveConsOnlyType>(false), "");
811f9a1c 149 static_assert(test_property<is_trivially_constructible,
285dc591 150 MoveConsOnlyType, MoveConsOnlyType>(true), "");
811f9a1c 151 static_assert(test_property<is_trivially_constructible,
285dc591 152 MoveConsOnlyType, MoveConsOnlyType&>(false), "");
811f9a1c 153 static_assert(test_property<is_trivially_constructible,
285dc591 154 MoveConsOnlyType, MoveConsOnlyType&&>(true), "");
811f9a1c 155 static_assert(test_property<is_trivially_constructible,
285dc591 156 MoveConsOnlyType, const MoveConsOnlyType&>(false), "");
811f9a1c 157 static_assert(test_property<is_trivially_constructible,
285dc591 158 ClassType, DerivedType>(true), "");
811f9a1c 159 static_assert(test_property<is_trivially_constructible,
285dc591 160 ClassType, DerivedType&>(true), "");
811f9a1c 161 static_assert(test_property<is_trivially_constructible,
285dc591 162 ClassType, DerivedType&&>(true), "");
811f9a1c 163 static_assert(test_property<is_trivially_constructible,
285dc591 164 ClassType, const DerivedType&>(true), "");
811f9a1c 165 static_assert(test_property<is_trivially_constructible,
285dc591 166 HasTemplateCCtor>(false), "");
811f9a1c 167 static_assert(test_property<is_trivially_constructible,
285dc591 168 HasTemplateCCtor, HasTemplateCCtor>(false), "");
811f9a1c 169 static_assert(test_property<is_trivially_constructible,
285dc591 170 HasTemplateCCtor, const HasTemplateCCtor&>(true), "");
811f9a1c 171 static_assert(test_property<is_trivially_constructible,
285dc591 172 MoveOnly>(false), "");
811f9a1c 173 static_assert(test_property<is_trivially_constructible,
285dc591 174 MoveOnly, MoveOnly>(true), "");
811f9a1c 175 static_assert(test_property<is_trivially_constructible,
285dc591 176 MoveOnly, MoveOnly&>(false), "");
811f9a1c 177 static_assert(test_property<is_trivially_constructible,
285dc591 178 MoveOnly, MoveOnly&&>(true), "");
811f9a1c 179 static_assert(test_property<is_trivially_constructible,
285dc591 180 MoveOnly, const MoveOnly&>(false), "");
811f9a1c 181 static_assert(test_property<is_trivially_constructible,
285dc591 182 MoveOnly2>(false), "");
48328bff 183 static_assert(test_property<is_trivially_constructible,
184 int[]>(false), "PR c++/90532");
285dc591 185}