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]

[C++ patch] fix bug 1960


Hi,
I've installed the attached fix for bug 1960, where we weren't always
generating the correct cvquals for an array type.

built & tested on i686-pc-linux-gnu, approved by Mark.

I'll shortly be putting this on the branch too.

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-02-13  Nathan Sidwell  <nathan@codesourcery.com>

	* tree.c (cp_build_qualified_type_real): Use CP_TYPE_QUALS to
	check whether we already have the type.

Index: cp/tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/tree.c,v
retrieving revision 1.232
diff -c -3 -p -r1.232 tree.c
*** tree.c	2001/02/12 09:58:18	1.232
--- tree.c	2001/02/13 15:53:38
*************** cp_build_qualified_type_real (type, type
*** 516,522 ****
    if (type == error_mark_node)
      return type;
  
!   if (type_quals == TYPE_QUALS (type))
      return type;
  
    /* A restrict-qualified pointer type must be a pointer (or reference)
--- 516,522 ----
    if (type == error_mark_node)
      return type;
  
!   if (type_quals == CP_TYPE_QUALS (type))
      return type;
  
    /* A restrict-qualified pointer type must be a pointer (or reference)
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 13 Feb 2001 <nathan@codesourcery.com>

// Bug 1960. We were not dealing with qualified array types properly.

#include <stdio.h>

template <typename T> int Foo (T const *ptr)
{
  static int count = 0;
  
  printf ("%s\n", __PRETTY_FUNCTION__);
  count++;
  
  return count;
}

int main ()
{
  static int const cs = 1;
  static int const ca[1] = {1};
  static int s = 1;
  static int a[1] = {1};
  
  Foo (&cs);
  Foo (&ca);
  if (Foo (&s) != 2)
    return 1;
  if (Foo (&a) != 2)
    return 2;
  
  return 0;
}

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