]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: ICE with unexpanded pack in asm
authoryxj-github-437 <2457369732@qq.com>
Wed, 4 Jun 2025 13:18:45 +0000 (21:18 +0800)
committerJason Merrill <jason@redhat.com>
Mon, 16 Jun 2025 10:41:08 +0000 (06:41 -0400)
Here an unexpanded parameter pack pass into asm_operand which doesn't
expect to see an operand without type. So use check_for_bare_parameter_packs
to remedy that.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_asm_operand_list): Check for unexpanded
parameter packs.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/variadic-crash7.C: New test.

gcc/cp/parser.cc
gcc/testsuite/g++.dg/cpp0x/variadic-crash7.C [new file with mode: 0644]

index 86337635f48d7ab558320e5dca23223407797200..cfebde8b118149accdaec8e32333e08a1310e3bd 100644 (file)
@@ -30421,6 +30421,9 @@ cp_parser_asm_operand_list (cp_parser* parser)
       parens.require_open (parser);
       /* Parse the expression.  */
       tree expression = cp_parser_expression (parser);
+      if (check_for_bare_parameter_packs (expression))
+       expression = error_mark_node;
+
       /* Look for the `)'.  */
       parens.require_close (parser);
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-crash7.C b/gcc/testsuite/g++.dg/cpp0x/variadic-crash7.C
new file mode 100644 (file)
index 0000000..b416508
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile { target c++11 } }
+
+template <typename... Ts>
+void f (Ts&&... args)
+{
+  asm volatile ("" :: "r"(args) : "memory"); // { dg-error "parameter packs" }
+}
+
+void g()
+{
+  f(1);
+}