diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-03-27 23:07:21 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-03-27 23:07:21 +0200 |
commit | a9e4a1a56fb8e99594b65d6640432ba29c705f3e (patch) | |
tree | 2a71ba738ce8094ef17accb652eb7b850caad814 /gcc/cp/typeck.c | |
parent | aade772d8a2eeda4ea22f0ca648ebdf44d8d8c15 (diff) | |
download | gcc-a9e4a1a56fb8e99594b65d6640432ba29c705f3e.zip gcc-a9e4a1a56fb8e99594b65d6640432ba29c705f3e.tar.gz gcc-a9e4a1a56fb8e99594b65d6640432ba29c705f3e.tar.bz2 |
re PR target/80162 (ICE on invalid code (address of register variable))
PR middle-end/80162
c-family/
* c-common.c (c_common_mark_addressable_vec): Don't set
TREE_ADDRESSABLE on DECL_HARD_REGISTER.
c/
* c-tree.h (c_mark_addressable): Add array_ref_p argument.
* c-typeck.c (c_mark_addressable): Likewise. Look through
VIEW_CONVERT_EXPR unless array_ref_p and VCE is from VECTOR_TYPE
to ARRAY_TYPE.
(build_array_ref): Pass true as array_ref_p to c_mark_addressable.
cp/
* cp-tree.h (cxx_mark_addressable): Add array_ref_p argument.
* typeck.c (cxx_mark_addressable): Likewise. Look through
VIEW_CONVERT_EXPR unless array_ref_p and VCE is from VECTOR_TYPE
to ARRAY_TYPE.
(cp_build_array_ref): Pass true as array_ref_p to cxx_mark_addressable.
testsuite/
* c-c++-common/pr80162-1.c: New test.
* c-c++-common/pr80162-2.c: New test.
* c-c++-common/pr80162-3.c: New test.
From-SVN: r246512
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r-- | gcc/cp/typeck.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 4e9a1c0..79391c0 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3217,7 +3217,7 @@ cp_build_array_ref (location_t loc, tree array, tree idx, && (TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))) { - if (!cxx_mark_addressable (array)) + if (!cxx_mark_addressable (array, true)) return error_mark_node; } @@ -6269,18 +6269,28 @@ unary_complex_lvalue (enum tree_code code, tree arg) /* Mark EXP saying that we need to be able to take the address of it; it should not be allocated in a register. - Value is true if successful. + Value is true if successful. ARRAY_REF_P is true if this + is for ARRAY_REF construction - in that case we don't want + to look through VIEW_CONVERT_EXPR from VECTOR_TYPE to ARRAY_TYPE, + it is fine to use ARRAY_REFs for vector subscripts on vector + register variables. C++: we do not allow `current_class_ptr' to be addressable. */ bool -cxx_mark_addressable (tree exp) +cxx_mark_addressable (tree exp, bool array_ref_p) { tree x = exp; while (1) switch (TREE_CODE (x)) { + case VIEW_CONVERT_EXPR: + if (array_ref_p + && TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE + && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (x, 0)))) + return true; + /* FALLTHRU */ case ADDR_EXPR: case COMPONENT_REF: case ARRAY_REF: |