* What is the difference between datatype "const_tree" and "tree" ?
[not found] <1944714078.2881309.1530766716580.ref@mail.yahoo.com>
@ 2018-07-05 4:58 ` å 人 ç via gcc
2018-07-05 13:29 ` David Malcolm
0 siblings, 1 reply; 2+ messages in thread
From: å 人 ç via gcc @ 2018-07-05 4:58 UTC (permalink / raw)
To: gcc
In the function emit_side_effect_warnings, I find its inputs are "location_t loc" and "tree expr".
And, there is a function warn_if_unused_value called by emit_side_effect_warnings:
emit_side_effect_warnings(location_t loc, tree expr){ ...
else
warn_if_unused_value(expr,loc)
}
To call warn_if_unused_value, we use location_t loc and tree expr as inputs
In the function warn_if_unused_value, I find its inputs are "location_t loc" and "const_tree expr"
warn_if_unused_value(const_tree exp, location_t locus){ ...
}
I am confused about the difference between "tree expr" and "const_tree expr" since
if I modify the"const_tree" to "tree", I make failed.
Besides this, I try to use debug_tree function to dump the imformation of the node.
I am successful when I use it in the function emit_side_effect_warnings but
not in the function warn_if_unused_value
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: What is the difference between datatype "const_tree" and "tree" ?
2018-07-05 4:58 ` What is the difference between datatype "const_tree" and "tree" ? å 人 ç via gcc
@ 2018-07-05 13:29 ` David Malcolm
0 siblings, 0 replies; 2+ messages in thread
From: David Malcolm @ 2018-07-05 13:29 UTC (permalink / raw)
To: 冠人 王, gcc
On Thu, 2018-07-05 at 04:58 +0000, å 人 ç via gcc wrote:
> In the function emit_side_effect_warnings, I find its inputs are
> "location_t loc" and "tree expr".
> And, there is a function warn_if_unused_value called by
> emit_side_effect_warnings:
> emit_side_effect_warnings(location_t loc, tree expr){ ...
> else
> warn_if_unused_value(expr,loc)
> }
>
> To call warn_if_unused_value, we use location_t loc and tree expr as
> inputs
> In the function warn_if_unused_value, I find its inputs are
> "location_t loc" and "const_tree expr"
> warn_if_unused_value(const_tree exp, location_t locus){ ...
> }
> I am confused about the difference between "tree expr" and
> "const_tree expr" since
> if I modify the"const_tree" to "tree", I make failed.
The pertinent typedefs are in gcc/coretypes.h
tree is defined via:
typedef union tree_node *tree;
i.e. "tree" is a "union tree_node *".
const_tree is almost the same:
typedef const union tree_node *const_tree;
i.e. "const_tree" is a "const union tree_node *".
Both are pointers to tree_node union, but const_tree is a pointer to a
const union i.e. it promises not to write to the node.
You didn't show us the error message, so I can only guess the problem,
but my guess is that by changing it from "const_tree" to "tree", the
function is no longer promising not to write to the node, and thus
violating constness of something that calls that function.
> Besides this, I try to use debug_tree function to dump the
> imformation of the node.
> I am successful when I use it in the function
> emit_side_effect_warnings but
> not in the function warn_if_unused_value
I see that debug_tree takes a "tree", rather than a "const_tree". I'm
guessing that that's a bug, and ought to be fixed.
You can probably work around it for now by casting the const_tree back
to a tree:
debug_tree ((const_tree)exp);
or similar.
Hope this is helpful; good luck.
Dave
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-05 13:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1944714078.2881309.1530766716580.ref@mail.yahoo.com>
2018-07-05 4:58 ` What is the difference between datatype "const_tree" and "tree" ? å 人 ç via gcc
2018-07-05 13:29 ` David Malcolm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).