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]

[patch] Fix PR c++/28853: ICE on invalid use of template template parameter


The following invalid testcase triggers an ICE since GCC 4.0.0:

  template<template<int> class A> int A<0>::i;

bug.cc:1: internal compiler error: in cxx_incomplete_type_diagnostic, at cp/typeck2.c:426
Please submit a full bug report, [etc.]

The problem is that the switch statement in cxx_incomplete_type_diagnostic
doesn't handle BOUND_TEMPLATE_TEMPLATE_PARMs. The compiler ends up in the
default case which calls gcc_unreachable().

The following patch fixes the problem by adding an appropriate case
in the switch statement. It also improves the error message for
another case.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline, 4.1 branch, and 4.0 branch?

Regards,
Volker

:ADDPATCH C++:


2006-08-25  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/28853
	* typeck2.c (cxx_incomplete_type_diagnostic): Handle template
	template parameters.  Improve error message for template type
	parameters.

===================================================================
--- gcc/gcc/cp/typeck2.c	2006-06-23 23:53:36 +0200
+++ gcc/gcc/cp/typeck2.c	2006-08-19 22:52:54 +0200
@@ -403,9 +403,14 @@ cxx_incomplete_type_diagnostic (tree val
       break;
 
     case TEMPLATE_TYPE_PARM:
-      p_msg ("invalid use of template type parameter");
+      p_msg ("invalid use of template type parameter %qT", type);
       break;
 
+    case BOUND_TEMPLATE_TEMPLATE_PARM:
+      p_msg ("invalid use of template template parameter %qT",
+            TYPE_NAME (type));
+      break;
+
     case TYPENAME_TYPE:
       p_msg ("invalid use of dependent type %qT", type);
       break;
===================================================================

2006-08-25  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/28853
	* g++.dg/template/ttp21.C: New test.

===================================================================
--- gcc/gcc/testsuite/g++.dg/template/ttp21.C	2003-09-23 19:59:22 +0200
+++ gcc/gcc/testsuite/g++.dg/template/ttp21.C	2006-08-20 00:52:06 +0200
@@ -0,0 +1,5 @@
+// PR c++/28853
+// { dg-do compile }
+
+template<template<int> class A>
+int A<0>::i;  // { dg-error "template template parameter" }
===================================================================



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