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]

[C++ PATCH, committed] Fix incorrect diagnostics (PR 8772)


Hi

This is a fix to PR8772 where we issue incorrect error message
about template parameter mismatch.  When the template argument 
is non-type, `expected a type' is always displayed even for
template template parameters.  Fix by the following patch.

Patch committed to trunk as obvious.  Tested on i686-pc-linux-gnu.

--Kriang


2003-05-01  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/8772
	* pt.c (convert_template_argument): Correct diagnostic.

2003-05-01  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/8772
	* g++.dg/template/ttp5.C: New test.


diff -cprN gcc-main-save/gcc/cp/pt.c gcc-main-new/gcc/cp/pt.c
*** gcc-main-save/gcc/cp/pt.c	Tue Apr 29 21:11:06 2003
--- gcc-main-new/gcc/cp/pt.c	Thu May  1 17:13:37 2003
*************** convert_template_argument (parm, arg, ar
*** 3579,3584 ****
--- 3579,3586 ----
  		error ("  expected a constant of type `%T', got `%T'",
  			  TREE_TYPE (parm),
  			  (is_tmpl_type ? DECL_NAME (arg) : arg));
+ 	      else if (requires_tmpl_type)
+ 		error ("  expected a class template, got `%E'", arg);
  	      else
  		error ("  expected a type, got `%E'", arg);
  	    }
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/template/ttp5.C gcc-main-new/gcc/testsuite/g++.dg/template/ttp5.C
*** gcc-main-save/gcc/testsuite/g++.dg/template/ttp5.C	Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/template/ttp5.C	Thu May  1 17:17:37 2003
***************
*** 0 ****
--- 1,20 ----
+ // { dg-do compile }
+ 
+ // Origin: sneechy@hotmail.com
+ 
+ // PR c++/8772: Incorrect diagnostics for template template parameter
+ // mismatch
+ 
+ template <int> struct A {
+   template <int> struct B {
+     enum { v = 1 };
+   };
+ };
+ 
+ template <template <int> class F> struct C {
+   enum { v = F<1>::v || 2 }; 
+ };
+ 
+ template <int n> struct D {
+   enum { v = C<A<n>::B>::v }; // { dg-error "mismatch|class template|not a member" }
+ };


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