This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFA] PR c++/39637
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
This is another approach to the issue. I tried to detect (at parsing time) that
the initializer of the enumerator is not a parameter pack being used outside of
a parameter expansion.
C++/libstdc++ bootstrapped and regtested on trunk.
Thanks.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Remi - http://enigmail.mozdev.org
iEYEARECAAYFAknbSsIACgkQPejI7lrem2E/jQCfdTOKrf2/UXsuiMiOkVhPPVjJ
4J4AoJFWvdf2NwCTnhyQtzB6SEx8X099
=gkYP
-----END PGP SIGNATURE-----
commit 528bc3a8fa8759000fb19ef36e9e451ddfefe9a7
Author: Dodji Seketeli <dodji@redhat.com>
Date: Mon Apr 6 16:50:09 2009 +0200
Fix candidate for PR c++/39637
gcc/cp/ChangeLog:
2009-04-07 Dodji Seketeli <dodji@redhat.com>
PR c++/39637
* parser.c (cp_parser_enumerator_definition): Make sure the
initializer of the enumerator doesn't contain any bare parameter pack.
gcc/testsuite/ChangeLog
2009-04-07 Dodji Seketeli <dodji@redhat.com>
PRc++/39637
* g++.dg/cpp0x/variadic-crash2.C: New test.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 28f47c8..33c03fe 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -12011,6 +12011,12 @@ cp_parser_enumerator_definition (cp_parser* parser, tree type)
else
value = NULL_TREE;
+ /* If we are processing a template, make sure the initializer of the
+ enumerator doesn't contain any bare template parameter pack. */
+ if (processing_template_decl)
+ if (check_for_bare_parameter_packs (value))
+ value = error_mark_node;
+
/* Create the enumerator. */
build_enumerator (identifier, value, type);
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-crash2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-crash2.C
new file mode 100644
index 0000000..d1913b9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-crash2.C
@@ -0,0 +1,20 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin: PR c++/39637
+// { dg-options "-std=gnu++0x" }
+// { dg-do "compile" }
+
+template<class... Types>
+void
+f(Types...)
+{
+ enum {e = sizeof(Types)}; // { dg-error "parameter packs not expanded with '...'" }
+ enum {e1 = sizeof...(Types)};
+}
+
+int
+main()
+{
+ f(0);
+}
+
+// { dg-message "note" "Types" { target *-*-* } 10 }