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]: Fix 196


Hi,
I've installed this obvious fix for PR 196.  The code is ill-formed, but
the diagnostic is not at all helpful.

built & tested on i686-pc-linux-gnu.

I've also installed a test case from PR 411, which appears fixed, but
looks important not to break.

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-12-26  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/196
	* cp/parse.y (bad_parm): Better diagnostic when given a SCOPE_REF.

Index: cp/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parse.y,v
retrieving revision 1.238
diff -c -3 -p -r1.238 parse.y
*** parse.y	2001/12/18 03:35:35	1.238
--- parse.y	2001/12/26 18:46:40
*************** bad_parm:
*** 3766,3776 ****
  		}
  	| notype_declarator
  		{
! 		  error ("type specifier omitted for parameter");
! 		  if (TREE_CODE ($$) == SCOPE_REF
! 		      && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
! 			  || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM))
! 		    error ("  perhaps you want `typename %E' to make it a type", $$);
  		  $$ = build_tree_list (integer_type_node, $$);
  		}
  	;
--- 3766,3781 ----
  		}
  	| notype_declarator
  		{
! 		  if (TREE_CODE ($$) == SCOPE_REF)
! 		    {
! 		      if (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
! 			  || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM)
! 			error ("`%E' is not a type, use `typename %E' to make it one", $$);
! 		      else
! 			error ("no type `%D' in `%T'", TREE_OPERAND ($$, 1), TREE_OPERAND ($$, 0));
! 		    }
! 		  else
! 		    error ("type specifier omitted for parameter `%E'", $$);
  		  $$ = build_tree_list (integer_type_node, $$);
  		}
  	;
// { dg-do compile }

// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@nathan@codesourcery.com>

// PR 196. Misleading diagnostic

namespace N
{
  class B { friend void operator>>(int, class B); };
  class N { friend void operator>>(int,class N); };
} 
void N::operator>>(int, N::B)  // { dg-error "no type `B' in `N::N'" "" }
{ } // { dg-error "" "" }
// { dg-do run }

// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@nathan@codesourcery.com>

// PR 411

bool was_f_in_Bar_destroyed=false;

struct Foo
{
  ~Foo()
  {
    was_f_in_Bar_destroyed=true;
  }
};

struct Bar
{
  ~Bar()
  {
    throw 1;
  }
  
  Foo f;
};

int main()
{
  try
    {
      Bar f; 
    }
  catch(int i)
    {
      if(was_f_in_Bar_destroyed)
	{
	  return 0;
	}
    }
  return 1;
}

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