Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>
To: Tom Tromey <tom@tromey.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH 1/1] gdb/dwarf, fortran: Use the function scope for DW_TAG_imported_declaration
Date: Mon, 4 May 2026 07:12:57 +0000	[thread overview]
Message-ID: <SA1PR11MB684657D56747ACC2B64A8861CB312@SA1PR11MB6846.namprd11.prod.outlook.com> (raw)
In-Reply-To: <87ik97gjnq.fsf@tromey.com>

Thanks Tom for the feedback.

>> +      if (cu->lang () == language_fortran)
>> +	list_to_add = cu->list_in_scope;
>> +      else
>> +	list_to_add = &cu->get_builder ()->get_global_symbols ();

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

Abdul> Also not sure about the others languages.

Tom>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.
Tom>Would you mind giving this a try?

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

Abdul>Should be working fine. I will try this change and if it works fine then I will push the patch 2 with this change.

Best Regards,
Abdul Basit

-----Original Message-----
From: Tom Tromey <tom@tromey.com> 
Sent: Friday, May 1, 2026 6:49 PM
To: Ijaz, Abdul B <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

>>>>> 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
Intel Deutschland GmbH
Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

      reply	other threads:[~2026-05-04  7:13 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
2026-05-04  7:12   ` Ijaz, Abdul B [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=SA1PR11MB684657D56747ACC2B64A8861CB312@SA1PR11MB6846.namprd11.prod.outlook.com \
    --to=abdul.b.ijaz@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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