public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: Tom Tromey <tromey@adacore.com>,  gdb-patches@sourceware.org
Subject: Re: [PATCH 3/3] Add name canonicalization for C
Date: Fri, 02 Dec 2022 07:39:02 -0700	[thread overview]
Message-ID: <87sfhxlvjt.fsf@tromey.com> (raw)
In-Reply-To: <20221201232348.GD2415@redhat.com> (Andrew Burgess's message of "Thu, 1 Dec 2022 23:23:48 +0000")

>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:

>> struct type *
>> lookup_signed_typename (const struct language_defn *language, const char *name)
>> {
>> -  struct type *t;
>> -  char *uns = (char *) alloca (strlen (name) + 8);
>> -
>> -  strcpy (uns, "signed ");
>> -  strcpy (uns + 7, name);
>> -  t = lookup_typename (language, uns, NULL, 1);
>> -  /* If we don't find "signed FOO" just try again with plain "FOO".  */
>> -  if (t != NULL)
>> -    return t;
>> +  /* In C and C++, "char" and "signed char" are distinct types.  */
>> +  if (streq (name, "char"))
>> +    name = "signed char";

Andrew> I wondered why this "char" -> "signed char" conversion is done
Andrew> unconditionally for all languages, when the comment hints that the
Andrew> conversion only applies for C/C++?  I guess I would have expected a
Andrew> language check here.

lookup_signed_typename is only used by C and C-like languages.  For
non-C-like languages, sticking a "signed" (or "unsigned", see
lookup_unsigned_typename) prefix on a type name doesn't really make
sense anyway.

The uses outside c-exp.y are, IMNSHO, just leftover code from the bad
old days.  Like, I suspect there's no reason to have binop_promote at
all, instead this could be an explicit node in the expression tree, and
rather than having a big 'switch' on the language, each language could
simply make a different node.

Tom

      reply	other threads:[~2022-12-02 14:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 16:23 [PATCH 0/3] Fix over-eager CU expansion with new DWARF reader Tom Tromey
2022-11-07 16:23 ` [PATCH 1/3] Remove language check from dwarf2_compute_name Tom Tromey
2022-12-01 15:16   ` Andrew Burgess
2022-11-07 16:23 ` [PATCH 2/3] Refactor cooked_index::do_finalize Tom Tromey
2022-12-01 15:34   ` Andrew Burgess
2022-11-07 16:23 ` [PATCH 3/3] Add name canonicalization for C Tom Tromey
2022-12-01 16:06   ` Simon Marchi
2022-12-01 16:29   ` Andrew Burgess
2022-12-01 17:56     ` Tom Tromey
2022-12-01 18:16       ` Tom Tromey
2022-12-01 23:23   ` Andrew Burgess
2022-12-02 14:39     ` Tom Tromey [this message]

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=87sfhxlvjt.fsf@tromey.com \
    --to=tromey@adacore.com \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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).