aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2017-02-02 08:54:55 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2017-02-02 08:54:55 +0000
commitd8d58893e4b12de87af384ec2bc45342e0238ce8 (patch)
tree4345a0724bf51384c4f8523ef2aba2ce4496accb
parent521a70a405539df8f0a573091c9ceb46c31be5f5 (diff)
downloadgcc-d8d58893e4b12de87af384ec2bc45342e0238ce8.zip
gcc-d8d58893e4b12de87af384ec2bc45342e0238ce8.tar.gz
gcc-d8d58893e4b12de87af384ec2bc45342e0238ce8.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c7
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr69637-1.C8
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr69637-2.C6
5 files changed, 31 insertions, 2 deletions
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 <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
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 <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__.
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 <class T>
+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 <class T, int N>
+constexpr int foo () { return N; }
+
+struct B { unsigned c: foo<int>, 3(); }; // { dg-error "non-integral type|expected" }