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: Thu, 10 Aug 2023 17:44:20 -0400 [thread overview]
Message-ID: <fc0d6a82-a6a3-dcde-a093-103c149b5419@redhat.com> (raw)
In-Reply-To: <ZNUDrXSjHpgTuknm@tucnak>
On 8/10/23 11:35, Jakub Jelinek wrote:
> Hi!
>
> I'd like to ping this patch. Reposting it as I found a typo in the
> documentation - s/builtin-in/built-in/. Bootstrapped/regtested again
> on x86_64-linux and i686-linux, ok for trunk?
>
> On Mon, Jun 12, 2023 at 09:57:17PM +0200, Jakub Jelinek via Gcc-patches wrote:
>> As mentioned in my stdckdint.h mail, __builtin_classify_type has
>> a problem that argument promotion (the argument is passed to ...
>> prototyped builtin function) means that certain type classes will
>> simply never appear.
>> I think it is too late to change how it behaves, lots of code in the
>> wild might rely on the current behavior.
Hmm, you really think there's any code at all in the wild relying on
__builtin_classify_type + array/function decay? It's a (previously)
undocumented built-in, I wouldn't expect anyone outside the project to
be using it. So at first glance I'd be inclined to fix it whether or
not we also allow it to accept a type. But I don't actually know how
it's used, so could well be wrong...
> --- gcc/cp/parser.cc.jj 2023-06-06 20:02:35.631211230 +0200
> +++ gcc/cp/parser.cc 2023-06-12 16:19:04.892202240 +0200
> @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3.
> #include "c-family/known-headers.h"
> #include "contracts.h"
> #include "bitmap.h"
> +#include "builtins.h"
>
> \f
> /* The lexer. */
> @@ -7850,6 +7851,50 @@ cp_parser_postfix_expression (cp_parser
> = parser->non_integral_constant_expression_p;
> parser->integral_constant_expression_p = false;
> }
> + else if (TREE_CODE (stripped_expression) == FUNCTION_DECL
> + && fndecl_built_in_p (stripped_expression,
> + BUILT_IN_CLASSIFY_TYPE))
> + {
> + /* __builtin_classify_type (type) */
> + auto cl1 = make_temp_override
> + (parser->type_definition_forbidden_message,
> + G_("types may not be defined in "
> + "%<__builtin_classify_type%> calls"));
> + auto cl2 = make_temp_override
> + (parser->type_definition_forbidden_message_arg,
> + NULL);
> + auto cl3 = make_temp_override (parser->in_type_id_in_expr_p,
> + true);
> + cp_evaluated ev;
> + ++cp_unevaluated_operand;
> + ++c_inhibit_evaluation_warnings;
These three lines seem unnecessary for parsing a type.
> + tentative_firewall firewall (parser);
I think you only need a tentative_firewall if you're going to call
cp_parser_commit_to_tentative_parse yourself, which you don't.
Jason
next prev parent reply other threads:[~2023-08-10 21:44 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 [this message]
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
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=fc0d6a82-a6a3-dcde-a093-103c149b5419@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).