PR ld/12152
[deliverable/binutils-gdb.git] / gdb / c-exp.y
index 5b6ef3eaa101daf7651b74a79e3a7a16b893fc18..bf4f4bc1a773bad3ca6b0861bd657c3fe78e2605 100644 (file)
@@ -1,7 +1,6 @@
 /* YACC parser for C expressions, for GDB.
-   Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 1986, 1989-2000, 2003-2004, 2006-2012 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -208,6 +207,7 @@ static struct stoken operator_stoken (const char *);
 %token NEW DELETE
 %type <sval> operator
 %token REINTERPRET_CAST DYNAMIC_CAST STATIC_CAST CONST_CAST
+%token ENTRY
 
 /* Special type cases, put in to allow the parser to distinguish different
    legal basetypes.  */
@@ -698,7 +698,7 @@ exp :       string_exp
                                case C_STRING_32:
                                  if (type != C_STRING
                                      && type != $1.tokens[i].type)
-                                   error ("Undefined string concatenation.");
+                                   error (_("Undefined string concatenation."));
                                  type = $1.tokens[i].type;
                                  break;
                                default:
@@ -737,7 +737,7 @@ block       :       BLOCKNAME
                          if ($1.sym)
                            $$ = SYMBOL_BLOCK_VALUE ($1.sym);
                          else
-                           error ("No file or function \"%s\".",
+                           error (_("No file or function \"%s\"."),
                                   copy_name ($1.stoken));
                        }
        |       FILENAME
@@ -751,18 +751,40 @@ block     :       block COLONCOLON name
                            = lookup_symbol (copy_name ($3), $1,
                                             VAR_DOMAIN, (int *) NULL);
                          if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
-                           error ("No function \"%s\" in specified context.",
+                           error (_("No function \"%s\" in specified context."),
                                   copy_name ($3));
                          $$ = SYMBOL_BLOCK_VALUE (tem); }
        ;
 
+variable:      name_not_typename ENTRY
+                       { struct symbol *sym = $1.sym;
+
+                         if (sym == NULL || !SYMBOL_IS_ARGUMENT (sym)
+                             || !symbol_read_needs_frame (sym))
+                           error (_("@entry can be used only for function "
+                                    "parameters, not for \"%s\""),
+                                  copy_name ($1.stoken));
+
+                         write_exp_elt_opcode (OP_VAR_ENTRY_VALUE);
+                         write_exp_elt_sym (sym);
+                         write_exp_elt_opcode (OP_VAR_ENTRY_VALUE);
+                       }
+       ;
+
 variable:      block COLONCOLON name
                        { struct symbol *sym;
                          sym = lookup_symbol (copy_name ($3), $1,
                                               VAR_DOMAIN, (int *) NULL);
                          if (sym == 0)
-                           error ("No symbol \"%s\" in specified context.",
+                           error (_("No symbol \"%s\" in specified context."),
                                   copy_name ($3));
+                         if (symbol_read_needs_frame (sym))
+                           {
+                             if (innermost_block == 0
+                                 || contained_in (block_found,
+                                                  innermost_block))
+                               innermost_block = block_found;
+                           }
 
                          write_exp_elt_opcode (OP_VAR_VALUE);
                          /* block_found is set by lookup_symbol.  */
@@ -778,7 +800,7 @@ qualified_name:     TYPENAME COLONCOLON name
                          if (TYPE_CODE (type) != TYPE_CODE_STRUCT
                              && TYPE_CODE (type) != TYPE_CODE_UNION
                              && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
-                           error ("`%s' is not defined as an aggregate type.",
+                           error (_("`%s' is not defined as an aggregate type."),
                                   TYPE_NAME (type));
 
                          write_exp_elt_opcode (OP_SCOPE);
@@ -794,7 +816,7 @@ qualified_name:     TYPENAME COLONCOLON name
                          if (TYPE_CODE (type) != TYPE_CODE_STRUCT
                              && TYPE_CODE (type) != TYPE_CODE_UNION
                              && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
-                           error ("`%s' is not defined as an aggregate type.",
+                           error (_("`%s' is not defined as an aggregate type."),
                                   TYPE_NAME (type));
 
                          tmp_token.ptr = (char*) alloca ($4.length + 2);
@@ -804,7 +826,7 @@ qualified_name:     TYPENAME COLONCOLON name
                          tmp_token.ptr[tmp_token.length] = 0;
 
                          /* Check for valid destructor name.  */
-                         destructor_name_p (tmp_token.ptr, type);
+                         destructor_name_p (tmp_token.ptr, $1.type);
                          write_exp_elt_opcode (OP_SCOPE);
                          write_exp_elt_type (type);
                          write_exp_string (tmp_token);
@@ -842,9 +864,9 @@ variable:   qualified_name
                          if (msymbol != NULL)
                            write_exp_msymbol (msymbol);
                          else if (!have_full_symbols () && !have_partial_symbols ())
-                           error ("No symbol table is loaded.  Use the \"file\" command.");
+                           error (_("No symbol table is loaded.  Use the \"file\" command."));
                          else
-                           error ("No symbol \"%s\" in current context.", name);
+                           error (_("No symbol \"%s\" in current context."), name);
                        }
        ;
 
@@ -894,9 +916,9 @@ variable:   name_not_typename
                              if (msymbol != NULL)
                                write_exp_msymbol (msymbol);
                              else if (!have_full_symbols () && !have_partial_symbols ())
-                               error ("No symbol table is loaded.  Use the \"file\" command.");
+                               error (_("No symbol table is loaded.  Use the \"file\" command."));
                              else
-                               error ("No symbol \"%s\" in current context.",
+                               error (_("No symbol \"%s\" in current context."),
                                       copy_name ($1.stoken));
                            }
                        }
@@ -1196,11 +1218,11 @@ const_or_volatile_noopt:        const_and_volatile
 operator:      OPERATOR NEW
                        { $$ = operator_stoken (" new"); }
        |       OPERATOR DELETE
-                       { $$ = operator_stoken (" delete"); }
+                       { $$ = operator_stoken (" delete "); }
        |       OPERATOR NEW '[' ']'
                        { $$ = operator_stoken (" new[]"); }
        |       OPERATOR DELETE '[' ']'
-                       { $$ = operator_stoken (" delete[]"); }
+                       { $$ = operator_stoken (" delete[] "); }
        |       OPERATOR '+'
                        { $$ = operator_stoken ("+"); }
        |       OPERATOR '-'
@@ -1527,7 +1549,7 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
       if (c != 'l' && c != 'u' && n != 0)
        {       
          if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
-           error ("Numeric constant too large.");
+           error (_("Numeric constant too large."));
        }
       prevn = n;
     }
@@ -1844,9 +1866,9 @@ parse_string_or_char (char *tokptr, char **outptr, struct typed_stoken *value,
   if (*tokptr != quote)
     {
       if (quote == '"')
-       error ("Unterminated string in expression.");
+       error (_("Unterminated string in expression."));
       else
-       error ("Unmatched single quote.");
+       error (_("Unmatched single quote."));
     }
   ++tokptr;
 
@@ -2218,12 +2240,27 @@ lex_one_token (void)
 
            memcpy (err_copy, tokstart, p - tokstart);
            err_copy[p - tokstart] = 0;
-           error ("Invalid number \"%s\".", err_copy);
+           error (_("Invalid number \"%s\"."), err_copy);
          }
        lexptr = p;
        return toktype;
       }
 
+    case '@':
+      {
+       char *p = &tokstart[1];
+       size_t len = strlen ("entry");
+
+       while (isspace (*p))
+         p++;
+       if (strncmp (p, "entry", len) == 0 && !isalnum (p[len])
+           && p[len] != '_')
+         {
+           lexptr = &p[len];
+           return ENTRY;
+         }
+      }
+      /* FALLTHRU */
     case '+':
     case '-':
     case '*':
@@ -2234,7 +2271,6 @@ lex_one_token (void)
     case '^':
     case '~':
     case '!':
-    case '@':
     case '<':
     case '>':
     case '?':
@@ -2261,7 +2297,7 @@ lex_one_token (void)
        if (result == CHAR)
          {
            if (host_len == 0)
-             error ("Empty character constant.");
+             error (_("Empty character constant."));
            else if (host_len > 2 && c == '\'')
              {
                ++tokstart;
@@ -2269,7 +2305,7 @@ lex_one_token (void)
                goto tryname;
              }
            else if (host_len > 1)
-             error ("Invalid character constant.");
+             error (_("Invalid character constant."));
          }
        return result;
       }
@@ -2278,7 +2314,7 @@ lex_one_token (void)
   if (!(c == '_' || c == '$'
        || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
     /* We must have come across a bad character (e.g. ';').  */
-    error ("Invalid character '%c' in expression.", c);
+    error (_("Invalid character '%c' in expression."), c);
 
   /* It's a name.  See how long it is.  */
   namelen = 0;
@@ -2486,7 +2522,7 @@ classify_inner_name (struct block *block, int first_name)
     return NAME;
 
   copy = copy_name (yylval.tsym.stoken);
-  new_type = cp_lookup_nested_type (type, copy, block);
+  new_type = cp_lookup_nested_type (yylval.tsym.type, copy, block);
 
   if (new_type == NULL)
     /* We know the caller won't expect us to update yylval.  */
@@ -2658,5 +2694,5 @@ yyerror (char *msg)
   if (prev_lexptr)
     lexptr = prev_lexptr;
 
-  error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
+  error (_("A %s in expression, near `%s'."), (msg ? msg : "error"), lexptr);
 }
This page took 0.028633 seconds and 4 git commands to generate.