Gradual 'tree' typing and C++
Richard Biener
richard.guenther@gmail.com
Wed Jul 22 08:16:18 GMT 2026
On Wed, Jul 22, 2026 at 9:31 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Wed, Jul 22, 2026 at 09:06:58AM +0200, Richard Biener wrote:
> > That said, I also believe trying to get tree more strongly typed using C++
> > is not going to be an improvement. That might be the fault of C++ though.
> >
> > Possibly doing sth like
> >
> > extern tree fold_build2_loc (location_t, enum tree_code, tree_type, tree,
> > tree CXX_MEM_STAT_INFO);
> >
> > with checking-enabled tree_type expanding to assertion (but otherwise just
> > being a no-op wrapper), and possibly allowing type assertions and/or
> > automatic annotation for static analysis might be an improvement?
>
> Usually something inside of fold_build2_loc actually accesses some
> properties of the type and type checking triggers there. So, by moving
> that check earlier, all we'd achieve is to assert one or two frames up
> in the callstack.
> With types vs. non-types, there is also the complication what is
> error_mark_node, currently we treat it as both expression and type, but
> with limited usability, TREE_TYPE (error_mark_node) is error_mark_node.
I think I was suggesting to have ERROR_TYPE/error_type_node at some
point. That would
be a requirement for any of this. It would also avoid some ice-on-invalid
where type accessors are used on error_mark_node without a prior
check for this case (but possibly only delay those).
Richard.
>
> Jakub
>
More information about the Gcc
mailing list