From: Jason Merrill Date: Tue, 28 Dec 2021 04:46:13 +0000 (-0500) Subject: c++: ICE on enum with bool value [PR99968] X-Git-Tag: upstream/12.2.0~2561 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db25655fa5dd23bba684ec7db628643c19e64d6a;p=platform%2Fupstream%2Fgcc.git c++: ICE on enum with bool value [PR99968] 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. --- diff --git a/gcc/testsuite/g++.dg/ext/is_enum2.C b/gcc/testsuite/g++.dg/ext/is_enum2.C new file mode 100644 index 0000000..de14d6a --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_enum2.C @@ -0,0 +1,10 @@ +// PR c++/99968 +// { dg-do compile { target c++11 } } +// { dg-additional-options -g } + +template struct A { + using type = T; + static const bool value = false; +}; + +enum E { e0 = __is_enum(E), e1 = A::value }; diff --git a/gcc/tree.c b/gcc/tree.c index 0741e3b..d68d694 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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 (t), TREE_TYPE (value))) { error ("enum value type is not % nor convertible "