public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++/modules: Handle error header names in modules [PR107594]
@ 2024-01-27 20:51 Nathaniel Shead
  2024-01-30  2:57 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Nathaniel Shead @ 2024-01-27 20:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: Nathan Sidwell, Jason Merrill

I don't provide a new test because this error only happens when there
are no include paths at all, and I haven't worked out a way to get this
to happen within DejaGNU (as it adds a number of `-B` and `-I` flags).

Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk?

-- >8 --

When there are no include paths while preprocessing a header-name token,
an empty STRING_CST is returned. This patch ensures this is handled when
attempting to create a module for this name.

	PR c++/107594

gcc/cp/ChangeLog:

	* module.cc (get_module): Bail on empty name.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
---
 gcc/cp/module.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 840c7ef6dab..3c2fef0e3f4 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -14050,6 +14050,12 @@ get_primary (module_state *parent)
 module_state *
 get_module (tree name, module_state *parent, bool partition)
 {
+  /* We might be given an empty NAME if preprocessing fails to handle
+     a header-name token.  */
+  if (name && TREE_CODE (name) == STRING_CST
+      && TREE_STRING_LENGTH (name) == 0)
+    return nullptr;
+
   if (partition)
     {
       if (!parent)
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] c++/modules: Handle error header names in modules [PR107594]
  2024-01-27 20:51 [PATCH] c++/modules: Handle error header names in modules [PR107594] Nathaniel Shead
@ 2024-01-30  2:57 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2024-01-30  2:57 UTC (permalink / raw)
  To: Nathaniel Shead, gcc-patches; +Cc: Nathan Sidwell

On 1/27/24 15:51, Nathaniel Shead wrote:
> I don't provide a new test because this error only happens when there
> are no include paths at all, and I haven't worked out a way to get this
> to happen within DejaGNU (as it adds a number of `-B` and `-I` flags).
> 
> Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk?

OK.

> -- >8 --
> 
> When there are no include paths while preprocessing a header-name token,
> an empty STRING_CST is returned. This patch ensures this is handled when
> attempting to create a module for this name.
> 
> 	PR c++/107594
> 
> gcc/cp/ChangeLog:
> 
> 	* module.cc (get_module): Bail on empty name.
> 
> Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
> ---
>   gcc/cp/module.cc | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
> index 840c7ef6dab..3c2fef0e3f4 100644
> --- a/gcc/cp/module.cc
> +++ b/gcc/cp/module.cc
> @@ -14050,6 +14050,12 @@ get_primary (module_state *parent)
>   module_state *
>   get_module (tree name, module_state *parent, bool partition)
>   {
> +  /* We might be given an empty NAME if preprocessing fails to handle
> +     a header-name token.  */
> +  if (name && TREE_CODE (name) == STRING_CST
> +      && TREE_STRING_LENGTH (name) == 0)
> +    return nullptr;
> +
>     if (partition)
>       {
>         if (!parent)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-30  2:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-27 20:51 [PATCH] c++/modules: Handle error header names in modules [PR107594] Nathaniel Shead
2024-01-30  2:57 ` Jason Merrill

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).