Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
255a48d6
Commit
255a48d6
authored
May 31, 2015
by
Jason Merrill
Committed by
Jason Merrill
May 31, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* constexpr.c (cxx_eval_indirect_ref): Try folding first.
From-SVN: r223902
parent
6ad6af49
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
18 deletions
+25
-18
gcc/cp/ChangeLog
+2
-0
gcc/cp/constexpr.c
+23
-18
No files found.
gcc/cp/ChangeLog
View file @
255a48d6
2015-05-31 Jason Merrill <jason@redhat.com>
* constexpr.c (cxx_eval_indirect_ref): Try folding first.
PR c++/66320
* constexpr.c (cxx_eval_constant_expression): Treat a placeholder
with the wrong type as non-constant.
...
...
gcc/cp/constexpr.c
View file @
255a48d6
...
...
@@ -2427,30 +2427,31 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t,
bool
*
non_constant_p
,
bool
*
overflow_p
)
{
tree
orig_op0
=
TREE_OPERAND
(
t
,
0
);
bool
empty_base
=
false
;
/* First try to simplify it directly. */
tree
r
=
cxx_fold_indirect_ref
(
EXPR_LOCATION
(
t
),
TREE_TYPE
(
t
),
orig_op0
,
&
empty_base
);
if
(
!
r
)
{
/* If that didn't work, evaluate the operand first. */
tree
op0
=
cxx_eval_constant_expression
(
ctx
,
orig_op0
,
/*lval*/
false
,
non_constant_p
,
overflow_p
);
bool
empty_base
=
false
;
tree
r
;
/* Don't VERIFY_CONSTANT here. */
if
(
*
non_constant_p
)
return
t
;
r
=
cxx_fold_indirect_ref
(
EXPR_LOCATION
(
t
),
TREE_TYPE
(
t
),
op0
,
&
empty_base
);
if
(
r
)
r
=
cxx_eval_constant_expression
(
ctx
,
r
,
lval
,
non_constant_p
,
overflow_p
);
else
if
(
r
==
NULL_TREE
)
{
/* We couldn't fold to a constant value. Make sure it's not
something we should have been able to fold. */
tree
sub
=
op0
;
STRIP_NOPS
(
sub
);
if
(
TREE_CODE
(
sub
)
==
ADDR_EXPR
)
{
/* We couldn't fold to a constant value. Make sure it's not
something we should have been able to fold. */
gcc_assert
(
!
same_type_ignoring_top_level_qualifiers_p
(
TREE_TYPE
(
TREE_TYPE
(
sub
)),
TREE_TYPE
(
t
)));
/* DR 1188 says we don't have to deal with this. */
...
...
@@ -2461,8 +2462,20 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t,
*
non_constant_p
=
true
;
return
t
;
}
if
(
lval
&&
op0
!=
orig_op0
)
return
build1
(
INDIRECT_REF
,
TREE_TYPE
(
t
),
op0
);
if
(
!
lval
)
VERIFY_CONSTANT
(
t
);
return
t
;
}
}
r
=
cxx_eval_constant_expression
(
ctx
,
r
,
lval
,
non_constant_p
,
overflow_p
);
if
(
*
non_constant_p
)
return
t
;
/* If we're pulling out the value of an empty base, make sure
that the whole object is constant and then return an empty
CONSTRUCTOR. */
...
...
@@ -2473,14 +2486,6 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t,
TREE_CONSTANT
(
r
)
=
true
;
}
if
(
r
==
NULL_TREE
)
{
if
(
lval
&&
op0
!=
orig_op0
)
return
build1
(
INDIRECT_REF
,
TREE_TYPE
(
t
),
op0
);
if
(
!
lval
)
VERIFY_CONSTANT
(
t
);
return
t
;
}
return
r
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment