From: Paolo Carlini Date: Thu, 2 Feb 2017 08:54:55 +0000 (+0000) Subject: re PR c++/69637 (ICE on an invalid bit-field with template name for width) X-Git-Tag: upstream/12.2.0~41410 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d8d58893e4b12de87af384ec2bc45342e0238ce8;p=platform%2Fupstream%2Fgcc.git re PR c++/69637 (ICE on an invalid bit-field with template name for width) /cp 2017-02-02 Paolo Carlini PR c++/69637 * decl2.c (grokbitfield): In case of error don't set-up DECL_INITIAL to the width. /testsuite 2017-02-02 Paolo Carlini PR c++/69637 * g++.dg/cpp0x/pr69637-1.C: New. * g++.dg/cpp0x/pr69637-2.C: Likewise. From-SVN: r245117 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 560bbfa..fbea09a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-02-02 Paolo Carlini + + PR c++/69637 + * decl2.c (grokbitfield): In case of error don't set-up DECL_INITIAL + to the width. + 2017-01-31 Jakub Jelinek PR c++/79304 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 86d9820..cecb6a1 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1059,8 +1059,11 @@ grokbitfield (const cp_declarator *declarator, && !INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (width))) error ("width of bit-field %qD has non-integral type %qT", value, TREE_TYPE (width)); - DECL_INITIAL (value) = width; - SET_DECL_C_BIT_FIELD (value); + else + { + DECL_INITIAL (value) = width; + SET_DECL_C_BIT_FIELD (value); + } } DECL_IN_AGGR_P (value) = 1; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5ec4a1b..a164883 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-02-02 Paolo Carlini + + PR c++/69637 + * g++.dg/cpp0x/pr69637-1.C: New. + * g++.dg/cpp0x/pr69637-2.C: Likewise. + 2017-02-02 Andreas Krebbel * gcc.target/s390/s390.exp: Rename __S390_VX__ to __VX__. diff --git a/gcc/testsuite/g++.dg/cpp0x/pr69637-1.C b/gcc/testsuite/g++.dg/cpp0x/pr69637-1.C new file mode 100644 index 0000000..b8c22eb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr69637-1.C @@ -0,0 +1,8 @@ +// { dg-do compile { target c++11 } } + +template +int foo () { return 1; } + +struct B { + unsigned c: foo; // { dg-error "non-integral type" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr69637-2.C b/gcc/testsuite/g++.dg/cpp0x/pr69637-2.C new file mode 100644 index 0000000..c652393 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr69637-2.C @@ -0,0 +1,6 @@ +// { dg-do compile { target c++11 } } + +template +constexpr int foo () { return N; } + +struct B { unsigned c: foo, 3(); }; // { dg-error "non-integral type|expected" }