This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] PATCH for PR c++/39639


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

In this PR g++ does not emit any diagnostic when an ellipsis appears in the
context of a template argument (e.g. when parsing a template specialization),
without being preceded by parameter pack.

This patch just emits the diagnostic in that case.

It bootstraps and passes regtests on trunk.

OK for trunk, 4.4 and 4.3, assuming it passes bootstraps/regtests on the branches ?

Thanks.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Remi - http://enigmail.mozdev.org

iEYEARECAAYFAknedBQACgkQPejI7lrem2HH2wCgoSkb/g1uxKhdsbko7JsY6hA8
AbMAnRkb2KgJyxRx2q+gOaBFedaffnWz
=7Kd5
-----END PGP SIGNATURE-----
commit 3d8cd2bb2e572e3516b1276ed792e8c54e982eb5
Author: Dodji Seketeli <dodji@redhat.com>
Date:   Thu Apr 9 20:17:46 2009 +0200

    Candidate fix PR c++/39639
    
    gcc/cp/ChangeLog:
    2009-04-09  Dodji Seketeli  <dodji@redhat.com>
    	PR c++/39639
    	* parser.c (cp_parser_template_argument_list): Display an error
    	when an ellipsis is not preceded by a parameter pack.
    
    gcc/testsuite/ChangeLog:
    2009-04-09  Dodji Seketeli  <dodji@redhat.com>
    	PR c++/39639
    	* g++.dg/cpp0x/pr39639.C: New test.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 18d62cc..0d4e604 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -10474,6 +10474,12 @@ cp_parser_template_argument_list (cp_parser* parser)
          argument pack. */
       if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
         {
+	  if (argument == error_mark_node)
+	    {
+	      cp_token *token = cp_lexer_peek_token (parser->lexer);
+	      error ("%Hexpected parameter pack before %<...%>",
+		     &token->location);
+	    }
           /* Consume the `...' token. */
           cp_lexer_consume_token (parser->lexer);
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr39639.C b/gcc/testsuite/g++.dg/cpp0x/pr39639.C
new file mode 100644
index 0000000..abd3bcf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr39639.C
@@ -0,0 +1,20 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin: PR c++/39639
+// { dg-options "-std=c++0x" }
+// { dg-do "compile" }
+
+template <class... Types>
+struct S
+  : S<...Types>, // { dg-error "expected parameter pack before '...'" }
+    S<...Types...>, // { dg-error "expected parameter pack before '...'" }
+    S<...> // { dg-error "expected parameter pack before '...'" }
+{
+  static int f () { return 1;}
+};
+
+int
+main ()
+{
+  return S<void>::f ();
+}
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]