1 // RUN: %cheri_cc1 -fno-rtti -std=c++14 -target-abi purecap -fsyntax-only -fdump-record-layouts %s -emit-llvm -o /dev/null | %cheri_FileCheck %s
2 // CHECK: *** Dumping AST Record Layout
3 // CHECK-NEXT: 0 | class error_category
4 // CHECK-NEXT: 0 | (error_category vtable pointer)
5 // CHECK-NEXT: | [sizeof=[[#CAP_SIZE]],
6 // CHECK-SAME: dsize=[[#CAP_SIZE]], align=[[#CAP_SIZE]],
7 // CHECK-NEXT: | nvsize=[[#CAP_SIZE]], nvalign=[[#CAP_SIZE]]]
8
9 // CHECK: *** Dumping AST Record Layout
10 // CHECK-NEXT: 0 | class __do_message
11 // CHECK-NEXT: 0 | class error_category (primary base)
12 // CHECK-NEXT: 0 | (error_category vtable pointer)
13 // CHECK-NEXT: | [sizeof=[[#CAP_SIZE]], dsize=[[#CAP_SIZE]], align=[[#CAP_SIZE]],
14 // CHECK-NEXT: | nvsize=[[#CAP_SIZE]], nvalign=[[#CAP_SIZE]]]
15
16
17 // CHECK: *** Dumping AST Record Layout
18 // CHECK-NEXT: 0 | class __future_error_category
19 // CHECK-NEXT: 0 | class __do_message (primary base)
20 // CHECK-NEXT: 0 | class error_category (primary base)
21 // CHECK-NEXT: 0 | (error_category vtable pointer)
22 // CHECK-NEXT: | [sizeof=[[#CAP_SIZE]], dsize=[[#CAP_SIZE]], align=[[#CAP_SIZE]],
23 // CHECK-NEXT: | nvsize=[[#CAP_SIZE]], nvalign=[[#CAP_SIZE]]]
24
25
26 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
27 #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
28 #define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
29 #define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
30 #define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
31 #define _NOEXCEPT noexcept
32 #define _NOEXCEPT_(x) noexcept(x)
33 #define _LIBCPP_DEFAULT = default;
34
35 class string;
36 class error_code;
37 class error_condition;
38
39
40 class _LIBCPP_HIDDEN __do_message;
41
42 class _LIBCPP_TYPE_VIS error_category
43 {
44 public:
45 virtual ~error_category() _NOEXCEPT;
46
47 #if defined(_LIBCPP_BUILDING_SYSTEM_ERROR) && \
48 defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
49 error_category() _NOEXCEPT;
50 #else
51 _LIBCPP_ALWAYS_INLINE
52 _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT
53 #endif
54 private:
55 error_category(const error_category&);// = delete;
56 error_category& operator=(const error_category&);// = delete;
57
58 public:
59 virtual const char* name() const _NOEXCEPT = 0;
60 virtual error_condition default_error_condition(int __ev) const _NOEXCEPT;
61 virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT;
62 virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT;
63 virtual string message(int __ev) const = 0;
64
65 _LIBCPP_ALWAYS_INLINE
operator ==(const error_category & __rhs) const66 bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;}
67
68 _LIBCPP_ALWAYS_INLINE
operator !=(const error_category & __rhs) const69 bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);}
70
71 _LIBCPP_ALWAYS_INLINE
operator <(const error_category & __rhs) const72 bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;}
73
74 friend class _LIBCPP_HIDDEN __do_message;
75 };
76
77
78 class _LIBCPP_HIDDEN __do_message
79 : public error_category
80 {
81 public:
82 virtual string message(int ev) const;
83 };
84
85 class _LIBCPP_HIDDEN __future_error_category
86 : public __do_message
87 {
88 public:
89 virtual const char* name() const _NOEXCEPT;
90 virtual string message(int ev) const;
91 };
92
93 _LIBCPP_FUNC_VIS
94 const error_category& future_category() _NOEXCEPT;
95
96 const error_category&
future_category()97 future_category() _NOEXCEPT
98 {
99 static __future_error_category __f;
100 return __f;
101 }
102
main()103 int main() {
104 // FIXME this crashes clang?
105 // return &future_category() != (void*)0x12345667;
106 (void)future_category();
107 return 1;
108 }
109