1// { dg-options "-std=gnu++11" }
2// { dg-do compile }
3
4// Copyright (C) 2013-2015 Free Software Foundation, Inc.
5//
6// This file is part of the GNU ISO C++ Library.  This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 3, or (at your option)
10// any later version.
11//
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING3.  If not see
19// <http://www.gnu.org/licenses/>.
20
21#include <type_traits>
22#include <testsuite_tr1.h>
23
24class HiddenCons
25{
26  HiddenCons();
27  HiddenCons(const HiddenCons&);
28};
29
30class DerivedHiddenCons
31: private HiddenCons
32{
33  DerivedHiddenCons();
34  DerivedHiddenCons(const DerivedHiddenCons&);
35};
36
37class MultiDerivedHiddenCons
38: private HiddenCons, private __gnu_test::ClassType
39{
40  MultiDerivedHiddenCons();
41  MultiDerivedHiddenCons(const MultiDerivedHiddenCons&);
42};
43
44void test01()
45{
46  using std::is_base_of;
47  using namespace __gnu_test;
48
49  // Positive tests.
50  static_assert(test_relationship<is_base_of, volatile ClassType,
51		ClassType>(true), "");
52  static_assert(test_relationship<is_base_of, AbstractClass,
53		AbstractClass>(true), "");
54  static_assert(test_relationship<is_base_of, ClassType,
55		DerivedType>(true), "");
56  static_assert(test_relationship<is_base_of, ClassType,
57		const DerivedType>(true), "");
58  static_assert(test_relationship<is_base_of, volatile ClassType,
59		volatile DerivedType>(true), "");
60  static_assert(test_relationship<is_base_of, PolymorphicClass,
61		DerivedPolymorphic>(true), "");
62  static_assert(test_relationship<is_base_of, HiddenCons,
63		DerivedHiddenCons>(true), "");
64  static_assert(test_relationship<is_base_of, HiddenCons,
65		MultiDerivedHiddenCons>(true), "");
66  static_assert(test_relationship<is_base_of, ClassType,
67		MultiDerivedHiddenCons>(true), "");
68
69  // Negative tests.
70  static_assert(test_relationship<is_base_of, int, int>(false), "");
71  static_assert(test_relationship<is_base_of, EnumType, EnumType>(false), "");
72  static_assert(test_relationship<is_base_of, UnionType, UnionType>(false), "");
73  static_assert(test_relationship<is_base_of, int, const int>(false), "");
74  static_assert(test_relationship<is_base_of, volatile UnionType,
75		UnionType>(false), "");
76  static_assert(test_relationship<is_base_of, int&, ClassType>(false), "");
77  static_assert(test_relationship<is_base_of, AbstractClass,
78		ClassType>(false), "");
79  static_assert(test_relationship<is_base_of, ClassType,
80		AbstractClass>(false), "");
81  static_assert(test_relationship<is_base_of, DerivedType,
82		ClassType>(false), "");
83  static_assert(test_relationship<is_base_of, DerivedPolymorphic,
84		PolymorphicClass>(false), "");
85  static_assert(test_relationship<is_base_of, DerivedHiddenCons,
86		HiddenCons>(false), "");
87  static_assert(test_relationship<is_base_of, MultiDerivedHiddenCons,
88		HiddenCons>(false), "");
89  static_assert(test_relationship<is_base_of, MultiDerivedHiddenCons,
90		ClassType>(false), "");
91}
92