/* YACC parser for C expressions, for GDB.
- Copyright (C) 1986-2013 Free Software Foundation, Inc.
+ Copyright (C) 1986-2014 Free Software Foundation, Inc.
This file is part of GDB.
%{
#include "defs.h"
-#include "gdb_string.h"
+#include <string.h>
#include <ctype.h>
#include "expression.h"
#include "value.h"
static void check_parameter_typelist (VEC (type_ptr) *);
static void write_destructor_name (struct stoken);
+#ifdef YYBISON
static void c_print_token (FILE *file, int type, YYSTYPE value);
#define YYPRINT(FILE, TYPE, VALUE) c_print_token (FILE, TYPE, VALUE)
+#endif
%}
%type <voidval> exp exp1 type_exp start variable qualified_name lcurly
copy = copy_name (yylval.ssym.stoken);
yylval.ssym.sym = cp_lookup_nested_symbol (type, copy, block);
+
+ /* If no symbol was found, search for a matching base class named
+ COPY. This will allow users to enter qualified names of class members
+ relative to the `this' pointer. */
if (yylval.ssym.sym == NULL)
- return ERROR;
+ {
+ struct type *base_type = find_type_baseclass_by_name (type, copy);
+
+ if (base_type != NULL)
+ {
+ yylval.tsym.type = base_type;
+ return TYPENAME;
+ }
+
+ return ERROR;
+ }
switch (SYMBOL_CLASS (yylval.ssym.sym))
{
case LOC_BLOCK:
case LOC_LABEL:
+ /* cp_lookup_nested_symbol might have accidentally found a constructor
+ named COPY when we really wanted a base class of the same name.
+ Double-check this case by looking for a base class. */
+ {
+ struct type *base_type = find_type_baseclass_by_name (type, copy);
+
+ if (base_type != NULL)
+ {
+ yylval.tsym.type = base_type;
+ return TYPENAME;
+ }
+ }
return ERROR;
case LOC_TYPEDEF:
return result;
}
+#ifdef YYBISON
+
/* This is called via the YYPRINT macro when parser debugging is
enabled. It prints a token's value. */
}
}
+#endif
+
void
yyerror (char *msg)
{