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 12774


Mark,
this patch fixes 12774. Your intuition about my array mangling fix was
correct -- I just needed to enable something similar for ABI-1.

booted and tested on i686-pc-linux-gnu, ok?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2003-12-23  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/12774
	* typeck.c (comp_array_types): Fold non-dependent domains for
	ABI-1.

Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.516
diff -c -3 -p -r1.516 typeck.c
*** cp/typeck.c	21 Dec 2003 21:07:31 -0000	1.516
--- cp/typeck.c	22 Dec 2003 17:43:01 -0000
*************** comp_array_types (tree t1, tree t2, bool
*** 857,862 ****
--- 857,863 ----
  {
    tree d1;
    tree d2;
+   tree max1, max2;
  
    if (t1 == t2)
      return true;
*************** comp_array_types (tree t1, tree t2, bool
*** 887,894 ****
      return allow_redeclaration;
  
    /* Check that the dimensions are the same.  */
!   return (cp_tree_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2))
! 	  && cp_tree_equal (TYPE_MAX_VALUE (d1), TYPE_MAX_VALUE (d2)));
  }
  
  /* Return true if T1 and T2 are related as allowed by STRICT.  STRICT
--- 888,914 ----
      return allow_redeclaration;
  
    /* Check that the dimensions are the same.  */
! 
!   if (!cp_tree_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2)))
!     return false;
!   max1 = TYPE_MAX_VALUE (d1);
!   max2 = TYPE_MAX_VALUE (d2);
!   if (processing_template_decl && !abi_version_at_least (2)
!       && !value_dependent_expression_p (max1)
!       && !value_dependent_expression_p (max2))
!     {
!       /* With abi-1 we do not fold non-dependent array bounds, (and
!          consequently mangle them incorrectly).  We must therefore
!          fold them here, to verify the domains have the same
!          value.  */
!       max1 = fold (max1);
!       max2 = fold (max2);
!     }
! 
!   if (!cp_tree_equal (max1, max2))
!     return false;
! 
!   return true;
  }
  
  /* Return true if T1 and T2 are related as allowed by STRICT.  STRICT
// { dg-do compile }
// { dg-options "-fabi-version=1" }

// Contributed by Nathan Sidwell 22 Dec 2003 <nathan@codesourcery.com>
// Origin: Roger Sayle  <roger@eyesopen.com>

// PR c++/12774 Array domains compared unequal

void Foo(double r[3][3])
{
}

void Baz()
{
   double m[3][3];
   Foo(m);
}

template <class T>
void Bar()
{
   double m[3][3];
   Foo(m);
}

int main()
{
   Baz();
   Bar<int>();
   return 0;
}

// { dg-do compile }
// { dg-options "-fabi-version=2" }

// Contributed by Nathan Sidwell 22 Dec 2003 <nathan@codesourcery.com>
// Origin: Roger Sayle  <roger@eyesopen.com>

// PR c++/12774 Array domains compared unequal

void Foo(double r[3][3])
{
}

void Baz()
{
   double m[3][3];
   Foo(m);
}

template <class T>
void Bar()
{
   double m[3][3];
   Foo(m);
}

int main()
{
   Baz();
   Bar<int>();
   return 0;
}


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