diff options
author | Marek Polacek <polacek@redhat.com> | 2019-01-27 19:54:29 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2019-01-27 19:54:29 +0000 |
commit | 73a54a61930af1aa355fdfb566c7a07af3a60cf8 (patch) | |
tree | 08f37ac4f396d13388fd0ec1e39979593257cc50 | |
parent | 9faf6e70187e2a425ae2c502b8c00dded63e6460 (diff) | |
download | gcc-73a54a61930af1aa355fdfb566c7a07af3a60cf8.zip gcc-73a54a61930af1aa355fdfb566c7a07af3a60cf8.tar.gz gcc-73a54a61930af1aa355fdfb566c7a07af3a60cf8.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/enum37.C | 24 |
4 files changed, 42 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2d7ab90..c2993db 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-01-27 Marek Polacek <polacek@redhat.com> + + 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 <paolo.carlini@oracle.com> PR c++/88969 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 515a942..c74d1b4 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 e4d6a1e..5438d4f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-27 Marek Polacek <polacek@redhat.com> + + PR c++/89024 - ICE with incomplete enum type. + * g++.dg/cpp0x/enum37.C: New test. + 2019-01-27 Eric Botcazou <ebotcazou@adacore.com> * 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 0000000..6aa3d40 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum37.C @@ -0,0 +1,24 @@ +// PR c++/89024 +// { dg-do compile { target c++11 } } + +template <class T, class U> struct same; +template <class T> struct same<T,T> {}; + +template<class T> T&& declval(); + +template<typename _To1> +void __test_aux(_To1); + +template<typename _From1, typename _To1, + typename = decltype(__test_aux<_To1>(declval<_From1>()))> +char __test(int); + +template<typename, typename> +int __test(...); + +enum E { + x = decltype(__test<E, int>(0))(0) +}; + +same<E,decltype(x)> s; +same<unsigned int,__underlying_type(E)> s2; |