From: Marek Polacek Date: Wed, 22 Feb 2017 19:33:13 +0000 (+0000) Subject: re PR c++/79657 (ICE on invalid c++ code in finish_underlying_type cp/semantics.c... X-Git-Tag: upstream/12.2.0~41032 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8fdddd3d837dac9f062236ce97e7c0be59638df1;p=platform%2Fupstream%2Fgcc.git re PR c++/79657 (ICE on invalid c++ code in finish_underlying_type cp/semantics.c:3849) PR c++/79657 * semantics.c (finish_underlying_type): Bail out for incomplete enums. * g++.dg/ext/underlying_type12.C: New test. From-SVN: r245658 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 38b60bc..c036f8c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -6,6 +6,9 @@ * pt.c (tsubst_attribute): If tsubst_pack_expansion fails, return error_mark_node. + PR c++/79657 + * semantics.c (finish_underlying_type): Bail out for incomplete enums. + 2017-02-21 Jason Merrill PR c++/50308 - wrong deprecated warning with ADL diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 6ba7c13..67f8b92 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3838,7 +3838,8 @@ finish_underlying_type (tree type) return underlying_type; } - complete_type (type); + if (!complete_type_or_else (type, NULL_TREE)) + return error_mark_node; if (TREE_CODE (type) != ENUMERAL_TYPE) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 628529b..31e7b4f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -4,6 +4,9 @@ * g++.dg/cpp0x/alignas10.C: New test. * g++.dg/cpp0x/alignas9.C: New test. + PR c++/79657 + * g++.dg/ext/underlying_type12.C: New test. + 2017-02-22 Jakub Jelinek PR target/70465 diff --git a/gcc/testsuite/g++.dg/ext/underlying_type12.C b/gcc/testsuite/g++.dg/ext/underlying_type12.C new file mode 100644 index 0000000..050ecf2 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/underlying_type12.C @@ -0,0 +1,6 @@ +// PR c++/79657 +// { dg-do compile { target c++11 } } + +enum A { x }; +enum B { a = (__underlying_type (A)) 1 }; +enum C { b = (__underlying_type (C)) 1 }; // { dg-error "incomplete" }