From: Marek Polacek Date: Sun, 27 Jan 2019 19:54:29 +0000 (+0000) Subject: PR c++/89024 - ICE with incomplete enum type. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=73a54a61930af1aa355fdfb566c7a07af3a60cf8;p=gcc.git PR c++/89024 - ICE with incomplete enum type. * call.c (standard_conversion): When converting an ARITHMETIC_TYPE_P to an incomplete type, return NULL. * g++.dg/cpp0x/enum37.C: New test. From-SVN: r268320 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2d7ab90885e..c2993db781d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-01-27 Marek Polacek + + PR c++/89024 - ICE with incomplete enum type. + * call.c (standard_conversion): When converting an + ARITHMETIC_TYPE_P to an incomplete type, return NULL. + 2019-01-25 Paolo Carlini PR c++/88969 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 515a9420032..c74d1b4ebdf 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1412,6 +1412,13 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, || (fcode == REAL_TYPE && !(flags & LOOKUP_NO_NON_INTEGRAL))) || SCOPED_ENUM_P (from)) return NULL; + + /* If we're parsing an enum with no fixed underlying type, we're + dealing with an incomplete type, which renders the conversion + ill-formed. */ + if (!COMPLETE_TYPE_P (from)) + return NULL; + conv = build_conv (ck_std, to, conv); /* Give this a better rank if it's a promotion. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e4d6a1ed436..5438d4fd256 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-27 Marek Polacek + + PR c++/89024 - ICE with incomplete enum type. + * g++.dg/cpp0x/enum37.C: New test. + 2019-01-27 Eric Botcazou * gnat.dg/opt75.adb: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/enum37.C b/gcc/testsuite/g++.dg/cpp0x/enum37.C new file mode 100644 index 00000000000..6aa3d4015d7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum37.C @@ -0,0 +1,24 @@ +// PR c++/89024 +// { dg-do compile { target c++11 } } + +template struct same; +template struct same {}; + +template T&& declval(); + +template +void __test_aux(_To1); + +template(declval<_From1>()))> +char __test(int); + +template +int __test(...); + +enum E { + x = decltype(__test(0))(0) +}; + +same s; +same s2;