re PR c++/27427 (ICE with invalid template parameter)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Sat, 6 May 2006 20:40:23 +0000 (20:40 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Sat, 6 May 2006 20:40:23 +0000 (20:40 +0000)
PR c++/27427
* pt.c (convert_nontype_argument): Return early on invalid arguments.

* g++.dg/template/incomplete2.C: New test.

From-SVN: r113582

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/incomplete2.C [new file with mode: 0644]

index 4f460a37e8631204150eca92d133fc26d2371c9d..5035ded8afa8c96f77be289238ef09d5f1e2b1d6 100644 (file)
@@ -1,5 +1,8 @@
 2006-05-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c++/27427
+       * pt.c (convert_nontype_argument): Return early on invalid arguments.
+
        * pt.c (process_template_parm): Remove superfluous temporary.
 
        PR c++/27430
index c7d94f1a7bae9451db3fe5cefb733b6e2e827da3..4d34da477ddae1ada444b290a224ccfabc0166b0 100644 (file)
@@ -3457,6 +3457,8 @@ convert_nontype_argument (tree type, tree expr)
      instantiated -- but here we need the resolved form so that we can
      convert the argument.  */
   expr = fold_non_dependent_expr (expr);
+  if (error_operand_p (expr))
+    return error_mark_node;
   expr_type = TREE_TYPE (expr);
 
   /* HACK: Due to double coercion, we can get a
index 3e6e72511a1689444e3e19f85472b634394d54df..63e386943b24c636aa0d8d1bf7e89ed0967117ad 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/27427
+       * g++.dg/template/incomplete2.C: New test.
+
 2006-05-06   Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/27151
diff --git a/gcc/testsuite/g++.dg/template/incomplete2.C b/gcc/testsuite/g++.dg/template/incomplete2.C
new file mode 100644 (file)
index 0000000..23d393e
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/27427
+// { dg-do compile }
+
+struct A;
+
+template<A&> void foo();
+
+A a;  // { dg-error "incomplete type" }
+
+void bar()
+{
+  foo<a>();  // { dg-error "no matching function" }
+}