PR c++/86728 - C variadic generic lambda.
[official-gcc.git] / gcc / testsuite / g++.dg / rtti / typeid10.C
blob47b45b1056dd68d81c4d40b5ddb2bfa6d81a8c55
1 // PR c++/25466
2 // { dg-do run }
4 #include <typeinfo>
6 const std::type_info *a;
8 template <class T>
9 bool is_polymorphic() {
10    bool result(false);
11    const std::type_info &a1 = typeid( (result=true), *(T*)0);
12    a = &a1;
13    return result;
16 struct non_polymorphic {};
17 struct polymorphic { virtual ~polymorphic() {} };
20 int main() {
21   if (is_polymorphic<int>()) __builtin_abort();
22   if (is_polymorphic<non_polymorphic>()) __builtin_abort();
23   try
24     {
25       is_polymorphic<polymorphic>();
26       __builtin_abort(); // should have thrown bad_typeid
27     }
28   catch (std::bad_typeid&)
29     {
30       // OK
31     }
32   catch (...)
33     {
34       __builtin_abort();
35     }