From: Yao Qi <qiyaoltc@gmail.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org, Phil Muldoon <pmuldoon@redhat.com>
Subject: Re: [patchv2] compile: Fix crash on cv-qualified self-reference
Date: Wed, 01 Jul 2015 11:21:00 -0000 [thread overview]
Message-ID: <86lhf0p1hf.fsf@gmail.com> (raw)
In-Reply-To: <20150516132555.GB17266@host1.jankratochvil.net> (Jan Kratochvil's message of "Sat, 16 May 2015 15:25:55 +0200")
Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> + quals = 0;
> + if (TYPE_CONST (type))
> + quals |= GCC_QUALIFIER_CONST;
> + if (TYPE_VOLATILE (type))
> + quals |= GCC_QUALIFIER_VOLATILE;
> + if (TYPE_RESTRICT (type))
> + quals |= GCC_QUALIFIER_RESTRICT;
> + result = C_CTX (context)->c_ops->build_qualified_type (C_CTX (context),
> + result, quals);
> insert_type (context, type, result);
Can we use convert_qualified instead? I find code we added here is
quite similar to convert_qualified.
>
> for (i = 0; i < TYPE_NFIELDS (type); ++i)
> @@ -329,10 +342,13 @@ static gcc_type
> convert_type_basic (struct compile_c_instance *context, struct type *type)
> {
> /* If we are converting a qualified type, first convert the
> - unqualified type and then apply the qualifiers. */
> + unqualified type and then apply the qualifiers, except for the
> + types handling qualifiers on their own. */
> if ((TYPE_INSTANCE_FLAGS (type) & (TYPE_INSTANCE_FLAG_CONST
> | TYPE_INSTANCE_FLAG_VOLATILE
> - | TYPE_INSTANCE_FLAG_RESTRICT)) != 0)
> + | TYPE_INSTANCE_FLAG_RESTRICT)) != 0
> + && (TYPE_CODE (type) != TYPE_CODE_STRUCT
> + && TYPE_CODE (type) != TYPE_CODE_UNION))
> return convert_qualified (context, type);
It looks right to me, however, isn't cleaner to do in this way?
/* Comments on why we do this first */
if (TYPE_CODE (type) == TYPE_CODE_STRUCT
|| TYPE_CODE (type) == TYPE_CODE_UNION)
return convert_struct_or_union (context, type);
/* If we are converting a qualified type, first convert the
unqualified type and then apply the qualifiers. */
if ((TYPE_INSTANCE_FLAGS (type) & (TYPE_INSTANCE_FLAG_CONST
| TYPE_INSTANCE_FLAG_VOLATILE
| TYPE_INSTANCE_FLAG_RESTRICT)) != 0)
return convert_qualified (context, type);
switch (TYPE_CODE (type))
{
/* Don't need to handle TYPE_CODE_STRUCT and TYPE_CODE_UNION
here. */
}
Otherwise, the patch looks good to me.
--
Yao (齐尧)
next prev parent reply other threads:[~2015-07-01 11:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-18 17:28 [patch] " Jan Kratochvil
2015-05-16 13:26 ` [patchv2] " Jan Kratochvil
2015-06-30 19:57 ` Joel Brobecker
2015-07-01 10:32 ` Pedro Alves
2015-07-01 11:21 ` Yao Qi [this message]
2015-07-01 13:24 ` Jan Kratochvil
2015-07-01 13:54 ` Pedro Alves
2015-07-01 14:10 ` Jan Kratochvil
2015-07-01 14:59 ` Pedro Alves
2015-07-01 15:12 ` Jan Kratochvil
2015-07-01 15:24 ` Pedro Alves
2015-07-01 15:29 ` Jan Kratochvil
2015-07-01 15:35 ` Pedro Alves
2015-07-01 16:07 ` Jan Kratochvil
2015-07-01 16:16 ` Pedro Alves
2015-07-01 14:06 ` Yao Qi
2015-07-02 12:34 ` Jan Kratochvil
2015-07-04 17:11 ` [patchv3] " Jan Kratochvil
2015-07-08 9:29 ` Pedro Alves
2015-07-08 12:51 ` [commit] " Jan Kratochvil
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=86lhf0p1hf.fsf@gmail.com \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=pmuldoon@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