re PR c++/84636 (internal compiler error: Segmentation fault (identifier_p()/grokdecl...
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 4 Dec 2018 23:48:45 +0000 (23:48 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 4 Dec 2018 23:48:45 +0000 (23:48 +0000)
/cp
2018-12-04  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/84636
* decl.c (grokdeclarator): Avoid crashing on an anonymous bit-field
with function type.

/testsuite
2018-12-04  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/84636
* g++.dg/parse/bitfield6.C: New.

From-SVN: r266807

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/bitfield6.C [new file with mode: 0644]

index d43d6132d3401b409cf5158f2a8fdbe83bc8c458..253af3ba1347a0a2296fc2aa6669a61571f9fd25 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-04  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84636
+       * decl.c (grokdeclarator): Avoid crashing on an anonymous bit-field
+       with function type.
+
 2018-12-04  Marek Polacek  <polacek@redhat.com>
 
        PR c++/88184 - ICE when treating name as template-name.
index 7d2c599a557336b4cdd463efab723fcf75c17b7b..e662f63bb0f07ffafecb8c9a3f7eb6c81e163755 100644 (file)
@@ -12187,7 +12187,8 @@ grokdeclarator (const cp_declarator *declarator,
     }
 
   if (ctype && TREE_CODE (type) == FUNCTION_TYPE && staticp < 2
-      && !(identifier_p (unqualified_id)
+      && !(unqualified_id
+          && identifier_p (unqualified_id)
           && IDENTIFIER_NEWDEL_OP_P (unqualified_id)))
     {
       cp_cv_quals real_quals = memfn_quals;
@@ -12267,8 +12268,7 @@ grokdeclarator (const cp_declarator *declarator,
            error ("invalid use of %<::%>");
            return error_mark_node;
          }
-       else if (TREE_CODE (type) == FUNCTION_TYPE
-                || TREE_CODE (type) == METHOD_TYPE)
+       else if (FUNC_OR_METHOD_TYPE_P (type) && unqualified_id)
          {
            int publicp = 0;
            tree function_context;
index c1b1bc49e3911325c0488c26a910f040276d1632..d02b6f37235939e33ddf02e49d6b4317d25ab285 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-04  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84636
+       * g++.dg/parse/bitfield6.C: New.
+
 2018-12-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/87320
diff --git a/gcc/testsuite/g++.dg/parse/bitfield6.C b/gcc/testsuite/g++.dg/parse/bitfield6.C
new file mode 100644 (file)
index 0000000..dad0b68
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/84636
+
+typedef void a();
+struct A {
+a: 1;  // { dg-error "bit-field .\\<anonymous\\>. with non-integral type" }
+};