Skip to content

Commit dcd9853

Browse files
committed
add tests
1 parent 83d1532 commit dcd9853

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

clang/test/SemaCXX/decltype.cpp

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,44 @@ struct A {
157157
}
158158
};
159159

160+
161+
162+
// This shouldn't crash.
163+
static_assert(A<int>().f<int>() == 0, "");
164+
// The result should not be dependent.
165+
static_assert(A<int>().f<int>() != 0, ""); // expected-error {{static assertion failed due to requirement 'GH99873::A<int>().f<int>() != 0'}}
166+
// expected-note@-1 {{expression evaluates to '0 != 0'}}
167+
}
168+
169+
160170
#if __cplusplus >= 201703L
161171
namespace GH160497 {
162172

163173
template <class> struct S {
164174
template <class>
165-
static inline auto mem =
175+
inline static auto mem =
166176
[] { static_assert(false); // expected-error {{static assertion failed}} \
167177
// expected-note {{while substituting into a lambda expression here}}
168178
return 42;
169179
}();
170180
};
171181

172182
using T = decltype(S<void>::mem<void>);
173-
// expected-note@-1 {{in instantiation of static data member 'GH99873::GH160497::S<void>::mem<void>' requested here}}
183+
// expected-note@-1 {{in instantiation of static data member 'GH160497::S<void>::mem<void>' requested here}}
184+
185+
186+
template <class> struct S2 {
187+
template <class>
188+
inline static auto* mem =
189+
[] { static_assert(false); // expected-error {{static assertion failed}} \
190+
// expected-note {{while substituting into a lambda expression here}}
191+
return static_cast<int*>(nullptr);
192+
}();
193+
};
194+
195+
196+
using T2 = decltype(S2<void>::mem<void>);
197+
//expected-note@-1 {{in instantiation of static data member 'GH160497::S2<void>::mem<void>' requested here}}
174198

175199
namespace N1 {
176200

@@ -188,13 +212,6 @@ T y = 42;
188212
}
189213
#endif
190214

191-
// This shouldn't crash.
192-
static_assert(A<int>().f<int>() == 0, "");
193-
// The result should not be dependent.
194-
static_assert(A<int>().f<int>() != 0, ""); // expected-error {{static assertion failed due to requirement 'GH99873::A<int>().f<int>() != 0'}}
195-
// expected-note@-1 {{expression evaluates to '0 != 0'}}
196-
}
197-
198215
template<typename>
199216
class conditional {
200217
};

0 commit comments

Comments
 (0)