Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/1] gdb/dwarf, fortran: Use the function scope for DW_TAG_imported_declaration
Date: Fri, 01 May 2026 10:48:57 -0600	[thread overview]
Message-ID: <87ik97gjnq.fsf@tromey.com> (raw)
In-Reply-To: <20260429212413.150679-1-abdul.b.ijaz@intel.com> (Abdul Basit Ijaz's message of "Wed, 29 Apr 2026 23:24:13 +0200")

>>>>> Abdul Basit Ijaz <abdul.b.ijaz@intel.com> writes:

> All Fortran imported variable aliases (`use module, alias => var`) were
> being added to "global scope", regardless of whether they appeared in:
> - Program/module scope (should be global)
> - Function scope (should be local)

Thanks for the patch.

>      case DW_TAG_imported_declaration:
> +      sym->set_domain (TYPE_DOMAIN);
> +      sym->set_loc_class_index (LOC_TYPEDEF);
> +      /* For Fortran imported declarations, use current scope context
> +	 rather than forcing global scope.  This ensures variable aliases
> +	 are scoped correctly (function-level, module-level, or
> +	 program-level).  */
> +      if (cu->lang () == language_fortran)
> +	list_to_add = cu->list_in_scope;
> +      else
> +	list_to_add = &cu->get_builder ()->get_global_symbols ();

I wonder if this could simply omit the 'if' and do the "usual"
file->global transform like:

	      list_to_add
		= ((cu->list_in_scope
		    == &cu->get_builder ()->get_file_symbols ())
		   ? &cu->get_builder ()->get_global_symbols ()
		   : cu->list_in_scope);

That is, do we know for sure that there's some language requiring that a
local import be stuffed into the global scope?

I tend to think such DWARF wouldn't exist and the code would be easier
to maintain in the long run without a fortran-specific check.

Would you mind giving this a try?

thanks,
Tom

  reply	other threads:[~2026-05-01 16:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29 21:24 Abdul Basit Ijaz
2026-05-01 16:48 ` Tom Tromey [this message]
2026-05-04  7:12   ` Ijaz, Abdul B

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=87ik97gjnq.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=abdul.b.ijaz@intel.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