re PR c++/77626 (ICE with -Wall on x86_64-linux-gnu (internal compiler error: Segment...
authorJakub Jelinek <jakub@redhat.com>
Tue, 20 Sep 2016 15:18:31 +0000 (17:18 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 20 Sep 2016 15:18:31 +0000 (17:18 +0200)
PR c++/77626
* constexpr.c (cxx_fold_indirect_ref): Don't call byte_position on
FIELD_DECLs with error_mark_node type.  Remove useless break; after
return.

* g++.dg/other/pr77626.C: New test.

From-SVN: r240267

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr77626.C [new file with mode: 0644]

index 5efc79522befdee9701538f57ac5b4ac007f4458..0babd50d2bd0be1b0103b7350520c690f70ae1c5 100644 (file)
@@ -1,5 +1,10 @@
 2016-09-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/77626
+       * constexpr.c (cxx_fold_indirect_ref): Don't call byte_position on
+       FIELD_DECLs with error_mark_node type.  Remove useless break; after
+       return.
+
        PR c++/77638
        * parser.c (cp_parser_template_declaration_after_parameter): For 2
        argument operator"" template set ok to false for
index 9308c5486217e635b564f1089f6ae3f636649c49..b7d49f19e7a3e8ee0841aa9177761e2e64bee5a3 100644 (file)
@@ -2894,13 +2894,11 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree op0, bool *empty_base)
          tree field = TYPE_FIELDS (optype);
          for (; field; field = DECL_CHAIN (field))
            if (TREE_CODE (field) == FIELD_DECL
+               && TREE_TYPE (field) != error_mark_node
                && integer_zerop (byte_position (field))
                && (same_type_ignoring_top_level_qualifiers_p
                    (TREE_TYPE (field), type)))
-             {
-               return fold_build3 (COMPONENT_REF, type, op, field, NULL_TREE);
-               break;
-             }
+             return fold_build3 (COMPONENT_REF, type, op, field, NULL_TREE);
        }
     }
   else if (TREE_CODE (sub) == POINTER_PLUS_EXPR
@@ -2972,14 +2970,12 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree op0, bool *empty_base)
              tree field = TYPE_FIELDS (op00type);
              for (; field; field = DECL_CHAIN (field))
                if (TREE_CODE (field) == FIELD_DECL
+                   && TREE_TYPE (field) != error_mark_node
                    && tree_int_cst_equal (byte_position (field), op01)
                    && (same_type_ignoring_top_level_qualifiers_p
                        (TREE_TYPE (field), type)))
-                 {
-                   return fold_build3 (COMPONENT_REF, type, op00,
-                                       field, NULL_TREE);
-                   break;
-                 }
+                 return fold_build3 (COMPONENT_REF, type, op00,
+                                     field, NULL_TREE);
            }
        }
     }
index 8ffa014add7daf84e639416491a924e41929b918..a15c601e33f0910137ea1b43ca201ea13c2737c6 100644 (file)
@@ -1,5 +1,8 @@
 2016-09-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/77626
+       * g++.dg/other/pr77626.C: New test.
+
        PR c++/77638
        * g++.dg/cpp0x/udlit-tmpl-arg-neg2.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/other/pr77626.C b/gcc/testsuite/g++.dg/other/pr77626.C
new file mode 100644 (file)
index 0000000..d57551c
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/77626
+// { dg-do compile }
+
+struct B;                      // { dg-message "forward declaration of" }
+struct A { struct B b; };      // { dg-error "has incomplete type" }
+void bar (int);
+
+void
+foo ()
+{
+  A a;
+  bar ((int &) a);
+}