From 7b15d957f5b6ec1467029e83d50e748100aafa53 Mon Sep 17 00:00:00 2001 From: wilson Date: Wed, 28 Oct 2015 20:02:01 +0000 Subject: [PATCH] Fix for ICE with -g on testcase with incomplete types. gcc/c/ PR debug/66068 * c-typeck.c (c_build_qualified_type): Clear C_TYPE_INCOMPLETE_VARS after calling build_qualified_type. gcc/testsuite/ PR debug/66068 * gcc.dg/debug/pr66068.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229505 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-typeck.c | 8 +++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/debug/pr66068.c | 13 +++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/debug/pr66068.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 78597bec2683..d203f9d5bef6 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2015-10-26 Jim Wilson + + PR debug/66068 + * c-typeck.c (c_build_qualified_type): Clear C_TYPE_INCOMPLETE_VARS + after calling build_qualified_type. + 2015-10-27 Cesar Philippidis Thomas Schwinge James Norris diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 64ea1c272f89..1b0b9e2a6d70 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -13126,7 +13126,13 @@ c_build_qualified_type (tree type, int type_quals) type_quals &= ~TYPE_QUAL_RESTRICT; } - return build_qualified_type (type, type_quals); + tree var_type = build_qualified_type (type, type_quals); + /* A variant type does not inherit the list of incomplete vars from the + type main variant. */ + if (TREE_CODE (var_type) == RECORD_TYPE + || TREE_CODE (var_type) == UNION_TYPE) + C_TYPE_INCOMPLETE_VARS (var_type) = 0; + return var_type; } /* Build a VA_ARG_EXPR for the C parser. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 05cad86be445..711fbb55c2e2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-26 Jim Wilson + + PR debug/66068 + * gcc.dg/debug/pr66068.c: New test. + 2015-01-28 Paul Thomas PR fortran/67933 diff --git a/gcc/testsuite/gcc.dg/debug/pr66068.c b/gcc/testsuite/gcc.dg/debug/pr66068.c new file mode 100644 index 000000000000..d9cd9050e8d7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/pr66068.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +struct S a; +const struct S b; +struct S +{ +}; + +union U c; +const union U d; +union U +{ +}; -- 2.47.3