aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/constexpr.c14
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/other/pr77626.C13
4 files changed, 26 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5efc795..0babd50 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 9308c54..b7d49f1 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -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);
}
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8ffa014..a15c601 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..d57551cb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/pr77626.C
@@ -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);
+}