From 152ef731950c9b35e6bab40b30d60027bb996254 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 29 Jun 2016 00:30:04 +0200 Subject: [PATCH] re PR c/71685 (Segmentation fault in gcc when compiling the attached file.) PR c/71685 * c-typeck.c (c_build_qualified_type): Don't clear C_TYPE_INCOMPLETE_VARS for the main variant. * gcc.dg/pr71685.c: New test. From-SVN: r237830 --- gcc/c/ChangeLog | 8 +++++++- gcc/c/c-typeck.c | 3 ++- gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/gcc.dg/pr71685.c | 6 ++++++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr71685.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 403f267b612..df73934ca94 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,4 +1,10 @@ -2016-06-28 Martin Sebor +2016-06-29 Jakub Jelinek + + PR c/71685 + * c-typeck.c (c_build_qualified_type): Don't clear + C_TYPE_INCOMPLETE_VARS for the main variant. + +2016-06-28 Martin Sebor PR c/71552 * c-typeck.c (output_init_element): Diagnose incompatible types diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 818ad944f3f..56268fcc843 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -13676,7 +13676,8 @@ c_build_qualified_type (tree type, int type_quals, tree orig_qual_type, : build_qualified_type (type, type_quals)); /* A variant type does not inherit the list of incomplete vars from the type main variant. */ - if (RECORD_OR_UNION_TYPE_P (var_type)) + if (RECORD_OR_UNION_TYPE_P (var_type) + && TYPE_MAIN_VARIANT (var_type) != var_type) C_TYPE_INCOMPLETE_VARS (var_type) = 0; return var_type; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5fb67e13288..171e616d045 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,4 +1,9 @@ -2016-06-28 Martin Sebor +2016-06-29 Jakub Jelinek + + PR c/71685 + * gcc.dg/pr71685.c: New test. + +2016-06-28 Martin Sebor PR c/71552 * gcc.dg/init-bad-9.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr71685.c b/gcc/testsuite/gcc.dg/pr71685.c new file mode 100644 index 00000000000..80e5c8f5902 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr71685.c @@ -0,0 +1,6 @@ +/* PR c/71685 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +extern struct S v, s; +struct S { int t; int p[]; } v = { 4, 0 }; -- 2.30.2