c++: ICE on enum with bool value [PR99968]
authorJason Merrill <jason@redhat.com>
Tue, 28 Dec 2021 04:46:13 +0000 (23:46 -0500)
committerJason Merrill <jason@redhat.com>
Tue, 28 Dec 2021 17:46:16 +0000 (12:46 -0500)
BOOLEAN_TYPE also counts as integral, so verify_type should allow it.

PR c++/99968

gcc/ChangeLog:

* tree.c (verify_type): Allow enumerator with BOOLEAN_TYPE.

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_enum2.C: New test.

gcc/testsuite/g++.dg/ext/is_enum2.C [new file with mode: 0644]
gcc/tree.c

diff --git a/gcc/testsuite/g++.dg/ext/is_enum2.C b/gcc/testsuite/g++.dg/ext/is_enum2.C
new file mode 100644 (file)
index 0000000..de14d6a
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/99968
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -g }
+
+template <class T> struct A {
+  using type = T;
+  static const bool value = false;
+};
+
+enum E { e0 = __is_enum(E), e1 = A<E>::value };
index 0741e3b..d68d694 100644 (file)
@@ -13704,6 +13704,7 @@ verify_type (const_tree t)
            error_found = true;
          }
        if (TREE_CODE (TREE_TYPE (value)) != INTEGER_TYPE
+           && TREE_CODE (TREE_TYPE (value)) != BOOLEAN_TYPE
            && !useless_type_conversion_p (const_cast <tree> (t), TREE_TYPE (value)))
          {
            error ("enum value type is not %<INTEGER_TYPE%> nor convertible "