From: Jason Merrill <jason@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>,
"Joseph S. Myers" <joseph@codesourcery.com>,
Marek Polacek <polacek@redhat.com>,
gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c, c++, v2: Accept __builtin_classify_type (typename)
Date: Fri, 11 Aug 2023 12:12:28 -0400 [thread overview]
Message-ID: <d6c90855-921b-ec76-1471-55852da8b6a7@redhat.com> (raw)
In-Reply-To: <ZNX100n2YImOMOm4@tucnak>
On 8/11/23 04:48, Jakub Jelinek wrote:
> On Fri, Aug 11, 2023 at 01:13:32AM +0200, Jakub Jelinek wrote:
>> Looking at the first uses of the builtin back in 90s in va*.h, it certainly
>> relied on array/function decay there (the macros would abort e.g. on
>> array_type_class, function_type_class and various other return values).
>> Looking at older versions of tgmath.h, I see just checks for 8/9 (i.e.
>> real/complex) and those woiuldn't be affected by any promotions/decay.
>> But newer versions of tgmath.h before __builtin_tgmath do check also for
>> 1 and they would be upset if char wasn't promoted to int (including latest
>> glibc).
>> systemtap macros also use __builtin_classify_type and do check for pointers
>> but those seems to be prepared to handle even arrays.
>
> So to sum it up, I think at least the original use of the builtin had a
> strong reason to do the array to pointer etc. decay and argument promotion,
> because that is what happens with the varargs too and the builtin is still
> documented in the internals manual just for that purpose. It is true GCC
> doesn't use the builtin for that reason anymore, but there are numerous
> uses in the wild, some might cope well with changing the behavior, others
> less so.
>
>>>> + cp_evaluated ev;
>>>> + ++cp_unevaluated_operand;
>>>> + ++c_inhibit_evaluation_warnings;
>>>
>>> These three lines seem unnecessary for parsing a type.
>
> I had a quick look at this and a reason to do at least some of this
> is e.g. array types, __builtin_classify_type (int [foo () + whatever])
> will not really evaluate foo () + whatever, all it will care about is that
> it is an array, so emiting evaluation warnings for it would be weird.
> cp_unevaluated_operand is harder to find out what all the effects are,
> but e.g. warnings for missing member initializers in such expressions
> isn't needed either.
Fair enough. But you should only need a single line
cp_unevaluated ev;
The C++ bits are OK with that change.
Jason
next prev parent reply other threads:[~2023-08-11 16:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-12 19:57 [PATCH] c, c++: " Jakub Jelinek
2023-06-13 8:48 ` Jason Merrill
2023-08-10 15:35 ` [PATCH] c, c++, v2: " Jakub Jelinek
2023-08-10 21:44 ` Jason Merrill
2023-08-10 22:27 ` Joseph Myers
2023-08-10 23:13 ` Jakub Jelinek
2023-08-11 8:48 ` Jakub Jelinek
2023-08-11 16:12 ` Jason Merrill [this message]
2023-09-18 9:42 ` Patch ping: " Jakub Jelinek
2023-09-18 21:25 ` Joseph Myers
2023-09-20 7:17 ` [PATCH] c, c++, v3: " Jakub Jelinek
2023-09-20 16:08 ` Joseph Myers
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=d6c90855-921b-ec76-1471-55852da8b6a7@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=joseph@codesourcery.com \
--cc=polacek@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).