]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/84792 (ICE with broken typedef of a struct)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 5 Apr 2018 17:05:03 +0000 (17:05 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 5 Apr 2018 17:05:03 +0000 (17:05 +0000)
/cp
2018-04-05  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/84792
* decl.c (grokdeclarator): Fix diagnostic about typedef name used
as nested-name-specifier, keep type and TREE_TYPE (decl) in sync.

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

PR c++/84792
* g++.dg/other/pr84792-1.C: New.
* g++.dg/other/pr84792-2.C: Likewise.

From-SVN: r259136

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr84792-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/pr84792-2.C [new file with mode: 0644]

index a876dc9bffdf74e0cc53d2c9c4746c9f7e86a7fa..0d60ed00a7de793623896b32384f1b1948ea7b92 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-05  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84792
+       * decl.c (grokdeclarator): Fix diagnostic about typedef name used
+       as nested-name-specifier, keep type and TREE_TYPE (decl) in sync.
+
 2018-04-05  Jason Merrill  <jason@redhat.com>
 
        PR c++/82152 - ICE with class deduction and inherited ctor.
index b2e509e4d05c36da8892dec8b742c5421c2e49d7..489dcc0a8ed9b3b12feef8971180cf406bdbc2ef 100644 (file)
@@ -11766,15 +11766,16 @@ grokdeclarator (const cp_declarator *declarator,
       if (reqs)
        error_at (location_of (reqs), "requires-clause on typedef");
 
+      if (id_declarator && declarator->u.id.qualifying_scope)
+       {
+         error ("typedef name may not be a nested-name-specifier");
+         type = error_mark_node;
+       }
+
       if (decl_context == FIELD)
        decl = build_lang_decl (TYPE_DECL, unqualified_id, type);
       else
        decl = build_decl (input_location, TYPE_DECL, unqualified_id, type);
-      if (id_declarator && declarator->u.id.qualifying_scope) {
-       error_at (DECL_SOURCE_LOCATION (decl), 
-                 "typedef name may not be a nested-name-specifier");
-       TREE_TYPE (decl) = error_mark_node;
-      }
 
       if (decl_context != FIELD)
        {
index 45fecfb27bf3b65d9f70a6e8719e15b35fe6e641..a94044ebc3a7cc4e2e184057618ae6e6c4bafddf 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-05  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84792
+       * g++.dg/other/pr84792-1.C: New.
+       * g++.dg/other/pr84792-2.C: Likewise.
+
 2018-04-05  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/85193
diff --git a/gcc/testsuite/g++.dg/other/pr84792-1.C b/gcc/testsuite/g++.dg/other/pr84792-1.C
new file mode 100644 (file)
index 0000000..23df8ae
--- /dev/null
@@ -0,0 +1,6 @@
+struct A {};
+
+typedef struct
+{
+  virtual void foo() {}
+} A::B;  // { dg-error "typedef" }
diff --git a/gcc/testsuite/g++.dg/other/pr84792-2.C b/gcc/testsuite/g++.dg/other/pr84792-2.C
new file mode 100644 (file)
index 0000000..a393d57
--- /dev/null
@@ -0,0 +1,6 @@
+struct A {};
+
+typedef struct
+{
+  void foo() {}
+} A::B;  // { dg-error "typedef" }
This page took 0.099091 seconds and 5 git commands to generate.