re PR c++/69637 (ICE on an invalid bit-field with template name for width)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 2 Feb 2017 08:54:55 +0000 (08:54 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 2 Feb 2017 08:54:55 +0000 (08:54 +0000)
/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

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr69637-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr69637-2.C [new file with mode: 0644]

index 560bbfab3e859562097fc999789d89f2f32f1e77..fbea09af7fc47aaf221eef725b6c91bee41e2c15 100644 (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
index 86d98202f0d733f4f595940adf089263cdd75942..cecb6a145b707a7bc249f008b699ec8a0b951582 100644 (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;
index 5ec4a1b3a2da3ae5fb8e17803795c721d4ca70cc..a164883c20417399ce7e9a1e6210d813ff373a6a 100644 (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__.
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr69637-1.C b/gcc/testsuite/g++.dg/cpp0x/pr69637-1.C
new file mode 100644 (file)
index 0000000..b8c22eb
--- /dev/null
@@ -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 (file)
index 0000000..c652393
--- /dev/null
@@ -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" }