C++: dlsym casts in gdb/linux-thread-db.c and gdb/gdbserver/thread-db.c
[deliverable/binutils-gdb.git] / gdb / cp-name-parser.y
index d85a5bf2b7907d6d463c7d6c3e5525594fa19312..b4690ea497bc90b8f03940abe0f1b481feaf42b1 100644 (file)
@@ -1,6 +1,6 @@
 /* YACC parser for C++ names, for GDB.
 
-   Copyright (C) 2003-2005, 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2003-2015 Free Software Foundation, Inc.
 
    Parts of the lexer are based on c-exp.y from GDB.
 
 
 #include "defs.h"
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <unistd.h>
-#include <string.h>
-
 #include "safe-ctype.h"
-#include "libiberty.h"
 #include "demangle.h"
 #include "cp-support.h"
-#include "gdb_assert.h"
 
 /* Bison does not make it easy to create a parser without global
    state, unfortunately.  Here are all the global variables used
@@ -170,6 +164,12 @@ static struct demangle_component *d_binary (const char *,
 #define yygindex cpname_yygindex
 #define yytable         cpname_yytable
 #define yycheck         cpname_yycheck
+#define yyss   cpname_yyss
+#define yysslim        cpname_yysslim
+#define yyssp  cpname_yyssp
+#define yystacksize cpname_yystacksize
+#define yyvs   cpname_yyvs
+#define yyvsp  cpname_yyvsp
 
 int yyparse (void);
 static int yylex (void);
@@ -277,9 +277,9 @@ make_name (const char *name, int len)
     const char *opname;
   }
 
-%type <comp> exp exp1 type start start_opt operator colon_name
+%type <comp> exp exp1 type start start_opt oper colon_name
 %type <comp> unqualified_name colon_ext_name
-%type <comp> template template_arg
+%type <comp> templ template_arg
 %type <comp> builtin_type
 %type <comp> typespec_2 array_indicator
 %type <comp> colon_ext_only ext_only_name
@@ -439,14 +439,30 @@ demangler_special
                        { $$ = fill_comp (DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, $2, $4); }
                ;
 
-operator       :       OPERATOR NEW
-                       { $$ = make_operator ("new", 3); }
+oper   :       OPERATOR NEW
+                       {
+                         /* Match the whitespacing of cplus_demangle_operators.
+                            It would abort on unrecognized string otherwise.  */
+                         $$ = make_operator ("new", 3);
+                       }
                |       OPERATOR DELETE
-                       { $$ = make_operator ("delete ", 1); }
+                       {
+                         /* Match the whitespacing of cplus_demangle_operators.
+                            It would abort on unrecognized string otherwise.  */
+                         $$ = make_operator ("delete ", 1);
+                       }
                |       OPERATOR NEW '[' ']'
-                       { $$ = make_operator ("new[]", 3); }
+                       {
+                         /* Match the whitespacing of cplus_demangle_operators.
+                            It would abort on unrecognized string otherwise.  */
+                         $$ = make_operator ("new[]", 3);
+                       }
                |       OPERATOR DELETE '[' ']'
-                       { $$ = make_operator ("delete[] ", 1); }
+                       {
+                         /* Match the whitespacing of cplus_demangle_operators.
+                            It would abort on unrecognized string otherwise.  */
+                         $$ = make_operator ("delete[] ", 1);
+                       }
                |       OPERATOR '+'
                        { $$ = make_operator ("+", 2); }
                |       OPERATOR '-'
@@ -538,8 +554,8 @@ conversion_op_name
 
 /* DEMANGLE_COMPONENT_NAME */
 /* This accepts certain invalid placements of '~'.  */
-unqualified_name:      operator
-               |       operator '<' template_params '>'
+unqualified_name:      oper
+               |       oper '<' template_params '>'
                        { $$ = fill_comp (DEMANGLE_COMPONENT_TEMPLATE, $1, $3.comp); }
                |       '~' NAME
                        { $$ = make_dtor (gnu_v3_complete_object_dtor, $2); }
@@ -563,9 +579,9 @@ colon_name  :       name
 name           :       nested_name NAME %prec NAME
                        { $$ = $1.comp; d_right ($1.last) = $2; }
                |       NAME %prec NAME
-               |       nested_name template %prec NAME
+               |       nested_name templ %prec NAME
                        { $$ = $1.comp; d_right ($1.last) = $2; }
-               |       template %prec NAME
+               |       templ %prec NAME
                ;
 
 colon_ext_name :       colon_name
@@ -595,13 +611,13 @@ nested_name       :       NAME COLONCOLON
                          d_left ($$.last) = $2;
                          d_right ($$.last) = NULL;
                        }
-               |       template COLONCOLON
+               |       templ COLONCOLON
                        { $$.comp = make_empty (DEMANGLE_COMPONENT_QUAL_NAME);
                          d_left ($$.comp) = $1;
                          d_right ($$.comp) = NULL;
                          $$.last = $$.comp;
                        }
-               |       nested_name template COLONCOLON
+               |       nested_name templ COLONCOLON
                        { $$.comp = $1.comp;
                          d_right ($1.last) = make_empty (DEMANGLE_COMPONENT_QUAL_NAME);
                          $$.last = d_right ($1.last);
@@ -612,7 +628,7 @@ nested_name :       NAME COLONCOLON
 
 /* DEMANGLE_COMPONENT_TEMPLATE */
 /* DEMANGLE_COMPONENT_TEMPLATE_ARGLIST */
-template       :       NAME '<' template_params '>'
+templ  :       NAME '<' template_params '>'
                        { $$ = fill_comp (DEMANGLE_COMPONENT_TEMPLATE, $1, $3.comp); }
                ;
 
@@ -1177,7 +1193,11 @@ exp      :       FLOAT
        ;
 
 exp    :       SIZEOF '(' type ')'     %prec UNARY
-               { $$ = d_unary ("sizeof", $3); }
+               {
+                 /* Match the whitespacing of cplus_demangle_operators.
+                    It would abort on unrecognized string otherwise.  */
+                 $$ = d_unary ("sizeof ", $3);
+               }
        ;
 
 /* C++.  */
This page took 0.026344 seconds and 4 git commands to generate.