]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/34054 (ICE with parameter pack in return type)
authorJakub Jelinek <jakub@redhat.com>
Tue, 13 Nov 2007 18:27:09 +0000 (19:27 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 13 Nov 2007 18:27:09 +0000 (19:27 +0100)
PR c++/34054
PR c++/34056
PR c++/34057
PR c++/34058
PR c++/34060
* pt.c (find_parameter_packs_r): If ppd->set_packs_to_error,
set to error_mark_node the outermost POINTER_TYPE to the pack if
it is seen in a POINTER_TYPE.
(push_template_decl_real): If check_for_bare_parameter_packs
fails for function return type, set the return type to
integer_type_node.  If check_for_bare_parameter_packs failed
for non-function, return error_mark_node.

* g++.dg/parse/crash36.C: Add another dg-error.
* g++.dg/cpp0x/pr34054.C: New test.
* g++.dg/cpp0x/pr34056.C: New test.
* g++.dg/cpp0x/pr34057.C: New test.
* g++.dg/cpp0x/pr34058.C: New test.
* g++.dg/cpp0x/pr34060.C: New test.

From-SVN: r130152

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr34054.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr34056.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr34057.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr34058.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr34060.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/crash36.C

index 1bcad75c1ce727d13246c9b6196484507f9b6f78..efc48a95bd71a16d536b4f32e23393010983f723 100644 (file)
@@ -1,5 +1,18 @@
 2007-11-13  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/34054
+       PR c++/34056
+       PR c++/34057
+       PR c++/34058
+       PR c++/34060
+       * pt.c (find_parameter_packs_r): If ppd->set_packs_to_error,
+       set to error_mark_node the outermost POINTER_TYPE to the pack if
+       it is seen in a POINTER_TYPE.
+       (push_template_decl_real): If check_for_bare_parameter_packs
+       fails for function return type, set the return type to
+       integer_type_node.  If check_for_bare_parameter_packs failed
+       for non-function, return error_mark_node.
+
        PR c++/29225
        * call.c (build_new_op): Call resolve_args before calling
        build_over_call.
index 0339a8c02d3ba75145e00a5018e3cc4101a8c6e1..8a95ccf7f74dac52748057b797d4bfa0753e5b5b 100644 (file)
@@ -2454,6 +2454,7 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
       return NULL_TREE;
     }
 
+recheck:
   /* Identify whether this is a parameter pack or not.  */
   switch (TREE_CODE (t))
     {
@@ -2478,6 +2479,16 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
         }
       break;
 
+    case POINTER_TYPE:
+      if (ppd->set_packs_to_error)
+       /* Pointer types are shared, set in that case the outermost
+          POINTER_TYPE to error_mark_node rather than the parameter pack.  */
+       {
+         t = TREE_TYPE (t);
+         goto recheck;
+       }
+      break;
+
     default:
       /* Not a parameter pack.  */
       break;
@@ -2553,7 +2564,6 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
                    ppd, NULL);
       *walk_subtrees = 0;
       return NULL_TREE;
-
       
     case TYPE_PACK_EXPANSION:
     case EXPR_PACK_EXPANSION:
@@ -3864,11 +3874,15 @@ push_template_decl_real (tree decl, bool is_friend)
 
       /* Check for bare parameter packs in the return type and the
          exception specifiers.  */
-      check_for_bare_parameter_packs (&TREE_TYPE (type));
+      if (!check_for_bare_parameter_packs (&TREE_TYPE (type)))
+       /* Errors were already issued, set return type to int
+          as the frontend doesn't expect error_mark_node as
+          the return type.  */
+       TREE_TYPE (type) = integer_type_node;
       check_for_bare_parameter_packs (&TYPE_RAISES_EXCEPTIONS (type));
     }
-  else
-    check_for_bare_parameter_packs (&TREE_TYPE (decl));
+  else if (!check_for_bare_parameter_packs (&TREE_TYPE (decl)))
+    return error_mark_node;
 
   if (is_partial)
     return process_partial_specialization (decl);
index 7a5f41af85bb43ac44cbb166ffd4c2e29588c1bd..f4337d28539035bafbbc609618ce8aa76682569e 100644 (file)
@@ -1,5 +1,17 @@
 2007-11-13  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/34054
+       PR c++/34056
+       PR c++/34057
+       PR c++/34058
+       PR c++/34060
+       * g++.dg/parse/crash36.C: Add another dg-error.
+       * g++.dg/cpp0x/pr34054.C: New test.
+       * g++.dg/cpp0x/pr34056.C: New test.
+       * g++.dg/cpp0x/pr34057.C: New test.
+       * g++.dg/cpp0x/pr34058.C: New test.
+       * g++.dg/cpp0x/pr34060.C: New test.
+
        PR tree-optimization/34063
        * g++.dg/tree-ssa/pr34063.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34054.C b/gcc/testsuite/g++.dg/cpp0x/pr34054.C
new file mode 100644 (file)
index 0000000..cfc6c4b
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/34054
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+template<typename... T> T foo() {} // { dg-error "not expanded|T" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34056.C b/gcc/testsuite/g++.dg/cpp0x/pr34056.C
new file mode 100644 (file)
index 0000000..0e5246b
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/34056
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+template<typename... T> struct A
+{
+  void foo (T *) { ++p; }      // { dg-error "not expanded|T" }
+  void bar (T **) { }          // { dg-error "not expanded|T" }
+  T *p;                                // { dg-error "not expanded|T" }
+};
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34057.C b/gcc/testsuite/g++.dg/cpp0x/pr34057.C
new file mode 100644 (file)
index 0000000..38da5ff
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/34057
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+template <typename... T> struct A
+{
+  typedef T X __attribute__ ((vector_size (8))); // { dg-error "not expanded|T" }
+};
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34058.C b/gcc/testsuite/g++.dg/cpp0x/pr34058.C
new file mode 100644 (file)
index 0000000..0cf1fae
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/34058
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+template <typename...T> struct A
+{
+  typedef T X; // { dg-error "not expanded|T" }
+};
+
+A<int> a;
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34060.C b/gcc/testsuite/g++.dg/cpp0x/pr34060.C
new file mode 100644 (file)
index 0000000..8e0d321
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/34060
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+template <int> struct A
+{
+  template <typename... > struct B {};
+  template <typename... T> struct B <int, T *> {}; // { dg-error "not expanded|T" }
+};
+
+A<0>::B<int>b;
index e73e928350d4f6177eabe3437391886f9304b9ca..bcd96e4ec1f91b2811abf4de9a8b019b73bc5850 100644 (file)
@@ -5,7 +5,7 @@
 template <typename... T> struct A      // { dg-error "does not include variadic templates" }
 {
   static T &t;                         // { dg-error "not expanded with|T" }
-  static const int i = sizeof (++t);
+  static const int i = sizeof (++t);   // { dg-error "was not declared in this scope" }
 };
 
 int x[A <int>::i];     // { dg-error "is not an integral constant-expression" }