From: Tom Tromey <tom@tromey.com>
To: Pedro Alves <palves@redhat.com>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [RFA 2/6] Handle alignof and _Alignof
Date: Fri, 27 Apr 2018 20:53:00 -0000 [thread overview]
Message-ID: <87604c5q2r.fsf@tromey.com> (raw)
In-Reply-To: <0a567678-2138-4634-d472-44c170f47f93@redhat.com> (Pedro Alves's message of "Fri, 27 Apr 2018 19:02:30 +0100")
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> My thought was to simply support compiling a separate testcase
Pedro> binary for a given type instead of mixing all types in
Pedro> the same program. So if a type is not supported, the program
Pedro> won't compile and we'd skip the testing that type.
Ok, I can do that. I'll put the "void" test there too -- the problem
with it being that (1) we'd need "nowarnings" and (2) since it isn't
really valid, presumably some other C++ compiler might reject it.
Tom> No, and this is hard to do. I've left the door open a bit by the way
Tom> the new expression emits a new OP instead of simply writing out a
Tom> constant (and this allows alignof(typeof(..)) to work as well).
Tom> However, I think the way the parser is written makes this difficult,
Pedro> OOC, can you expand a bit on what you mean here? I would have assumed
Pedro> that at the parser level, we'd just copy exactly what is done for
Pedro> supporting expressions with sizeof.
Right now we have:
exp : ALIGNOF '(' type_exp ')' %prec UNARY
{ write_exp_elt_opcode (pstate, UNOP_ALIGNOF); }
;
We could add another production like:
exp : ALIGNOF '(' exp ')' ...
... but when I tried this the resulting parser had issues with the tests
-- claiming syntax errors where there were none.
Tom> which is one reason that sizeof requires or does not require parens
Tom> depending on whether the argument is an expression or a type.
Pedro> Not clear what you mean here. I know that sizeof with an expression
Pedro> requires parenthesis in C/C++, but I'm not connecting the dots with
Pedro> the above comments.
For sizeof there are two productions:
exp : SIZEOF exp %prec UNARY
{ write_exp_elt_opcode (pstate, UNOP_SIZEOF); }
;
exp : SIZEOF '(' type ')' %prec UNARY
I don't really know offhand why the latter is taken when a paren is
seen, it seems ambiguous to me.
Debugging this stuff is not very easy or enjoyable. Switching to a
recursive descent parser would eliminate problems like this, because
some of the decisions would be turned into more simple programming
problems.
Tom> especially since "alignof(typeof(expression))" is
Tom> pretty easy.
Pedro> Ah, if that works, then yeah, that's a good escape hatch.
Pedro> Should we have a test for that?
Yeah, I'll add one.
Pedro> Yeah. I think the main complication here would be related to how the
Pedro> expression machinery returns values and types, and then how to
Pedro> distinguish a struct field of type X with a standalone variable of
Pedro> type X, for alignof purposes (given x86's funny alignments).
I think with the new agreed-upon definition of alignof, this is no
longer a concern.
Tom
next prev parent reply other threads:[~2018-04-27 20:53 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-24 15:22 [RFA 0/6] Teach gdb about type alignment Tom Tromey
2018-04-24 15:22 ` [RFA 2/6] Handle alignof and _Alignof Tom Tromey
2018-04-24 17:04 ` Eli Zaretskii
2018-04-24 19:17 ` Pedro Alves
2018-04-24 20:23 ` Tom Tromey
2018-04-27 18:02 ` Pedro Alves
2018-04-27 20:53 ` Tom Tromey [this message]
2018-04-30 16:46 ` Tom Tromey
2018-04-26 20:45 ` Tom Tromey
2018-04-27 18:05 ` Pedro Alves
2018-04-26 20:54 ` Tom Tromey
2018-04-24 15:22 ` [RFA 4/6] Expose type alignment on gdb.Type Tom Tromey
2018-04-24 16:59 ` Eli Zaretskii
2018-04-24 15:22 ` [RFA 3/6] Reindent type_object_getset in py-type.c Tom Tromey
2018-04-24 15:22 ` [RFA 5/6] Remove rust_type_alignment Tom Tromey
2018-04-24 15:22 ` [RFA 1/6] Add initial type alignment support Tom Tromey
2018-04-24 19:16 ` Pedro Alves
2018-04-24 20:23 ` Tom Tromey
2018-04-24 15:22 ` [RFA 6/6] Remove long_long_align_bit gdbarch attribute Tom Tromey
2018-04-24 15:24 ` Tom Tromey
2018-04-24 17:17 ` Anton Kolesov
2018-04-26 20:56 ` Tom Tromey
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=87604c5q2r.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.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