public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/52957] Missing suggestions on '=' and '==' confusion
Date: Sat, 14 Apr 2012 13:16:00 -0000	[thread overview]
Message-ID: <bug-52957-4-2JllULMsm4@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <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.


  parent reply	other threads:[~2012-04-14 13:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-12 22:03 [Bug c++/52957] New: " xinliangli at gmail dot com
2012-04-12 22:54 ` [Bug c++/52957] " pinskia at gcc dot gnu.org
2012-04-12 23:00 ` pinskia at gcc dot gnu.org
2012-04-12 23:08 ` manu at gcc dot gnu.org
2012-04-12 23:29 ` xinliangli at gmail dot com
2012-04-13  1:03 ` manu at gcc dot gnu.org
2012-04-13  5:02 ` xinliangli at gmail dot com
2012-04-14 12:10 ` manu at gcc dot gnu.org
2012-04-14 12:25 ` redi at gcc dot gnu.org
2012-04-14 12:43 ` manu at gcc dot gnu.org
2012-04-14 13:16 ` redi at gcc dot gnu.org [this message]
2012-04-15  4:10 ` xinliangli at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-52957-4-2JllULMsm4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).