aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-11-13 19:27:09 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2007-11-13 19:27:09 +0100
commit046e40718070e75485fd70ff7d4349596bb7630a (patch)
tree35c42534fc87425283ca5817c084bcdc35bb88eb /gcc
parentf6ee9faefced4284e4d602a84a745e3456a58f2e (diff)
downloadgcc-046e40718070e75485fd70ff7d4349596bb7630a.zip
gcc-046e40718070e75485fd70ff7d4349596bb7630a.tar.gz
gcc-046e40718070e75485fd70ff7d4349596bb7630a.tar.bz2
re PR c++/34054 (ICE with parameter pack in return type)
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog13
-rw-r--r--gcc/cp/pt.c22
-rw-r--r--gcc/testsuite/ChangeLog12
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr34054.C5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr34056.C10
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr34057.C8
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr34058.C10
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr34060.C11
-rw-r--r--gcc/testsuite/g++.dg/parse/crash36.C2
9 files changed, 88 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1bcad75..efc48a9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 0339a8c..8a95ccf 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7a5f41a..f4337d28 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..cfc6c4b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr34054.C
@@ -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
index 0000000..0e5246b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr34056.C
@@ -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
index 0000000..38da5ff
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr34057.C
@@ -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
index 0000000..0cf1fae
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr34058.C
@@ -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
index 0000000..8e0d321
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr34060.C
@@ -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;
diff --git a/gcc/testsuite/g++.dg/parse/crash36.C b/gcc/testsuite/g++.dg/parse/crash36.C
index e73e928..bcd96e4 100644
--- a/gcc/testsuite/g++.dg/parse/crash36.C
+++ b/gcc/testsuite/g++.dg/parse/crash36.C
@@ -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" }