From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Reimers To: 'Philippe Bouchard' Cc: "'gcc-bugs@gcc.gnu.org'" Subject: RE: Bug report Date: Fri, 20 Aug 1999 11:23:00 -0000 Message-id: <71B30885B657D111809D080009EEBBF39C9F7D@mailserv.molienergy.bc.ca> X-SW-Source: 1999-08/msg00785.html List-Id: See below. > ---------- > From: Philippe Bouchard[SMTP:boucp00@DMI.USherb.CA] > Sent: Friday, August 20, 1999 12:08 AM > To: > Subject: Bug report > > OK, I have a situation here. > I have defined a template wrapper class from which I can only perform > casts to the template type. > In my subclass (class text), I have defined the operator << as taking > "const text &" and "text &", but the compiler is confused about which > one of the cast operator to use between the two defined in class gc. > In this case, it should be smart enough to take the shortest way > between an object of type gc and a function taking "const text &" and > "text &". > Here is the wrapper class: > template class gc { >    ... >    operator const TYPE & () const; >    operator TYPE & () const; Here it appears you are trying to overload based on return type. This is not allowed in C++. JR >    ... >    }; > Here is the subclass: > class text { >    ... >   text(char * const); >   friend text & operator << (text &, const text &); >    ... >    }; > Here is the function in question, it should use the "text &" operator > for the first argument and the "const text &" operator for the second > one... > text & operator << (text &, const text &); > int main() { >    const gc a; >    a << "Some text..."; >    ... >    } > Here's exactly what the compiler is complaining about: > testgc.cc: In function `int main()': > testgc.cc:14: conversion from `gc' to `const text &' is > ambiguous > gc.h:141: candidates are: gc::operator const text &() > const > gc.h:146:                 gc::operator text &() const > gc.h:151:                 gc::operator text &() match> > I am using "g++ testgc.cc -Wall" as the command line. > Reading specs from > /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs > gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) >   > Thank you. > Philippe. > >>From bernds@cygnus.co.uk Fri Aug 20 11:29:00 1999 From: Bernd Schmidt To: Loring Holden Cc: wilson@cygnus.com, gcc-bugs@gcc.gnu.org Subject: Re: gcc won't compile from cvs on sparc Date: Fri, 20 Aug 1999 11:29:00 -0000 Message-id: References: <199908201012.GAA19075@poplar.cs.brown.edu> X-SW-Source: 1999-08/msg00786.html Content-length: 11252 > I can't compile egcs from cvs sources (as of 10:45 EDT Aug 19) on sparc. > > The compilation of cc1 dies with: > Undefined first referenced > symbol in file > emit_float_lib_cmp insn-emit.o This patch should fix it. Jim, is this one OK? Bernd * optabs.c (prepare_cmp_insn): Turn COMPARISON arg into a pointer. All callers changed. (prepare_float_lib_cmp): Likewise. Use FLOAT_LIB_COMPARE_RETURNS_BOOL. * expr.h (emit_float_lib_cmp): Delete declaration. * tm.texi (FLOAT_LIB_COMPARE_RETURNS_BOOL): Document. * sparc.h (FLOAT_LIB_COMPARE_RETURNS_BOOL): Define. * sparc.md (bcc and scc patterns): Don't handle TFmode comparisons specially. (cmptf): Now conditional on TARGET_HARD_QUAD. Index: optabs.c =================================================================== RCS file: /egcs/carton/cvsfiles/egcs/gcc/optabs.c,v retrieving revision 1.39 diff -u -p -r1.39 optabs.c --- optabs.c 1999/08/18 17:51:26 1.39 +++ optabs.c 1999/08/20 17:10:58 @@ -270,11 +270,11 @@ static void init_traps PROTO((void)); static int cmp_available_p PROTO((enum machine_mode, enum rtx_code, int)); static void emit_cmp_and_jump_insn_1 PROTO((rtx, rtx, enum machine_mode, enum rtx_code, int, rtx)); -static void prepare_cmp_insn PROTO((rtx *, rtx *, enum rtx_code, rtx, +static void prepare_cmp_insn PROTO((rtx *, rtx *, enum rtx_code *, rtx, enum machine_mode *, int *, int)); static rtx prepare_operand PROTO((int, rtx, int, enum machine_mode, enum machine_mode, int)); -static void prepare_float_lib_cmp PROTO((rtx *, rtx *, enum rtx_code, +static void prepare_float_lib_cmp PROTO((rtx *, rtx *, enum rtx_code *, enum machine_mode *, int *)); /* Add a REG_EQUAL note to the last insn in SEQ. TARGET is being set to @@ -3020,14 +3020,15 @@ cmp_available_p (mode, code, can_use_tst should perform the comparison on the modified values. */ void -prepare_cmp_insn (px, py, comparison, size, pmode, punsignedp, align) +prepare_cmp_insn (px, py, pcomparison, size, pmode, punsignedp, align) rtx *px, *py; - enum rtx_code comparison; + enum rtx_code *pcomparison; rtx size; enum machine_mode *pmode; int *punsignedp; int align; { + enum rtx_code comparison = *pcomparison; enum machine_mode mode = *pmode; rtx x = *px, y = *py; int unsignedp = *punsignedp; @@ -3181,7 +3182,7 @@ prepare_cmp_insn (px, py, comparison, si } if (class == MODE_FLOAT) - prepare_float_lib_cmp (px, py, comparison, pmode, punsignedp); + prepare_float_lib_cmp (px, py, pcomparison, pmode, punsignedp); else abort (); @@ -3322,7 +3323,7 @@ emit_cmp_and_jump_insns (x, y, compariso emit_queue (); if (unsignedp) comparison = unsigned_condition (comparison); - prepare_cmp_insn (&op0, &op1, comparison, size, &mode, &unsignedp, align); + prepare_cmp_insn (&op0, &op1, &comparison, size, &mode, &unsignedp, align); emit_cmp_and_jump_insn_1 (op0, op1, mode, comparison, unsignedp, label); } @@ -3361,12 +3362,13 @@ can_compare_p (mode) COMPARISON is the rtl operator to compare with (EQ, NE, GT, etc.). */ void -prepare_float_lib_cmp (px, py, comparison, pmode, punsignedp) +prepare_float_lib_cmp (px, py, pcomparison, pmode, punsignedp) rtx *px, *py; - enum rtx_code comparison; + enum rtx_code *pcomparison; enum machine_mode *pmode; int *punsignedp; { + enum rtx_code comparison = *pcomparison; rtx x = *px, y = *py; enum machine_mode mode = GET_MODE (x); rtx libfunc = 0; @@ -3537,7 +3539,7 @@ prepare_float_lib_cmp (px, py, compariso y = protect_from_queue (y, 0); *px = convert_to_mode (wider_mode, x, 0); *py = convert_to_mode (wider_mode, y, 0); - prepare_float_lib_cmp (px, py, comparison, pmode, punsignedp); + prepare_float_lib_cmp (px, py, pcomparison, pmode, punsignedp); return; } } @@ -3558,6 +3560,10 @@ prepare_float_lib_cmp (px, py, compariso *px = result; *py = const0_rtx; *pmode = word_mode; +#ifdef FLOAT_LIB_COMPARE_RETURNS_BOOL + if (FLOAT_LIB_COMPARE_RETURNS_BOOL (mode, comparison)) + *pcomparison = NE; +#endif *punsignedp = 0; } Index: tm.texi =================================================================== RCS file: /egcs/carton/cvsfiles/egcs/gcc/tm.texi,v retrieving revision 1.84 diff -u -p -r1.84 tm.texi --- tm.texi 1999/08/02 23:17:06 1.84 +++ tm.texi 1999/08/20 17:11:01 @@ -4046,6 +4046,15 @@ Define this macro as a C statement that routines renames existing ones. @code{init_optabs} calls this macro after initializing all the normal library routines. +@findex FLOAT_LIB_COMPARE_RETURNS_BOOL (@var{mode}, @var{comparison}) +@item FLOAT_LIB_COMPARE_RETURNS_BOOL +Define this macro as a C statement that returns nonzero if a call to +the floating point comparison library function will return a boolean +value that indicates the result of the comparison. It should return +zero if one of gcc's own libgcc functions is called. + +Most ports don't need to define this macro. + @findex TARGET_EDOM @cindex @code{EDOM}, implicit usage @item TARGET_EDOM Index: config/sparc/sparc.h =================================================================== RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/sparc/sparc.h,v retrieving revision 1.74 diff -u -p -r1.74 sparc.h --- config/sparc/sparc.h 1999/08/09 14:00:12 1.74 +++ config/sparc/sparc.h 1999/08/20 17:11:05 @@ -2676,6 +2676,11 @@ do { /* This is meant to be redefined in the host dependent files */ #define INIT_SUBTARGET_OPTABS +/* Nonzero if a floating point comparison library call for + mode MODE that will return a boolean value. Zero if one + of the libgcc2 functions is used. */ +#define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) ((MODE) == TFmode) + /* Compute the cost of computing a constant rtl expression RTX whose rtx-code is CODE. The body of this macro is a portion of a switch statement. If the code is computed here, Index: config/sparc/sparc.md =================================================================== RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/sparc/sparc.md,v retrieving revision 1.74 diff -u -p -r1.74 sparc.md --- config/sparc/sparc.md 1999/08/02 22:58:04 1.74 +++ config/sparc/sparc.md 1999/08/20 17:11:06 @@ -606,7 +606,7 @@ [(set (reg:CCFP 96) (compare:CCFP (match_operand:TF 0 "register_operand" "") (match_operand:TF 1 "register_operand" "")))] - "TARGET_FPU" + "TARGET_FPU && TARGET_HARD_QUAD" " { sparc_compare_op0 = operands[0]; @@ -834,12 +834,6 @@ emit_insn (pat); DONE; } - else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, EQ); - emit_insn (gen_sne (operands[0])); - DONE; - } else if (TARGET_V9) { if (gen_v9_scc (EQ, operands)) @@ -887,12 +881,6 @@ emit_insn (pat); DONE; } - else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, NE); - emit_insn (gen_sne (operands[0])); - DONE; - } else if (TARGET_V9) { if (gen_v9_scc (NE, operands)) @@ -908,13 +896,7 @@ "! TARGET_LIVE_G0" " { - if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GT); - emit_insn (gen_sne (operands[0])); - DONE; - } - else if (TARGET_V9) + if (TARGET_V9) { if (gen_v9_scc (GT, operands)) DONE; @@ -929,13 +911,7 @@ "! TARGET_LIVE_G0" " { - if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LT); - emit_insn (gen_sne (operands[0])); - DONE; - } - else if (TARGET_V9) + if (TARGET_V9) { if (gen_v9_scc (LT, operands)) DONE; @@ -950,13 +926,7 @@ "! TARGET_LIVE_G0" " { - if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GE); - emit_insn (gen_sne (operands[0])); - DONE; - } - else if (TARGET_V9) + if (TARGET_V9) { if (gen_v9_scc (GE, operands)) DONE; @@ -971,13 +941,7 @@ "! TARGET_LIVE_G0" " { - if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LE); - emit_insn (gen_sne (operands[0])); - DONE; - } - else if (TARGET_V9) + if (TARGET_V9) { if (gen_v9_scc (LE, operands)) DONE; @@ -1605,12 +1569,6 @@ emit_v9_brxx_insn (EQ, sparc_compare_op0, operands[0]); DONE; } - else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, EQ); - emit_jump_insn (gen_bne (operands[0])); - DONE; - } operands[1] = gen_compare_reg (EQ, sparc_compare_op0, sparc_compare_op1); }") @@ -1629,12 +1587,6 @@ emit_v9_brxx_insn (NE, sparc_compare_op0, operands[0]); DONE; } - else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, NE); - emit_jump_insn (gen_bne (operands[0])); - DONE; - } operands[1] = gen_compare_reg (NE, sparc_compare_op0, sparc_compare_op1); }") @@ -1653,12 +1605,6 @@ emit_v9_brxx_insn (GT, sparc_compare_op0, operands[0]); DONE; } - else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GT); - emit_jump_insn (gen_bne (operands[0])); - DONE; - } operands[1] = gen_compare_reg (GT, sparc_compare_op0, sparc_compare_op1); }") @@ -1687,12 +1633,6 @@ emit_v9_brxx_insn (LT, sparc_compare_op0, operands[0]); DONE; } - else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LT); - emit_jump_insn (gen_bne (operands[0])); - DONE; - } operands[1] = gen_compare_reg (LT, sparc_compare_op0, sparc_compare_op1); }") @@ -1721,12 +1661,6 @@ emit_v9_brxx_insn (GE, sparc_compare_op0, operands[0]); DONE; } - else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GE); - emit_jump_insn (gen_bne (operands[0])); - DONE; - } operands[1] = gen_compare_reg (GE, sparc_compare_op0, sparc_compare_op1); }") @@ -1755,12 +1689,6 @@ emit_v9_brxx_insn (LE, sparc_compare_op0, operands[0]); DONE; } - else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD) - { - emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LE); - emit_jump_insn (gen_bne (operands[0])); - DONE; - } operands[1] = gen_compare_reg (LE, sparc_compare_op0, sparc_compare_op1); }")