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]

[RFC C++ PATCH] Fix PR4447


Hi

The appended patch is a proposed fix to the bug PR4447.  The mangling 
for type cast is missing from GCC.  This patch adds just CAST_EXPR 
handling.  I have question about other new-style casts (such as 
static_cast).  The V3 ABI documentation only list C-style type cast.  
How should new-style cast be mangled?  Is it the same as old C-style cast?
I'll submit a newer version after receiving comments about how this
should be done.

Thank you

--Kriang


2001-10-12  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

        * mangle.c (write_expression): Handle CAST_EXPR.
        * operators.def: Add CAST_EXPR.

diff -cprN gcc-main-save4/gcc/cp/mangle.c gcc-main-new/gcc/cp/mangle.c
*** gcc-main-save4/gcc/cp/mangle.c      Sun Oct  7 23:09:17 2001
--- gcc-main-new/gcc/cp/mangle.c        Fri Oct 12 23:06:07 2001
*************** write_expression (expr)
*** 1827,1832 ****
--- 1827,1837 ----
          else
            write_encoding (TREE_OPERAND (expr, 1));
        }
+       else if (code == CAST_EXPR)
+       {
+         write_type (TREE_TYPE (expr));
+         write_expression (TREE_VALUE (TREE_OPERAND (expr, 0)));
+       }
        else
        for (i = 0; i < TREE_CODE_LENGTH (code); ++i)
          write_expression (TREE_OPERAND (expr, i));
diff -cprN gcc-main-save4/gcc/cp/operators.def gcc-main-new/gcc/cp/operators.def
*** gcc-main-save4/gcc/cp/operators.def Sun Oct  7 23:09:17 2001
--- gcc-main-new/gcc/cp/operators.def   Fri Oct 12 22:57:47 2001
*************** DEF_SIMPLE_OPERATOR ("--", POSTDECREMENT
*** 131,138 ****
  /* These are extensions.  */
  DEF_SIMPLE_OPERATOR ("<?", MIN_EXPR, "v23min", 2)
  DEF_SIMPLE_OPERATOR (">?", MAX_EXPR, "v23max", 2)
! /* This one is needed for mangling.  */
  DEF_SIMPLE_OPERATOR ("::", SCOPE_REF, "sr", 2);
  
  /* Assignment operators.  */
  DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS", 2)
--- 131,139 ----
  /* These are extensions.  */
  DEF_SIMPLE_OPERATOR ("<?", MIN_EXPR, "v23min", 2)
  DEF_SIMPLE_OPERATOR (">?", MAX_EXPR, "v23max", 2)
! /* These are needed for mangling.  */
  DEF_SIMPLE_OPERATOR ("::", SCOPE_REF, "sr", 2);
+ DEF_SIMPLE_OPERATOR ("(cast)", CAST_EXPR, "cv", 1);
  
  /* Assignment operators.  */
  DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS", 2)
diff -cprN gcc-main-save4/gcc/testsuite/g++.dg/abi/cast1.C gcc-main-new/gcc/testsuite/g++.dg/abi/cast1.C
*** gcc-main-save4/gcc/testsuite/g++.dg/abi/cast1.C     Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/abi/cast1.C       Fri Oct 12 23:16:23 2001
***************
*** 0 ****
--- 1,18 ----
+ // Origin: Joe Buck <jbuck@synopsys.com>
+ // { dg-do compile }
+ 
+ template<bool B,int I>
+ class T {
+ public:
+     T(int);
+ };
+ 
+ template<bool B1,bool B2,int I1,int I2>
+ T<(B1&&B2),I1+I2-int(B1&&B2)> 
+ func(T<B1,I1> a, T<B2,I2> b) {
+     return T<(B1&&B2),I1+I2-int(B1&&B2)> (I1+I2);
+ }
+ 
+ void foo(T<true,3> a, T<true,4>b) {
+     func(a, b);
+ }


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