Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: complex numbers in c-valprint.c
@ 2002-01-30 20:31 Daniel Jacobowitz
  2002-02-03 14:43 ` Jim Blandy
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2002-01-30 20:31 UTC (permalink / raw)
  To: gdb-patches

This patch fixes half of gdb/320.  The other half is a bug in GCC 3.x, that
I just CC'd gdb@ about.

Is this OK to commit?  Does anyone have a preference for {0, 0} vs. { re =
0, im = 0}?  I used the former.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

2002-01-30  Daniel Jacobowitz  <drow@mvista.com>

	* c-valprint.c (c_val_print): Handle TYPE_CODE_COMPLEX.

Index: c-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-valprint.c,v
retrieving revision 1.11
diff -u -r1.11 c-valprint.c
--- c-valprint.c	2001/11/10 20:44:37	1.11
+++ c-valprint.c	2002/01/31 04:26:09
@@ -459,6 +459,29 @@
       fprintf_filtered (stream, "<incomplete type>");
       break;
 
+    case TYPE_CODE_COMPLEX:
+      fprintf_filtered (stream, "{");
+      if (format)
+	print_scalar_formatted (valaddr + embedded_offset,
+				TYPE_TARGET_TYPE (type),
+				format, 0, stream);
+      else
+	print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type),
+			stream);
+      fprintf_filtered (stream, ", ");
+      if (format)
+	print_scalar_formatted (valaddr + embedded_offset
+				+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
+				TYPE_TARGET_TYPE (type),
+				format, 0, stream);
+      else
+	print_floating (valaddr + embedded_offset
+			+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
+			TYPE_TARGET_TYPE (type),
+			stream);
+      fprintf_filtered (stream, "}");
+      break;
+
     default:
       error ("Invalid C/C++ type code %d in symbol table.", TYPE_CODE (type));
     }


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFA: complex numbers in c-valprint.c
  2002-01-30 20:31 RFA: complex numbers in c-valprint.c Daniel Jacobowitz
@ 2002-02-03 14:43 ` Jim Blandy
  2002-02-03 14:52   ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2002-02-03 14:43 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches


Daniel Jacobowitz <drow@mvista.com> writes:
> This patch fixes half of gdb/320.  The other half is a bug in GCC 3.x, that
> I just CC'd gdb@ about.
> 
> Is this OK to commit?  Does anyone have a preference for {0, 0} vs. { re =
> 0, im = 0}?  I used the former.

{0, 0} looks to me like GDB's syntax for array literals.  In ISO C
programs, don't you just write complex literals as x+I*y?  What's wrong
with GDB printing that?

If you say, "It shouldn't be an expression!", then I'll just say, "We
already print negative numbers as an expression!"  Lexically speaking,
C integer literals can't have a sign.  `-3' is an application of the
prefix operator `-' to the literal `3'.  Since the spec promises that
the compiler will fold constant expressions, you don't need a
dedicated syntax for negative numbers.  I assume the same thinking is
behind the lack of any syntactic support for complex literals.

(The bikeshed should be a nice yellow-green, I think.)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFA: complex numbers in c-valprint.c
  2002-02-03 14:43 ` Jim Blandy
@ 2002-02-03 14:52   ` Daniel Jacobowitz
  2002-02-05 11:24     ` Jim Blandy
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2002-02-03 14:52 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb-patches

On Sun, Feb 03, 2002 at 05:44:50PM -0500, Jim Blandy wrote:
> 
> Daniel Jacobowitz <drow@mvista.com> writes:
> > This patch fixes half of gdb/320.  The other half is a bug in GCC 3.x, that
> > I just CC'd gdb@ about.
> > 
> > Is this OK to commit?  Does anyone have a preference for {0, 0} vs. { re =
> > 0, im = 0}?  I used the former.
> 
> {0, 0} looks to me like GDB's syntax for array literals.  In ISO C
> programs, don't you just write complex literals as x+I*y?  What's wrong
> with GDB printing that?
> 
> If you say, "It shouldn't be an expression!", then I'll just say, "We
> already print negative numbers as an expression!"  Lexically speaking,
> C integer literals can't have a sign.  `-3' is an application of the
> prefix operator `-' to the literal `3'.  Since the spec promises that
> the compiler will fold constant expressions, you don't need a
> dedicated syntax for negative numbers.  I assume the same thinking is
> behind the lack of any syntactic support for complex literals.

x + y * I, I think.  That's nice; I didn't realize C99 and <complex.h>
supported ``I''.

OK with that syntax change?

> (The bikeshed should be a nice yellow-green, I think.)

...

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFA: complex numbers in c-valprint.c
  2002-02-03 14:52   ` Daniel Jacobowitz
@ 2002-02-05 11:24     ` Jim Blandy
  2002-02-05 13:41       ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2002-02-05 11:24 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches


Daniel Jacobowitz <drow@mvista.com> writes:
> x + y * I, I think.  That's nice; I didn't realize C99 and <complex.h>
> supported ``I''.
> 
> OK with that syntax change?

Cool with me.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: RFA: complex numbers in c-valprint.c
  2002-02-05 11:24     ` Jim Blandy
@ 2002-02-05 13:41       ` Daniel Jacobowitz
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2002-02-05 13:41 UTC (permalink / raw)
  To: gdb-patches

On Tue, Feb 05, 2002 at 02:26:18PM -0500, Jim Blandy wrote:
> 
> Daniel Jacobowitz <drow@mvista.com> writes:
> > x + y * I, I think.  That's nice; I didn't realize C99 and <complex.h>
> > supported ``I''.
> > 
> > OK with that syntax change?
> 
> Cool with me.

Thanks, committed.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-02-05 21:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-30 20:31 RFA: complex numbers in c-valprint.c Daniel Jacobowitz
2002-02-03 14:43 ` Jim Blandy
2002-02-03 14:52   ` Daniel Jacobowitz
2002-02-05 11:24     ` Jim Blandy
2002-02-05 13:41       ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox