Fix PR c++/70590 (error: location references block not in block tree)
gcc/cp/ChangeLog: PR c++/70590 PR c++/70452 * constexpr.c (cxx_eval_outermost_expression): Call unshare_expr on the result if it's not a CONSTRUCTOR. gcc/testsuite/ChangeLog: PR c++/70590 PR c++/70452 * g++.dg/pr70590.C: New test. * g++.dg/pr70590-2.C: New test. From-SVN: r234837
This commit is contained in:
parent
abc0647a4d
commit
56cfb59670
5 changed files with 69 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
|||
2016-04-08 Patrick Palka <ppalka@gcc.gnu.org>
|
||||
|
||||
PR c++/70590
|
||||
PR c++/70452
|
||||
* constexpr.c (cxx_eval_outermost_expression): Call unshare_expr
|
||||
on the result if it's not a CONSTRUCTOR.
|
||||
|
||||
2016-04-07 Patrick Palka <ppalka@gcc.gnu.org>
|
||||
|
||||
PR c++/70452
|
||||
|
|
|
@ -4164,6 +4164,12 @@ cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant,
|
|||
if (!non_constant_p && overflow_p)
|
||||
non_constant_p = true;
|
||||
|
||||
/* Unshare the result unless it's a CONSTRUCTOR in which case it's already
|
||||
unshared. */
|
||||
bool should_unshare = true;
|
||||
if (r == t || TREE_CODE (r) == CONSTRUCTOR)
|
||||
should_unshare = false;
|
||||
|
||||
if (non_constant_p && !allow_non_constant)
|
||||
return error_mark_node;
|
||||
else if (non_constant_p && TREE_CONSTANT (r))
|
||||
|
@ -4180,6 +4186,9 @@ cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant,
|
|||
else if (non_constant_p || r == t)
|
||||
return t;
|
||||
|
||||
if (should_unshare)
|
||||
r = unshare_expr (r);
|
||||
|
||||
if (TREE_CODE (r) == CONSTRUCTOR && CLASS_TYPE_P (TREE_TYPE (r)))
|
||||
{
|
||||
if (TREE_CODE (t) == TARGET_EXPR
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2016-04-08 Patrick Palka <ppalka@gcc.gnu.org>
|
||||
|
||||
PR c++/70590
|
||||
PR c++/70452
|
||||
* g++.dg/pr70590.C: New test.
|
||||
* g++.dg/pr70590-2.C: New test.
|
||||
|
||||
2016-04-08 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR middle-end/70593
|
||||
|
|
21
gcc/testsuite/g++.dg/pr70590-2.C
Normal file
21
gcc/testsuite/g++.dg/pr70590-2.C
Normal file
|
@ -0,0 +1,21 @@
|
|||
// PR c++/70590
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-options "-O2" }
|
||||
|
||||
int a;
|
||||
|
||||
constexpr int *foo = &a;
|
||||
|
||||
void blah (int *);
|
||||
|
||||
int
|
||||
bar ()
|
||||
{
|
||||
blah (foo);
|
||||
}
|
||||
|
||||
int
|
||||
baz ()
|
||||
{
|
||||
blah (foo);
|
||||
}
|
25
gcc/testsuite/g++.dg/pr70590.C
Normal file
25
gcc/testsuite/g++.dg/pr70590.C
Normal file
|
@ -0,0 +1,25 @@
|
|||
// PR c++/70590
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-options "-O2" }
|
||||
|
||||
int a;
|
||||
|
||||
constexpr int *
|
||||
foo ()
|
||||
{
|
||||
return &a;
|
||||
}
|
||||
|
||||
void blah (int *);
|
||||
|
||||
int
|
||||
bar ()
|
||||
{
|
||||
blah (foo ());
|
||||
}
|
||||
|
||||
int
|
||||
baz ()
|
||||
{
|
||||
blah (foo ());
|
||||
}
|
Loading…
Add table
Reference in a new issue