From: Jakub Jelinek Date: Tue, 20 Sep 2016 15:18:31 +0000 (+0200) Subject: re PR c++/77626 (ICE with -Wall on x86_64-linux-gnu (internal compiler error: Segment... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b912f962e2d8bfec7f633500e9a50fdddf867196;p=gcc.git re PR c++/77626 (ICE with -Wall on x86_64-linux-gnu (internal compiler error: Segmentation fault, byte_from_pos, cxx_fold_indirect_ref)) 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5efc79522be..0babd50d2bd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2016-09-20 Jakub Jelinek + 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 9308c548621..b7d49f19e7a 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 8ffa014add7..a15c601e33f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2016-09-20 Jakub Jelinek + 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 00000000000..d57551cbf6e --- /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); +}