diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-09-20 17:18:31 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-09-20 17:18:31 +0200 |
commit | b912f962e2d8bfec7f633500e9a50fdddf867196 (patch) | |
tree | fd9076cf102a3e661a70dbfcb096f70b77105ada /gcc | |
parent | eaf1ece1315e4fc7356e9fb24e07c4bd86c73f14 (diff) | |
download | gcc-b912f962e2d8bfec7f633500e9a50fdddf867196.zip gcc-b912f962e2d8bfec7f633500e9a50fdddf867196.tar.gz gcc-b912f962e2d8bfec7f633500e9a50fdddf867196.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/pr77626.C | 13 |
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); +} |