public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: David Faust <david.faust@oracle.com>
Cc: <gcc-patches@gcc.gnu.org>, Yonghong Song <yhs@fb.com>
Subject: Re: [ping2][PATCH 0/8][RFC] Support BTF decl_tag and type_tag annotations
Date: Tue, 3 May 2022 22:32:44 +0000	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2205032222500.688351@digraph.polyomino.org.uk> (raw)
In-Reply-To: <bf0a0918-33b5-a1ac-f678-74d2b4909e6d@oracle.com>

On Mon, 2 May 2022, David Faust via Gcc-patches wrote:

> Consider the following example:
> 
>    #define __typetag1 __attribute__((btf_type_tag("tag1")))
>    #define __typetag2 __attribute__((btf_type_tag("tag2")))
>    #define __typetag3 __attribute__((btf_type_tag("tag3")))
> 
>    int __typetag1 * __typetag2 __typetag3 * g;
> 
> The expected behavior is that 'g' is "a pointer with tags 'tag2' and 'tag3',
> to a pointer with tag 'tag1' to an int". i.e.:

That's not a correct expectation for either GNU __attribute__ or C2x [[]] 
attribute syntax.  In either syntax, __typetag2 __typetag3 should apply to 
the type to which g points, not to g or its type, just as if you had a 
type qualifier there.  You'd need to put the attributes (or qualifier) 
after the *, not before, to make them apply to the pointer type.  See 
"Attribute Syntax" in the GCC manual for how the syntax is defined for GNU 
attributes and deduce in turn, for each subsequence of the tokens matching 
the syntax for some kind of declarator, what the type for "T D1" would be 
as defined there and in the C standard, as deduced from the type for "T D" 
for a sub-declarator D.

> But GCC's attribute parsing produces a variable 'g' which is "a pointer with
> tag 'tag1' to a pointer with tags 'tag2' and 'tag3' to an int", i.e.

In GNU syntax, __typetag1 applies to the declaration, whereas in C2x 
syntax it applies to int.  Again, if you wanted it to apply to the pointer 
type it would need to go after the * not before.

If you are concerned with the fine details of what construct an attribute 
appertains to, I recommend using C2x syntax not GNU syntax.

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2022-05-03 22:32 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-01 19:42 [PATCH " David Faust
2022-04-01 19:42 ` [PATCH 1/8] dwarf: Add dw_get_die_parent function David Faust
2022-04-01 19:42 ` [PATCH 2/8] include: Add BTF tag defines to dwarf2 and btf David Faust
2022-04-01 19:42 ` [PATCH 3/8] c-family: Add BTF tag attribute handlers David Faust
2022-04-01 19:42 ` [PATCH 4/8] dwarf: create BTF decl and type tag DIEs David Faust
2022-04-01 19:42 ` [PATCH 5/8] ctfc: Add support to pass through BTF annotations David Faust
2022-04-01 19:42 ` [PATCH 6/8] dwarf2ctf: convert tag DIEs to CTF types David Faust
2022-04-01 19:42 ` [PATCH 7/8] Output BTF DECL_TAG and TYPE_TAG types David Faust
2022-04-01 19:42 ` [PATCH 8/8] testsuite: Add tests for BTF tags David Faust
2022-04-04 22:13 ` [PATCH 0/8][RFC] Support BTF decl_tag and type_tag annotations Yonghong Song
2022-04-05 16:26   ` David Faust
2022-04-18 19:36 ` [ping][PATCH " David Faust
2022-05-02 16:57   ` [ping2][PATCH " David Faust
2022-05-03 22:32     ` Joseph Myers [this message]
2022-05-04 17:03       ` David Faust
2022-05-05 23:00         ` Yonghong Song
2022-05-06 21:18           ` David Faust
2022-05-11  3:43             ` Yonghong Song
2022-05-11  5:05               ` Yonghong Song
2022-05-11 18:44                 ` David Faust
2022-05-24  6:33                   ` Yonghong Song
2022-05-24 11:07                     ` Jose E. Marchesi
2022-05-24 15:52                       ` Yonghong Song
2022-05-24 15:53                       ` David Faust
2022-05-24 16:03                         ` Yonghong Song
2022-05-24 17:04                           ` David Faust
2022-05-26  7:29                             ` Yonghong Song
2022-05-27 19:56                               ` David Faust
2022-06-03  2:04                                 ` Yonghong Song
2022-06-07 21:42                                   ` David Faust

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=alpine.DEB.2.22.394.2205032222500.688351@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=david.faust@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=yhs@fb.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).