From: Marek Polacek Date: Tue, 14 Feb 2017 17:33:21 +0000 (+0000) Subject: re PR c++/79420 (ICE on invalid C++ code on x86_64-linux-gnu: in tsubst_copy, at... X-Git-Tag: upstream/12.2.0~41177 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f207d5810934c0156cda61a12a56ff1915adb79;p=platform%2Fupstream%2Fgcc.git re PR c++/79420 (ICE on invalid C++ code on x86_64-linux-gnu: in tsubst_copy, at cp/pt.c:14573) PR c++/79420 PR c++/79463 * parser.c (cp_parser_postfix_dot_deref_expression): Avoid clobbering if the postfix expression isn't an EXPR_P. * g++.dg/cpp1y/pr79463.C: New. * g++.dg/template/incomplete10.C: New. * g++.dg/template/incomplete9.C: New. From-SVN: r245440 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3d840c5..7b94d3b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2017-02-14 Marek Polacek + + PR c++/79420 + PR c++/79463 + * parser.c (cp_parser_postfix_dot_deref_expression): Avoid + clobbering if the postfix expression isn't an EXPR_P. + 2017-02-13 Jason Merrill PR c++/79461 - ICE with lambda in constexpr constructor diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index ce45bba..ccafefd 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -7331,7 +7331,9 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, (scope, current_class_type)))) { scope = complete_type (scope); - if (!COMPLETE_TYPE_P (scope)) + if (!COMPLETE_TYPE_P (scope) + /* Avoid clobbering e.g. OVERLOADs or DECLs. */ + && EXPR_P (postfix_expression)) { /* In a template, be permissive by treating an object expression of incomplete type as dependent (after a pedwarn). */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 071f38f..be1ea5c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-02-14 Marek Polacek + + PR c++/79420 + PR c++/79463 + * g++.dg/cpp1y/pr79463.C: New. + * g++.dg/template/incomplete10.C: New. + * g++.dg/template/incomplete9.C: New. + 2017-02-14 H.J. Lu PR target/79498 diff --git a/gcc/testsuite/g++.dg/cpp1y/pr79463.C b/gcc/testsuite/g++.dg/cpp1y/pr79463.C new file mode 100644 index 0000000..fdf668b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr79463.C @@ -0,0 +1,7 @@ +// PR c++/79463 +// { dg-options "-g" } +// { dg-do compile { target c++14 } } + +struct A; +extern A a; // { dg-error "'a' has incomplete type" } +template < int > int f = a.x; diff --git a/gcc/testsuite/g++.dg/template/incomplete10.C b/gcc/testsuite/g++.dg/template/incomplete10.C new file mode 100644 index 0000000..f0b406d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/incomplete10.C @@ -0,0 +1,13 @@ +// PR c++/79420 + +struct S; +extern S s; // { dg-error "'s' has incomplete type" } +template int f () +{ + return s.x; +} + +void g () +{ + f<0> (); +} diff --git a/gcc/testsuite/g++.dg/template/incomplete9.C b/gcc/testsuite/g++.dg/template/incomplete9.C new file mode 100644 index 0000000..9e03232 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/incomplete9.C @@ -0,0 +1,11 @@ +// PR c++/79420 + +template int f () +{ + return f.x; // { dg-error "overloaded function with no contextual type information" } +} + +void g () +{ + f<0> (); +}