Commit 73a54a61 by Marek Polacek Committed by 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.
	
	* g++.dg/cpp0x/enum37.C: New test.

From-SVN: r268320
parent 9faf6e70
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
......
......@@ -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. */
......
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.
......
// 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment