public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Joseph S. Myers" <jsm@polyomino.org.uk>
To: Geoffrey Keating <geoffk@apple.com>
Cc: Gabriel Dos Reis <gdr@cs.tamu.edu>, gcc List <gcc@gcc.gnu.org>
Subject: Re: attribute data structure rewrite
Date: Fri, 24 Sep 2004 14:03:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.61.0409240837120.2844@digraph.polyomino.org.uk> (raw)
In-Reply-To: <E14DD3DE-0DF6-11D9-B012-000A95B1F520@apple.com>

On Thu, 23 Sep 2004, Geoffrey Keating wrote:

> That's a very good point.  I noticed from looking at the C front-end that an
> attribute can have as a 'value' any of:
> 
> 1. NULL
> 2. an IDENTIFIER
> 3. an expression
> 
> From that, I suspect that what's happening here is that 'N' is an identifier,
> so that rule matches in preference to treating 'N' as an expression and
> evaluating it.
> 
> I would really like to avoid case (2), or at least make sure that you can tell
> which of (2) or (3) any particular attribute should have.

That's one of the shift-reduce conflicts in the C parser, between the 
alternatives

attrib:
    /* empty */
                { $$ = NULL_TREE; }
        | any_word
                { $$ = build_tree_list ($1, NULL_TREE); }
        | any_word '(' IDENTIFIER ')'
                { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
        | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
                { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
        | any_word '(' exprlist ')'
                { $$ = build_tree_list ($1, $3); }
        ;

where an identifier might be parsed either way.  The enum case means that 
looking up the identifier to get an expression is needed for C as well as 
C++ (though of course independent from changes to datastructures).

Empty attributes are no trouble.  Many attributes have no arguments.  The 
identifier case applies (for example) to "mode" attributes, "cleanup" 
attributes (where it names a function) and some target-specific 
attributes.  The identifier followed by expression list case applies to 
format attributes.  The expression list case applies to many attributes, 
most taking one argument, some such as "nonnull" taking multiple 
arguments.  It should be well-defined for each attribute what sort of 
arguments it takes.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
  http://www.srcf.ucam.org/~jsm28/gcc/#c90status - status of C90 for GCC 4.0
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

  reply	other threads:[~2004-09-24  8:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-24  0:15 Geoffrey Keating
2004-09-24  0:34 ` Andrew Pinski
2004-09-24  1:30   ` Joseph S. Myers
2004-09-24  1:47   ` Zack Weinberg
2004-09-24  6:52   ` Geoffrey Keating
2004-09-24  1:40 ` Gabriel Dos Reis
2004-09-24  2:34   ` Giovanni Bajo
2004-09-24  2:59     ` Gabriel Dos Reis
2004-09-24  4:17       ` Giovanni Bajo
2004-09-24  4:18         ` Gabriel Dos Reis
2004-09-24  8:40     ` Andreas Schwab
2004-09-24  8:40       ` Andreas Schwab
2004-09-24  9:17     ` Joseph S. Myers
2004-09-24 14:45       ` Giovanni Bajo
2004-09-24  8:36   ` Geoffrey Keating
2004-09-24 14:03     ` Joseph S. Myers [this message]
2004-09-24  2:35 ` Giovanni Bajo
2004-09-24  8:33   ` Geoffrey Keating
2004-09-24 12:24     ` Nathan Sidwell
2004-09-24 22:29 ` Mark Mitchell

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=Pine.LNX.4.61.0409240837120.2844@digraph.polyomino.org.uk \
    --to=jsm@polyomino.org.uk \
    --cc=gcc@gcc.gnu.org \
    --cc=gdr@cs.tamu.edu \
    --cc=geoffk@apple.com \
    /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).