* breakpoint.c (update_watchpoint, _initialize_breakpoint): Remove
[binutils-gdb.git] / gdb / cp-namespace.c
index 43f9c9a6091870451e1967209328257ce82c577d..d0fdcbe44081e773a4370af98ce7b6d620a10685 100644 (file)
@@ -81,7 +81,6 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
       const char *name = SYMBOL_DEMANGLED_NAME (symbol);
       unsigned int previous_component;
       unsigned int next_component;
-      const char *len;
 
       /* Start with a quick-and-dirty check for mention of "(anonymous
         namespace)".  */
@@ -264,12 +263,13 @@ cp_lookup_symbol_in_namespace (const char *namespace,
   else
     {
       char *concatenated_name = alloca (strlen (namespace) + 2 +
-                                        strlen (name+ 1));
+                                        strlen (name) + 1);
+
       strcpy (concatenated_name, namespace);
       strcat (concatenated_name, "::");
       strcat (concatenated_name, name);
       return lookup_symbol_file (concatenated_name, block,
-                                domain,cp_is_anonymous (namespace));
+                                domain, cp_is_anonymous (namespace));
     }
 }
 
@@ -355,12 +355,14 @@ cp_lookup_symbol_imports (const char *scope,
        searched_cleanup = make_cleanup (reset_directive_searched, current);
 
        /* If there is an import of a single declaration, compare the imported
-          declaration with the sought out name.  If there is a match pass
-          current->import_src as NAMESPACE to direct the search towards the
-          imported namespace.  */
-       if (current->declaration && strcmp (name, current->declaration) == 0)
+          declaration (after optional renaming by its alias) with the sought
+          out name.  If there is a match pass current->import_src as NAMESPACE
+          to direct the search towards the imported namespace.  */
+       if (current->declaration
+           && strcmp (name, current->alias ? current->alias
+                                           : current->declaration) == 0)
          sym = cp_lookup_symbol_in_namespace (current->import_src,
-                                              name,
+                                              current->declaration,
                                               block,
                                               domain);
 
@@ -576,10 +578,24 @@ cp_lookup_nested_type (struct type *parent_type,
                                                            nested_name,
                                                            block,
                                                            VAR_DOMAIN);
-       if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF)
-         return NULL;
-       else
+       char *concatenated_name;
+
+       if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+         return SYMBOL_TYPE (sym);
+
+       /* Now search all static file-level symbols.  Not strictly correct,
+          but more useful than an error.  We do not try to guess any imported
+          namespace as even the fully specified namespace seach is is already
+          not C++ compliant and more assumptions could make it too magic.  */
+
+       concatenated_name = alloca (strlen (parent_name) + 2
+                                   + strlen (nested_name) + 1);
+       sprintf (concatenated_name, "%s::%s", parent_name, nested_name);
+       sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
+       if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
          return SYMBOL_TYPE (sym);
+
+       return NULL;
       }
     default:
       internal_error (__FILE__, __LINE__,
@@ -643,6 +659,7 @@ cp_lookup_transparent_type_loop (const char *name, const char *scope,
     {
       struct type *retval
        = cp_lookup_transparent_type_loop (name, scope, scope_length + 2);
+
       if (retval != NULL)
        return retval;
     }
@@ -875,6 +892,7 @@ static void
 maintenance_cplus_namespace (char *args, int from_tty)
 {
   struct objfile *objfile;
+
   printf_unfiltered (_("Possible namespaces:\n"));
   ALL_OBJFILES (objfile)
     {