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, diagnostic] PR 37719


Hi all, hi Gaby,

I have this patchlet fixing a slightly incorrect error message (throw
(int) instead of throw (float) for the specialization in the testcase).
Tested x86_64-linux. Ok for mainline?

Paolo.

/////////////////////////
/cp
2008-10-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/37719
	* error.c (dump_function_decl): Save the exceptions in case of
	error about incompatible specifications in a specialization.

/testsuite
2008-10-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/37719
	* g++.dg/template/error36.C: New.
Index: testsuite/g++.dg/template/error36.C
===================================================================
*** testsuite/g++.dg/template/error36.C	(revision 0)
--- testsuite/g++.dg/template/error36.C	(revision 0)
***************
*** 0 ****
--- 1,9 ----
+ // PR c++/37719.C
+ 
+ template <typename T>
+ class foo {
+     void bar() throw(int); // { dg-error "throw \\(int\\)" }
+ };
+ 
+ template <>
+ void foo<int>::bar() throw(float) {} // { dg-error "throw \\(float\\)" }
Index: cp/error.c
===================================================================
*** cp/error.c	(revision 140854)
--- cp/error.c	(working copy)
*************** dump_function_decl (tree t, int flags)
*** 1084,1094 ****
--- 1084,1099 ----
    tree template_parms = NULL_TREE;
    int show_return = flags & TFF_RETURN_TYPE || flags & TFF_DECL_SPECIFIERS;
    int do_outer_scope = ! (flags & TFF_UNQUALIFIED_NAME);
+   tree exceptions;
  
    flags &= ~TFF_UNQUALIFIED_NAME;
    if (TREE_CODE (t) == TEMPLATE_DECL)
      t = DECL_TEMPLATE_RESULT (t);
  
+   /* Save the exceptions, in case t is a specialization and we are
+      emitting an error about incompatible specifications.  */
+   exceptions = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (t));
+ 
    /* Pretty print template instantiations only.  */
    if (DECL_USE_TEMPLATE (t) && DECL_TEMPLATE_INFO (t))
      {
*************** dump_function_decl (tree t, int flags)
*** 1153,1159 ****
        if (flags & TFF_EXCEPTION_SPECIFICATION)
  	{
  	  pp_base (cxx_pp)->padding = pp_before;
! 	  dump_exception_spec (TYPE_RAISES_EXCEPTIONS (fntype), flags);
  	}
  
        if (show_return)
--- 1158,1164 ----
        if (flags & TFF_EXCEPTION_SPECIFICATION)
  	{
  	  pp_base (cxx_pp)->padding = pp_before;
! 	  dump_exception_spec (exceptions, flags);
  	}
  
        if (show_return)

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