public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++/modules: alias CTAD and specializations table
@ 2023-11-24 18:09 Patrick Palka
  2023-12-09 20:42 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2023-11-24 18:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason, nathan, Patrick Palka

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

-- >8 --

A rewritten guide for alias CTAD isn't really a specialization of the
original guide, so we shouldn't register it as such.  This avoids an ICE
in the below modules testcase which otherwise tries to inspect the
rewritten guide's empty DECL_CONTEXT.  It also preemptively avoids an
ICE in modules/concept-6 in C++23 mode with the inherited CTAD patch.

	* pt.cc (alias_ctad_tweaks): Pass use_spec_table=false to
	tsubst_decl.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/concept-8.h: New test.
	* g++.dg/modules/concept-8_a.H: New test.
	* g++.dg/modules/concept-8_b.C: New test.
---
 gcc/cp/pt.cc                               |  3 ++-
 gcc/testsuite/g++.dg/modules/concept-8.h   | 14 ++++++++++++++
 gcc/testsuite/g++.dg/modules/concept-8_a.H |  5 +++++
 gcc/testsuite/g++.dg/modules/concept-8_b.C |  8 ++++++++
 4 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/modules/concept-8.h
 create mode 100644 gcc/testsuite/g++.dg/modules/concept-8_a.H
 create mode 100644 gcc/testsuite/g++.dg/modules/concept-8_b.C

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 4f93150c5d7..2cfe1da5e07 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -30015,7 +30015,8 @@ alias_ctad_tweaks (tree tmpl, tree uguides)
 	      /* Parms are to have DECL_CHAIN tsubsted, which would be skipped
 		 if cp_unevaluated_operand.  */
 	      cp_evaluated ev;
-	      g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain);
+	      g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain,
+			       /*use_spec_table=*/false);
 	    }
 	  if (g == error_mark_node)
 	    continue;
diff --git a/gcc/testsuite/g++.dg/modules/concept-8.h b/gcc/testsuite/g++.dg/modules/concept-8.h
new file mode 100644
index 00000000000..a25f9b752fd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/concept-8.h
@@ -0,0 +1,14 @@
+// A version of concept-6.h using an alias template + alias CTAD
+
+template<typename _Callable>
+struct Base
+{
+  Base (const _Callable &)
+    requires true
+  {}
+};
+
+template<typename _Callable> requires true
+using Derived = Base<_Callable>;
+
+inline Derived all = [] (auto&& __r) {};
diff --git a/gcc/testsuite/g++.dg/modules/concept-8_a.H b/gcc/testsuite/g++.dg/modules/concept-8_a.H
new file mode 100644
index 00000000000..da0467781c1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/concept-8_a.H
@@ -0,0 +1,5 @@
+// { dg-require-effective-target c++20 }
+// { dg-additional-options "-fmodule-header -fconcepts" }
+// { dg-module-cmi {} }
+
+#include "concept-8.h"
diff --git a/gcc/testsuite/g++.dg/modules/concept-8_b.C b/gcc/testsuite/g++.dg/modules/concept-8_b.C
new file mode 100644
index 00000000000..9a9f014ee09
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/concept-8_b.C
@@ -0,0 +1,8 @@
+// { dg-require-effective-target c++20 }
+// { dg-additional-options "-fmodules-ts -fconcepts -fdump-lang-module-alias -fno-module-lazy" }
+
+#include "concept-8.h"
+import "concept-8_a.H";
+
+// { dg-final { scan-lang-dump-times {named merge key \(matched\) function_decl:'::Base<::._anon_0>::__ct '} 2 module } }
+// { dg-final { scan-lang-dump-not {merge key \(new\)} module } }
-- 
2.43.0.rc1


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

* Re: [PATCH] c++/modules: alias CTAD and specializations table
  2023-11-24 18:09 [PATCH] c++/modules: alias CTAD and specializations table Patrick Palka
@ 2023-12-09 20:42 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2023-12-09 20:42 UTC (permalink / raw)
  To: Patrick Palka, gcc-patches; +Cc: nathan

On 11/24/23 13:09, Patrick Palka wrote:
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
> trunk?

OK.

> -- >8 --
> 
> A rewritten guide for alias CTAD isn't really a specialization of the
> original guide, so we shouldn't register it as such.  This avoids an ICE
> in the below modules testcase which otherwise tries to inspect the
> rewritten guide's empty DECL_CONTEXT.  It also preemptively avoids an
> ICE in modules/concept-6 in C++23 mode with the inherited CTAD patch.
> 
> 	* pt.cc (alias_ctad_tweaks): Pass use_spec_table=false to
> 	tsubst_decl.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/modules/concept-8.h: New test.
> 	* g++.dg/modules/concept-8_a.H: New test.
> 	* g++.dg/modules/concept-8_b.C: New test.
> ---
>   gcc/cp/pt.cc                               |  3 ++-
>   gcc/testsuite/g++.dg/modules/concept-8.h   | 14 ++++++++++++++
>   gcc/testsuite/g++.dg/modules/concept-8_a.H |  5 +++++
>   gcc/testsuite/g++.dg/modules/concept-8_b.C |  8 ++++++++
>   4 files changed, 29 insertions(+), 1 deletion(-)
>   create mode 100644 gcc/testsuite/g++.dg/modules/concept-8.h
>   create mode 100644 gcc/testsuite/g++.dg/modules/concept-8_a.H
>   create mode 100644 gcc/testsuite/g++.dg/modules/concept-8_b.C
> 
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 4f93150c5d7..2cfe1da5e07 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -30015,7 +30015,8 @@ alias_ctad_tweaks (tree tmpl, tree uguides)
>   	      /* Parms are to have DECL_CHAIN tsubsted, which would be skipped
>   		 if cp_unevaluated_operand.  */
>   	      cp_evaluated ev;
> -	      g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain);
> +	      g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain,
> +			       /*use_spec_table=*/false);
>   	    }
>   	  if (g == error_mark_node)
>   	    continue;
> diff --git a/gcc/testsuite/g++.dg/modules/concept-8.h b/gcc/testsuite/g++.dg/modules/concept-8.h
> new file mode 100644
> index 00000000000..a25f9b752fd
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/modules/concept-8.h
> @@ -0,0 +1,14 @@
> +// A version of concept-6.h using an alias template + alias CTAD
> +
> +template<typename _Callable>
> +struct Base
> +{
> +  Base (const _Callable &)
> +    requires true
> +  {}
> +};
> +
> +template<typename _Callable> requires true
> +using Derived = Base<_Callable>;
> +
> +inline Derived all = [] (auto&& __r) {};
> diff --git a/gcc/testsuite/g++.dg/modules/concept-8_a.H b/gcc/testsuite/g++.dg/modules/concept-8_a.H
> new file mode 100644
> index 00000000000..da0467781c1
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/modules/concept-8_a.H
> @@ -0,0 +1,5 @@
> +// { dg-require-effective-target c++20 }
> +// { dg-additional-options "-fmodule-header -fconcepts" }
> +// { dg-module-cmi {} }
> +
> +#include "concept-8.h"
> diff --git a/gcc/testsuite/g++.dg/modules/concept-8_b.C b/gcc/testsuite/g++.dg/modules/concept-8_b.C
> new file mode 100644
> index 00000000000..9a9f014ee09
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/modules/concept-8_b.C
> @@ -0,0 +1,8 @@
> +// { dg-require-effective-target c++20 }
> +// { dg-additional-options "-fmodules-ts -fconcepts -fdump-lang-module-alias -fno-module-lazy" }
> +
> +#include "concept-8.h"
> +import "concept-8_a.H";
> +
> +// { dg-final { scan-lang-dump-times {named merge key \(matched\) function_decl:'::Base<::._anon_0>::__ct '} 2 module } }
> +// { dg-final { scan-lang-dump-not {merge key \(new\)} module } }


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

end of thread, other threads:[~2023-12-09 20:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-24 18:09 [PATCH] c++/modules: alias CTAD and specializations table Patrick Palka
2023-12-09 20:42 ` 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).