aboutsummaryrefslogtreecommitdiff
path: root/gdb/linespec.c
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2009-09-21 19:46:43 +0000
committerKeith Seitz <keiths@redhat.com>2009-09-21 19:46:43 +0000
commit1290797801825ff96506c8197d301b60154c3250 (patch)
treef67a841cbe9ea0494e161fc4f3522abc7fa758ab /gdb/linespec.c
parent11ef0d76ab7ca2b103955a98af4aa0eb7dbf74ab (diff)
downloadfsf-binutils-gdb-1290797801825ff96506c8197d301b60154c3250.zip
fsf-binutils-gdb-1290797801825ff96506c8197d301b60154c3250.tar.gz
fsf-binutils-gdb-1290797801825ff96506c8197d301b60154c3250.tar.bz2
* cp-support.h (cp_validate_operator): Declare new function.
* cp-support.c (cp_validate_operator): New function. * linespec.c (decode_compound): For C++ check for a valid operator.
Diffstat (limited to 'gdb/linespec.c')
-rw-r--r--gdb/linespec.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 3e943a1..70e27f76 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -30,6 +30,7 @@
#include "value.h"
#include "completer.h"
#include "cp-abi.h"
+#include "cp-support.h"
#include "parser-defs.h"
#include "block.h"
#include "objc-lang.h"
@@ -1257,6 +1258,9 @@ decode_compound (char **argptr, int funfirstline, char ***canonical,
/* Move pointer ahead to next double-colon. */
while (*p && (p[0] != ' ') && (p[0] != '\t') && (p[0] != '\''))
{
+ if (current_language->la_language == language_cplus)
+ p += cp_validate_operator (p);
+
if (p[0] == '<')
{
temp_end = find_template_name_end (p);
@@ -1334,6 +1338,15 @@ decode_compound (char **argptr, int funfirstline, char ***canonical,
while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p != ':')
p++;
/* At this point p->"". String ended. */
+ /* Nope, C++ operators could have spaces in them
+ ("foo::operator <" or "foo::operator delete []").
+ I apologize, this is a bit hacky... */
+ if (current_language->la_language == language_cplus
+ && *p == ' ' && p - 8 - *argptr + 1 > 0)
+ {
+ /* The above loop has already swallowed "operator". */
+ p += cp_validate_operator (p - 8) - 8;
+ }
}
/* Allocate our own copy of the substring between argptr and
@@ -1474,26 +1487,16 @@ find_method (int funfirstline, char ***canonical, char *saved_arg,
}
else
{
- char *tmp;
-
- if (is_operator_name (copy))
- {
- tmp = (char *) alloca (strlen (copy + 3) + 9);
- strcpy (tmp, "operator ");
- strcat (tmp, copy + 3);
- }
- else
- tmp = copy;
if (not_found_ptr)
*not_found_ptr = 1;
- if (tmp[0] == '~')
+ if (copy[0] == '~')
cplusplus_error (saved_arg,
"the class `%s' does not have destructor defined\n",
SYMBOL_PRINT_NAME (sym_class));
else
cplusplus_error (saved_arg,
"the class %s does not have any method named %s\n",
- SYMBOL_PRINT_NAME (sym_class), tmp);
+ SYMBOL_PRINT_NAME (sym_class), copy);
}
}