This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52957] Missing suggestions on '=' and '==' confusion
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 14 Apr 2012 13:16:18 +0000
- Subject: [Bug c++/52957] Missing suggestions on '=' and '==' confusion
- Auto-submitted: auto-generated
- References: <bug-52957-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52957
--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-04-14 13:16:18 UTC ---
(In reply to comment #9)
> (In reply to comment #8)
> Thanks for sharing this. This broadens my perception of the issues contributors
> have with GCC. That said, it should be possible right now to use a C++ wrapper
> around tree, and use that in the C++ FE (and require C++ to bootstrap the C++
> FE). What do you think about that?
I think that would help me, I don't know about others.
This is probably more suitable for the mailing list not bugzilla but it would
certainly help me if a tree is a FIELD_DECL then pass in a field_decl wrapper
around a tree, if it's a TREE_LIST pass in a tree_list wrapper around a tree.
Then functions/accessors that work on a TREE_LIST could be overloaded to work
on the wrapper, so you can use the original accessor on the raw tree if you
know what you're doing, or the type-safe overload on the wrapper which will
only compile if it's a valid operation.
But that wouldn't work when a function parameter is a tree that could be either
one type or another. That would either require the function to be refactored
to take two parameters, or some other way to have a wrapper that could be more
than one thing e.g. make the wrapper a template parameterised on by an enum
bitmask
template<tree_code C>
struct tree_wrapper
{
tree t;
explicit tree_wrapper(tree t) : t(t)
{ gcc_checking_assert ( code() & C ); }
tree_code code() const { return TREE_CODE (t); }
};
typedef tree_wrapper<TREE_LIST> tree_list;
typedef tree_wrapper<TARGET_EXPR> target_expr;
typedef tree_wrapper<CONSTRUCTOR> constructor;
// etc.
void f( tree_list list );
void g( target_expr expr );
void h( tree_wrapper<TREE_LIST|TARGET_EXPR> tree )
{
if (tree.code() == TREE_LIST)
f( tree_list(tree.t) );
else
g( target_expr(tree.t) );
}
> Well, the wiki is just a minor example, but it is awfully slow, nobody has
> administrator login (I can access as Daniel Berlin and ban users, but little
> more), and it is a unsupported version with known security issues.
Ah yes, I see what you mean now.