From 6f4f30bf3142fe3454345be587b373aa457078d3 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 10 Feb 2017 16:32:19 +0000 Subject: [PATCH] re PR c++/79435 (ICE on invalid C++ code (with member access into an incomplete type) on x86_64-linux-gnu: Segmentation fault) PR c++/79435 * pt.c (type_dependent_expression_p): Check if the expression type is null. * g++.dg/cpp1y/pr79435.C: New. From-SVN: r245334 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/pr79435.C | 6 ++++++ 4 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr79435.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0c5d1654bad..7f113ecf490 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-02-10 Marek Polacek + + PR c++/79435 + * pt.c (type_dependent_expression_p): Check if the expression type + is null. + 2017-02-10 Paolo Carlini PR c++/71737 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c23c14c9e38..712fb691903 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -23818,6 +23818,7 @@ type_dependent_expression_p (tree expression) we couldn't determine its length in cp_complete_array_type because it is dependent. */ if (VAR_P (expression) + && TREE_TYPE (expression) != NULL_TREE && TREE_CODE (TREE_TYPE (expression)) == ARRAY_TYPE && !TYPE_DOMAIN (TREE_TYPE (expression)) && DECL_INITIAL (expression)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a1cee1b2812..0c17a0362de 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-02-10 Marek Polacek + + PR c++/79435 + * g++.dg/cpp1y/pr79435.C: New. + 2017-02-10 Christophe Lyon * gcc.target/aarch64/advsimd-intrinsics/p64_p128.c diff --git a/gcc/testsuite/g++.dg/cpp1y/pr79435.C b/gcc/testsuite/g++.dg/cpp1y/pr79435.C new file mode 100644 index 00000000000..a9e467122f5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr79435.C @@ -0,0 +1,6 @@ +// PR c++/79435 +// { dg-do compile { target c++14 } } + +struct A; +extern A a; // { dg-error "'a' has incomplete type" } +template < int > int f = a.x; -- 2.30.2