diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-09 05:12:03 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-09 05:12:03 +0000 |
commit | c4118b0c744f9fbe95ccf9db45b5aaf71042380e (patch) | |
tree | 359b47855f934495611d898ba25a3f1b9d21d4b8 | |
parent | b4af519ad1cd4be276a5c1a38320c3420ede9545 (diff) | |
download | gcc-c4118b0c744f9fbe95ccf9db45b5aaf71042380e.tar.gz |
PR c++/69158
* constexpr.c (cxx_fold_indirect_ref): Handle array type differing
in completion.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232186 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/array40.C | 2 |
3 files changed, 17 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 49dc0cfc5c3..8723cad590c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-01-08 Jason Merrill <jason@redhat.com> + + PR c++/69158 + * constexpr.c (cxx_fold_indirect_ref): Handle array type differing + in completion. + 2016-01-08 Marek Polacek <polacek@redhat.com> PR c++/68449 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 7b6027138f2..e60180ee6cd 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -2382,7 +2382,15 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree op0, bool *empty_base) if (TREE_CODE (op) == CONST_DECL) return DECL_INITIAL (op); /* *&p => p; make sure to handle *&"str"[cst] here. */ - if (same_type_ignoring_top_level_qualifiers_p (optype, type)) + if (same_type_ignoring_top_level_qualifiers_p (optype, type) + /* Also handle the case where the desired type is an array of unknown + bounds because the variable has had its bounds deduced since the + ADDR_EXPR was created. */ + || (TREE_CODE (type) == ARRAY_TYPE + && TREE_CODE (optype) == ARRAY_TYPE + && TYPE_DOMAIN (type) == NULL_TREE + && same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (optype), + TREE_TYPE (type)))) { tree fop = fold_read_from_constant_string (op); if (fop) diff --git a/gcc/testsuite/g++.dg/init/array40.C b/gcc/testsuite/g++.dg/init/array40.C new file mode 100644 index 00000000000..5c976e2a0bd --- /dev/null +++ b/gcc/testsuite/g++.dg/init/array40.C @@ -0,0 +1,2 @@ +// PR c++/69158 +char IdHdr[] = { (IdHdr)[0] }; |