public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: don't ICE on NAMESPACE_DECL inside FUNCTION_DECL
@ 2021-12-15  8:53 Matthias Kretz
  2021-12-17 20:54 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias Kretz @ 2021-12-15  8:53 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1313 bytes --]

OK for trunk? This fixes several modules.exp failures for me.

────────────────────── ✂ ──────────────────────

Code like
  void swap() {
    namespace __variant = __detail::__variant;
    ...
  }
create a NAMESPACE_DECL where the CP_DECL_CONTEXT is a FUNCTION_DECL.
DECL_TEMPLATE_INFO fails on NAMESPACE_DECL and therefore must be handled
first in the assertion.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

gcc/cp/ChangeLog:

	* module.cc (trees_out::get_merge_kind): NAMESPACE_DECLs also
	cannot have a DECL_TEMPLATE_INFO.
---
 gcc/cp/module.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)


--
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
 stdₓ::simd
──────────────────────────────────────────────────────────────────────────

[-- Attachment #2: 0001-c-don-t-assert-on-NAMESPACE_DECL-inside-FUNCTION_DEC.patch --]
[-- Type: text/x-patch, Size: 721 bytes --]

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 3b1b5ca0ac0..2b5a32695d2 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -10067,9 +10067,10 @@ trees_out::get_merge_kind (tree decl, depset *dep)
       tree ctx = CP_DECL_CONTEXT (decl);
       if (TREE_CODE (ctx) == FUNCTION_DECL)
 	{
-	  /* USING_DECLs cannot have DECL_TEMPLATE_INFO -- this isn't
-	     permitting them to have one.   */
+	  /* USING_DECLs and NAMESPACE_DECLs cannot have DECL_TEMPLATE_INFO --
+	     this isn't permitting them to have one.   */
 	  gcc_checking_assert (TREE_CODE (decl) == USING_DECL
+			       || TREE_CODE (decl) == NAMESPACE_DECL
 			       || !DECL_LANG_SPECIFIC (decl)
 			       || !DECL_TEMPLATE_INFO (decl));
 

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

* Re: [PATCH] c++: don't ICE on NAMESPACE_DECL inside FUNCTION_DECL
  2021-12-15  8:53 [PATCH] c++: don't ICE on NAMESPACE_DECL inside FUNCTION_DECL Matthias Kretz
@ 2021-12-17 20:54 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2021-12-17 20:54 UTC (permalink / raw)
  To: Matthias Kretz, gcc-patches

On 12/15/21 03:53, Matthias Kretz wrote:
> OK for trunk? This fixes several modules.exp failures for me.

OK.

> ────────────────────── ✂ ──────────────────────
> 
> Code like
>    void swap() {
>      namespace __variant = __detail::__variant;
>      ...
>    }
> create a NAMESPACE_DECL where the CP_DECL_CONTEXT is a FUNCTION_DECL.
> DECL_TEMPLATE_INFO fails on NAMESPACE_DECL and therefore must be handled
> first in the assertion.
> 
> Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
> 
> gcc/cp/ChangeLog:
> 
> 	* module.cc (trees_out::get_merge_kind): NAMESPACE_DECLs also
> 	cannot have a DECL_TEMPLATE_INFO.
> ---
>   gcc/cp/module.cc | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> 
> --
> ──────────────────────────────────────────────────────────────────────────
>   Dr. Matthias Kretz                           https://mattkretz.github.io
>   GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
>   stdₓ::simd
> ──────────────────────────────────────────────────────────────────────────


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

end of thread, other threads:[~2021-12-17 20:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-15  8:53 [PATCH] c++: don't ICE on NAMESPACE_DECL inside FUNCTION_DECL Matthias Kretz
2021-12-17 20:54 ` 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).