* gdb.base/gdb1555.exp: New file.
[deliverable/binutils-gdb.git] / gdb / c-exp.y
index 7630da4a17daded26a1f49088d62a0a71703fda8..f11b93e3a2b434e2a0043ff097438d85aa3728e3 100644 (file)
@@ -1,6 +1,6 @@
 /* YACC parser for C expressions, for GDB.
    Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2003
+   1998, 1999, 2000, 2003, 2004
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -939,11 +939,6 @@ typebase  /* Implements (approximately): (type-qualifier)* type-specifier */
    decode_line_1), but I'm not holding my breath waiting for somebody
    to get around to cleaning this up...  */
 
-/* FIXME: carlton/2003-09-25: Currently, the only qualified type
-   symbols that we generate are nested namespaces.  Next on my TODO
-   list is to generate all nested type names properly (or at least as
-   well as possible, assuming that we're using DWARF-2).  */
-
 qualified_type: typebase COLONCOLON name
                {
                  struct type *type = $1;
@@ -953,14 +948,16 @@ qualified_type: typebase COLONCOLON name
                  memcpy (ncopy, $3.ptr, $3.length);
                  ncopy[$3.length] = '\0';
 
-                 if (TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
-                   error ("`%s' is not defined as a namespace.",
+                 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.",
                           TYPE_NAME (type));
 
                  new_type = cp_lookup_nested_type (type, ncopy,
                                                    expression_context_block);
                  if (new_type == NULL)
-                   error ("No type \"%s\" in namespace \"%s\".",
+                   error ("No type \"%s\" within class or namespace \"%s\".",
                           ncopy, TYPE_NAME (type));
                  
                  $$ = new_type;
@@ -1340,7 +1337,7 @@ yylex ()
   tokstart = lexptr;
   /* See if it is a special token of length 3.  */
   for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
-    if (STREQN (tokstart, tokentab3[i].operator, 3))
+    if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
       {
        lexptr += 3;
        yylval.opcode = tokentab3[i].opcode;
@@ -1349,7 +1346,7 @@ yylex ()
 
   /* See if it is a special token of length 2.  */
   for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
-    if (STREQN (tokstart, tokentab2[i].operator, 2))
+    if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
       {
        lexptr += 2;
        yylval.opcode = tokentab2[i].opcode;
@@ -1645,52 +1642,52 @@ yylex ()
   switch (namelen)
     {
     case 8:
-      if (STREQN (tokstart, "unsigned", 8))
+      if (strncmp (tokstart, "unsigned", 8) == 0)
        return UNSIGNED;
       if (current_language->la_language == language_cplus
-         && STREQN (tokstart, "template", 8))
+         && strncmp (tokstart, "template", 8) == 0)
        return TEMPLATE;
-      if (STREQN (tokstart, "volatile", 8))
+      if (strncmp (tokstart, "volatile", 8) == 0)
        return VOLATILE_KEYWORD;
       break;
     case 6:
-      if (STREQN (tokstart, "struct", 6))
+      if (strncmp (tokstart, "struct", 6) == 0)
        return STRUCT;
-      if (STREQN (tokstart, "signed", 6))
+      if (strncmp (tokstart, "signed", 6) == 0)
        return SIGNED_KEYWORD;
-      if (STREQN (tokstart, "sizeof", 6))      
+      if (strncmp (tokstart, "sizeof", 6) == 0)
        return SIZEOF;
-      if (STREQN (tokstart, "double", 6))      
+      if (strncmp (tokstart, "double", 6) == 0)
        return DOUBLE_KEYWORD;
       break;
     case 5:
       if (current_language->la_language == language_cplus)
         {
-          if (STREQN (tokstart, "false", 5))
+          if (strncmp (tokstart, "false", 5) == 0)
             return FALSEKEYWORD;
-          if (STREQN (tokstart, "class", 5))
+          if (strncmp (tokstart, "class", 5) == 0)
             return CLASS;
         }
-      if (STREQN (tokstart, "union", 5))
+      if (strncmp (tokstart, "union", 5) == 0)
        return UNION;
-      if (STREQN (tokstart, "short", 5))
+      if (strncmp (tokstart, "short", 5) == 0)
        return SHORT;
-      if (STREQN (tokstart, "const", 5))
+      if (strncmp (tokstart, "const", 5) == 0)
        return CONST_KEYWORD;
       break;
     case 4:
-      if (STREQN (tokstart, "enum", 4))
+      if (strncmp (tokstart, "enum", 4) == 0)
        return ENUM;
-      if (STREQN (tokstart, "long", 4))
+      if (strncmp (tokstart, "long", 4) == 0)
        return LONG;
       if (current_language->la_language == language_cplus)
           {
-            if (STREQN (tokstart, "true", 4))
+            if (strncmp (tokstart, "true", 4) == 0)
               return TRUEKEYWORD;
           }
       break;
     case 3:
-      if (STREQN (tokstart, "int", 3))
+      if (strncmp (tokstart, "int", 3) == 0)
        return INT_KEYWORD;
       break;
     default:
This page took 0.032028 seconds and 4 git commands to generate.