Problem with your patch to is_type_conversion_operator

Daniel Jacobowitz
2002-01-16T02:45:18Z

This patch caused a few dozen regressions on the GCC 2.95.x/DWARF-2
combination. This is caused by the v2 vs. v3 use of DW_AT_name for
operators. In v2 we get:
DW_AT_name : operator =
But in v3:
DW_AT_name : operator=

So in v3:
399 if (! strchr (" \t\f\n\r", *name))
400 return 0;
triggers for operator=. We never even go to look at what operator it is.
But for v2 it doesn't, and name is '='. That doesn't look like new. That
doesn't look like delete. It's not a type conversion operator!

Not that there was anything wrong with your patch; it was papering over this
potential bug (well, potential when that code was written).

I've committed the patch below to fix it.

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

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

* c-typeprint.c (is_type_conversion_operator): Add additional
check for non-conversion operators.

Index: c-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-typeprint.c,v
retrieving revision 1.14
diff -u -p -r1.14 c-typeprint.c
--- c-typeprint.c 2002/01/10 00:06:02 1.14
+++ c-typeprint.c 2002/01/16 02:41:47
@@ -402,7 +402,13 @@ is_type_conversion_operator (struct type
while (strchr (" \t\f\n\r", *name))
name++;

- if (strncmp (name, "new", 3) == 0)
+ if (!('a' <= *name && *name <= 'z')
+ && !('A' <= *name && *name <= 'Z')
+ && *name != '_')
+ /* If this doesn't look like the start of an identifier, then it
+ isn't a type conversion operator. */
+ return 0;
+ else if (strncmp (name, "new", 3) == 0)
name += 3;
else if (strncmp (name, "delete", 6) == 0)
name += 6;