re PR c++/69637 (ICE on an invalid bit-field with template name for width)

/cp
2017-02-02  Paolo Carlini  <paolo.carlini@oracle.com>

	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  <paolo.carlini@oracle.com>

	PR c++/69637
	* g++.dg/cpp0x/pr69637-1.C: New.
	* g++.dg/cpp0x/pr69637-2.C: Likewise.

From-SVN: r245117
This commit is contained in:
Paolo Carlini 2017-02-02 08:54:55 +00:00 committed by Paolo Carlini
parent 521a70a405
commit d8d58893e4
5 changed files with 31 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2017-02-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/69637
* decl2.c (grokbitfield): In case of error don't set-up DECL_INITIAL
to the width.
2017-01-31 Jakub Jelinek <jakub@redhat.com>
PR c++/79304

View File

@ -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;

View File

@ -1,3 +1,9 @@
2017-02-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/69637
* g++.dg/cpp0x/pr69637-1.C: New.
* g++.dg/cpp0x/pr69637-2.C: Likewise.
2017-02-02 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* gcc.target/s390/s390.exp: Rename __S390_VX__ to __VX__.

View File

@ -0,0 +1,8 @@
// { dg-do compile { target c++11 } }
template <class T>
int foo () { return 1; }
struct B {
unsigned c: foo; // { dg-error "non-integral type" }
};

View File

@ -0,0 +1,6 @@
// { dg-do compile { target c++11 } }
template <class T, int N>
constexpr int foo () { return N; }
struct B { unsigned c: foo<int>, 3(); }; // { dg-error "non-integral type|expected" }