1 /* Helper routines for C++ support in GDB.
2 Copyright (C) 2003-2013 Free Software Foundation, Inc.
4 Contributed by David Carlton and by Kealia, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include "cp-support.h"
23 #include "gdb_obstack.h"
26 #include "gdb_assert.h"
30 #include "dictionary.h"
36 static struct symbol
*lookup_namespace_scope (const char *name
,
37 const struct block
*block
,
38 const domain_enum domain
,
42 static struct symbol
*lookup_symbol_file (const char *name
,
43 const struct block
*block
,
44 const domain_enum domain
,
45 int anonymous_namespace
,
48 static struct type
*cp_lookup_transparent_type_loop (const char *name
,
52 /* Check to see if SYMBOL refers to an object contained within an
53 anonymous namespace; if so, add an appropriate using directive. */
56 cp_scan_for_anonymous_namespaces (const struct symbol
*const symbol
,
57 struct objfile
*const objfile
)
59 if (SYMBOL_DEMANGLED_NAME (symbol
) != NULL
)
61 const char *name
= SYMBOL_DEMANGLED_NAME (symbol
);
62 unsigned int previous_component
;
63 unsigned int next_component
;
65 /* Start with a quick-and-dirty check for mention of "(anonymous
68 if (!cp_is_anonymous (name
))
71 previous_component
= 0;
72 next_component
= cp_find_first_component (name
+ previous_component
);
74 while (name
[next_component
] == ':')
76 if (((next_component
- previous_component
)
77 == CP_ANONYMOUS_NAMESPACE_LEN
)
78 && strncmp (name
+ previous_component
,
79 CP_ANONYMOUS_NAMESPACE_STR
,
80 CP_ANONYMOUS_NAMESPACE_LEN
) == 0)
82 int dest_len
= (previous_component
== 0
83 ? 0 : previous_component
- 2);
84 int src_len
= next_component
;
86 char *dest
= alloca (dest_len
+ 1);
87 char *src
= alloca (src_len
+ 1);
89 memcpy (dest
, name
, dest_len
);
90 memcpy (src
, name
, src_len
);
92 dest
[dest_len
] = '\0';
95 /* We've found a component of the name that's an
96 anonymous namespace. So add symbols in it to the
97 namespace given by the previous component if there is
98 one, or to the global namespace if there isn't. */
99 cp_add_using_directive (dest
, src
, NULL
, NULL
, NULL
,
100 &objfile
->objfile_obstack
);
102 /* The "+ 2" is for the "::". */
103 previous_component
= next_component
+ 2;
104 next_component
= (previous_component
105 + cp_find_first_component (name
106 + previous_component
));
112 /* Add a using directive to using_directives. If the using directive
113 in question has already been added, don't add it twice.
115 Create a new struct using_direct which imports the namespace SRC
116 into the scope DEST. ALIAS is the name of the imported namespace
117 in the current scope. If ALIAS is NULL then the namespace is known
118 by its original name. DECLARATION is the name if the imported
119 varable if this is a declaration import (Eg. using A::x), otherwise
120 it is NULL. EXCLUDES is a list of names not to import from an imported
121 module or NULL. The arguments are copied into newly allocated memory so
122 they can be temporaries. For EXCLUDES the VEC pointers are copied but the
123 pointed to characters are not copied. */
126 cp_add_using_directive (const char *dest
,
129 const char *declaration
,
130 VEC (const_char_ptr
) *excludes
,
131 struct obstack
*obstack
)
133 struct using_direct
*current
;
134 struct using_direct
*new;
136 /* Has it already been added? */
138 for (current
= using_directives
; current
!= NULL
; current
= current
->next
)
143 if (strcmp (current
->import_src
, src
) != 0)
145 if (strcmp (current
->import_dest
, dest
) != 0)
147 if ((alias
== NULL
&& current
->alias
!= NULL
)
148 || (alias
!= NULL
&& current
->alias
== NULL
)
149 || (alias
!= NULL
&& current
->alias
!= NULL
150 && strcmp (alias
, current
->alias
) != 0))
152 if ((declaration
== NULL
&& current
->declaration
!= NULL
)
153 || (declaration
!= NULL
&& current
->declaration
== NULL
)
154 || (declaration
!= NULL
&& current
->declaration
!= NULL
155 && strcmp (declaration
, current
->declaration
) != 0))
158 /* Compare the contents of EXCLUDES. */
159 for (ix
= 0; VEC_iterate (const_char_ptr
, excludes
, ix
, param
); ix
++)
160 if (current
->excludes
[ix
] == NULL
161 || strcmp (param
, current
->excludes
[ix
]) != 0)
163 if (ix
< VEC_length (const_char_ptr
, excludes
)
164 || current
->excludes
[ix
] != NULL
)
167 /* Parameters exactly match CURRENT. */
171 new = obstack_alloc (obstack
, (sizeof (*new)
172 + (VEC_length (const_char_ptr
, excludes
)
173 * sizeof (*new->excludes
))));
174 memset (new, 0, sizeof (*new));
176 new->import_src
= obstack_copy0 (obstack
, src
, strlen (src
));
177 new->import_dest
= obstack_copy0 (obstack
, dest
, strlen (dest
));
180 new->alias
= obstack_copy0 (obstack
, alias
, strlen (alias
));
182 if (declaration
!= NULL
)
183 new->declaration
= obstack_copy0 (obstack
,
184 declaration
, strlen (declaration
));
186 memcpy (new->excludes
, VEC_address (const_char_ptr
, excludes
),
187 VEC_length (const_char_ptr
, excludes
) * sizeof (*new->excludes
));
188 new->excludes
[VEC_length (const_char_ptr
, excludes
)] = NULL
;
190 new->next
= using_directives
;
191 using_directives
= new;
194 /* Record the namespace that the function defined by SYMBOL was
195 defined in, if necessary. BLOCK is the associated block; use
196 OBSTACK for allocation. */
199 cp_set_block_scope (const struct symbol
*symbol
,
201 struct obstack
*obstack
,
202 const char *processing_current_prefix
,
203 int processing_has_namespace_info
)
205 if (processing_has_namespace_info
)
208 (block
, obstack_copy0 (obstack
, processing_current_prefix
,
209 strlen (processing_current_prefix
)),
212 else if (SYMBOL_DEMANGLED_NAME (symbol
) != NULL
)
214 /* Try to figure out the appropriate namespace from the
217 /* FIXME: carlton/2003-04-15: If the function in question is
218 a method of a class, the name will actually include the
219 name of the class as well. This should be harmless, but
220 is a little unfortunate. */
222 const char *name
= SYMBOL_DEMANGLED_NAME (symbol
);
223 unsigned int prefix_len
= cp_entire_prefix_len (name
);
225 block_set_scope (block
,
226 obstack_copy0 (obstack
, name
, prefix_len
),
231 /* Test whether or not NAMESPACE looks like it mentions an anonymous
232 namespace; return nonzero if so. */
235 cp_is_anonymous (const char *namespace)
237 return (strstr (namespace, CP_ANONYMOUS_NAMESPACE_STR
)
241 /* The C++-specific version of name lookup for static and global
242 names. This makes sure that names get looked for in all namespaces
243 that are in scope. NAME is the natural name of the symbol that
244 we're looking for, BLOCK is the block that we're searching within,
245 DOMAIN says what kind of symbols we're looking for, and if SYMTAB
246 is non-NULL, we should store the symtab where we found the symbol
250 cp_lookup_symbol_nonlocal (const char *name
,
251 const struct block
*block
,
252 const domain_enum domain
)
255 const char *scope
= block_scope (block
);
257 sym
= lookup_namespace_scope (name
, block
,
262 return cp_lookup_symbol_namespace (scope
, name
,
266 /* Look up NAME in the C++ namespace NAMESPACE. Other arguments are
267 as in cp_lookup_symbol_nonlocal. If SEARCH is non-zero, search
268 through base classes for a matching symbol. */
270 static struct symbol
*
271 cp_lookup_symbol_in_namespace (const char *namespace,
273 const struct block
*block
,
274 const domain_enum domain
, int search
)
276 if (namespace[0] == '\0')
278 return lookup_symbol_file (name
, block
, domain
, 0, search
);
282 char *concatenated_name
= alloca (strlen (namespace) + 2
283 + strlen (name
) + 1);
285 strcpy (concatenated_name
, namespace);
286 strcat (concatenated_name
, "::");
287 strcat (concatenated_name
, name
);
288 return lookup_symbol_file (concatenated_name
, block
, domain
,
289 cp_is_anonymous (namespace), search
);
293 /* Used for cleanups to reset the "searched" flag incase
297 reset_directive_searched (void *data
)
299 struct using_direct
*direct
= data
;
300 direct
->searched
= 0;
303 /* Search for NAME by applying all import statements belonging to
304 BLOCK which are applicable in SCOPE. If DECLARATION_ONLY the
305 search is restricted to using declarations.
313 If SEARCH_PARENTS the search will include imports which are
314 applicable in parents of SCOPE.
324 If SCOPE is "A::B" and SEARCH_PARENTS is true the imports of
325 namespaces X and Y will be considered. If SEARCH_PARENTS is false
326 only the import of Y is considered. */
329 cp_lookup_symbol_imports (const char *scope
,
331 const struct block
*block
,
332 const domain_enum domain
,
333 const int declaration_only
,
334 const int search_parents
)
336 struct using_direct
*current
;
337 struct symbol
*sym
= NULL
;
340 struct cleanup
*searched_cleanup
;
342 /* First, try to find the symbol in the given namespace. */
343 if (!declaration_only
)
344 sym
= cp_lookup_symbol_in_namespace (scope
, name
,
350 /* Go through the using directives. If any of them add new names to
351 the namespace we're searching in, see if we can find a match by
354 for (current
= block_using (block
);
356 current
= current
->next
)
358 const char **excludep
;
360 len
= strlen (current
->import_dest
);
361 directive_match
= (search_parents
362 ? (strncmp (scope
, current
->import_dest
,
363 strlen (current
->import_dest
)) == 0
366 || scope
[len
] == '\0'))
367 : strcmp (scope
, current
->import_dest
) == 0);
369 /* If the import destination is the current scope or one of its
370 ancestors then it is applicable. */
371 if (directive_match
&& !current
->searched
)
373 /* Mark this import as searched so that the recursive call
374 does not search it again. */
375 current
->searched
= 1;
376 searched_cleanup
= make_cleanup (reset_directive_searched
,
379 /* If there is an import of a single declaration, compare the
380 imported declaration (after optional renaming by its alias)
381 with the sought out name. If there is a match pass
382 current->import_src as NAMESPACE to direct the search
383 towards the imported namespace. */
384 if (current
->declaration
385 && strcmp (name
, current
->alias
386 ? current
->alias
: current
->declaration
) == 0)
387 sym
= cp_lookup_symbol_in_namespace (current
->import_src
,
388 current
->declaration
,
391 /* If this is a DECLARATION_ONLY search or a symbol was found
392 or this import statement was an import declaration, the
393 search of this import is complete. */
394 if (declaration_only
|| sym
!= NULL
|| current
->declaration
)
396 current
->searched
= 0;
397 discard_cleanups (searched_cleanup
);
405 /* Do not follow CURRENT if NAME matches its EXCLUDES. */
406 for (excludep
= current
->excludes
; *excludep
; excludep
++)
407 if (strcmp (name
, *excludep
) == 0)
411 discard_cleanups (searched_cleanup
);
415 if (current
->alias
!= NULL
416 && strcmp (name
, current
->alias
) == 0)
417 /* If the import is creating an alias and the alias matches
418 the sought name. Pass current->import_src as the NAME to
419 direct the search towards the aliased namespace. */
421 sym
= cp_lookup_symbol_in_namespace (scope
,
425 else if (current
->alias
== NULL
)
427 /* If this import statement creates no alias, pass
428 current->inner as NAMESPACE to direct the search
429 towards the imported namespace. */
430 sym
= cp_lookup_symbol_imports (current
->import_src
,
434 current
->searched
= 0;
435 discard_cleanups (searched_cleanup
);
445 /* Helper function that searches an array of symbols for one named
448 static struct symbol
*
449 search_symbol_list (const char *name
, int num
,
450 struct symbol
**syms
)
454 /* Maybe we should store a dictionary in here instead. */
455 for (i
= 0; i
< num
; ++i
)
457 if (strcmp (name
, SYMBOL_NATURAL_NAME (syms
[i
])) == 0)
463 /* Like cp_lookup_symbol_imports, but if BLOCK is a function, it
464 searches through the template parameters of the function and the
468 cp_lookup_symbol_imports_or_template (const char *scope
,
470 const struct block
*block
,
471 const domain_enum domain
)
473 struct symbol
*function
= BLOCK_FUNCTION (block
);
475 if (function
!= NULL
&& SYMBOL_LANGUAGE (function
) == language_cplus
)
478 struct cplus_specific
*cps
479 = function
->ginfo
.language_specific
.cplus_specific
;
481 /* Search the function's template parameters. */
482 if (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (function
))
484 struct template_symbol
*templ
485 = (struct template_symbol
*) function
;
486 struct symbol
*result
;
488 result
= search_symbol_list (name
,
489 templ
->n_template_arguments
,
490 templ
->template_arguments
);
495 /* Search the template parameters of the function's defining
497 if (SYMBOL_NATURAL_NAME (function
))
499 struct type
*context
;
500 char *name_copy
= xstrdup (SYMBOL_NATURAL_NAME (function
));
501 struct cleanup
*cleanups
= make_cleanup (xfree
, name_copy
);
502 const struct language_defn
*lang
= language_def (language_cplus
);
503 struct gdbarch
*arch
= SYMBOL_SYMTAB (function
)->objfile
->gdbarch
;
504 const struct block
*parent
= BLOCK_SUPERBLOCK (block
);
508 struct symbol
*result
;
509 unsigned int prefix_len
= cp_entire_prefix_len (name_copy
);
515 name_copy
[prefix_len
] = '\0';
516 context
= lookup_typename (lang
, arch
,
525 = search_symbol_list (name
,
526 TYPE_N_TEMPLATE_ARGUMENTS (context
),
527 TYPE_TEMPLATE_ARGUMENTS (context
));
532 do_cleanups (cleanups
);
536 return cp_lookup_symbol_imports (scope
, name
, block
, domain
, 1, 1);
539 /* Searches for NAME in the current namespace, and by applying
540 relevant import statements belonging to BLOCK and its parents.
541 SCOPE is the namespace scope of the context in which the search is
545 cp_lookup_symbol_namespace (const char *scope
,
547 const struct block
*block
,
548 const domain_enum domain
)
552 /* First, try to find the symbol in the given namespace. */
553 sym
= cp_lookup_symbol_in_namespace (scope
, name
,
558 /* Search for name in namespaces imported to this and parent
560 while (block
!= NULL
)
562 sym
= cp_lookup_symbol_imports (scope
, name
, block
,
568 block
= BLOCK_SUPERBLOCK (block
);
574 /* Lookup NAME at namespace scope (or, in C terms, in static and
575 global variables). SCOPE is the namespace that the current
576 function is defined within; only consider namespaces whose length
577 is at least SCOPE_LEN. Other arguments are as in
578 cp_lookup_symbol_nonlocal.
580 For example, if we're within a function A::B::f and looking for a
581 symbol x, this will get called with NAME = "x", SCOPE = "A::B", and
582 SCOPE_LEN = 0. It then calls itself with NAME and SCOPE the same,
583 but with SCOPE_LEN = 1. And then it calls itself with NAME and
584 SCOPE the same, but with SCOPE_LEN = 4. This third call looks for
585 "A::B::x"; if it doesn't find it, then the second call looks for
586 "A::x", and if that call fails, then the first call looks for
589 static struct symbol
*
590 lookup_namespace_scope (const char *name
,
591 const struct block
*block
,
592 const domain_enum domain
,
598 if (scope
[scope_len
] != '\0')
600 /* Recursively search for names in child namespaces first. */
603 int new_scope_len
= scope_len
;
605 /* If the current scope is followed by "::", skip past that. */
606 if (new_scope_len
!= 0)
608 gdb_assert (scope
[new_scope_len
] == ':');
611 new_scope_len
+= cp_find_first_component (scope
+ new_scope_len
);
612 sym
= lookup_namespace_scope (name
, block
, domain
,
613 scope
, new_scope_len
);
618 /* Okay, we didn't find a match in our children, so look for the
619 name in the current namespace. */
621 namespace = alloca (scope_len
+ 1);
622 strncpy (namespace, scope
, scope_len
);
623 namespace[scope_len
] = '\0';
624 return cp_lookup_symbol_in_namespace (namespace, name
,
628 /* Look up NAME in BLOCK's static block and in global blocks. If
629 ANONYMOUS_NAMESPACE is nonzero, the symbol in question is located
630 within an anonymous namespace. If SEARCH is non-zero, search through
631 base classes for a matching symbol. Other arguments are as in
632 cp_lookup_symbol_nonlocal. */
634 static struct symbol
*
635 lookup_symbol_file (const char *name
,
636 const struct block
*block
,
637 const domain_enum domain
,
638 int anonymous_namespace
, int search
)
640 struct symbol
*sym
= NULL
;
642 sym
= lookup_symbol_static (name
, block
, domain
);
646 if (anonymous_namespace
)
648 /* Symbols defined in anonymous namespaces have external linkage
649 but should be treated as local to a single file nonetheless.
650 So we only search the current file's global block. */
652 const struct block
*global_block
= block_global_block (block
);
654 if (global_block
!= NULL
)
655 sym
= lookup_symbol_aux_block (name
, global_block
, domain
);
659 sym
= lookup_symbol_global (name
, block
, domain
);
667 char *klass
, *nested
;
668 unsigned int prefix_len
;
669 struct cleanup
*cleanup
;
670 struct symbol
*klass_sym
;
672 /* A simple lookup failed. Check if the symbol was defined in
675 cleanup
= make_cleanup (null_cleanup
, NULL
);
677 /* Find the name of the class and the name of the method,
679 prefix_len
= cp_entire_prefix_len (name
);
681 /* If no prefix was found, search "this". */
687 this = lookup_language_this (language_def (language_cplus
), block
);
690 do_cleanups (cleanup
);
694 type
= check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
695 klass
= xstrdup (TYPE_NAME (type
));
696 nested
= xstrdup (name
);
700 /* The class name is everything up to and including PREFIX_LEN. */
701 klass
= savestring (name
, prefix_len
);
703 /* The rest of the name is everything else past the initial scope
705 nested
= xstrdup (name
+ prefix_len
+ 2);
708 /* Add cleanups to free memory for these strings. */
709 make_cleanup (xfree
, klass
);
710 make_cleanup (xfree
, nested
);
712 /* Lookup a class named KLASS. If none is found, there is nothing
713 more that can be done. */
714 klass_sym
= lookup_symbol_global (klass
, block
, domain
);
715 if (klass_sym
== NULL
)
717 do_cleanups (cleanup
);
721 /* Look for a symbol named NESTED in this class. */
722 sym
= cp_lookup_nested_symbol (SYMBOL_TYPE (klass_sym
), nested
, block
);
723 do_cleanups (cleanup
);
729 /* Search through the base classes of PARENT_TYPE for a symbol named
730 NAME in block BLOCK. */
732 static struct symbol
*
733 find_symbol_in_baseclass (struct type
*parent_type
, const char *name
,
734 const struct block
*block
)
738 struct cleanup
*cleanup
;
739 char *concatenated_name
;
742 concatenated_name
= NULL
;
743 cleanup
= make_cleanup (free_current_contents
, &concatenated_name
);
744 for (i
= 0; i
< TYPE_N_BASECLASSES (parent_type
); ++i
)
747 const char *base_name
= TYPE_BASECLASS_NAME (parent_type
, i
);
749 if (base_name
== NULL
)
752 /* Search this particular base class. */
753 sym
= cp_lookup_symbol_namespace (base_name
, name
, block
, VAR_DOMAIN
);
757 len
= strlen (base_name
) + 2 + strlen (name
) + 1;
758 concatenated_name
= xrealloc (concatenated_name
, len
);
759 xsnprintf (concatenated_name
, len
, "%s::%s", base_name
, name
);
760 sym
= lookup_symbol_static (concatenated_name
, block
, VAR_DOMAIN
);
762 /* If there is currently no BLOCK, e.g., the inferior hasn't yet
763 been started, then try searching all STATIC_BLOCK symbols in
767 sym
= lookup_static_symbol_aux (concatenated_name
, VAR_DOMAIN
);
772 /* If this class has base classes, search them next. */
773 if (TYPE_N_BASECLASSES (TYPE_BASECLASS (parent_type
, i
)) > 0)
775 sym
= find_symbol_in_baseclass (TYPE_BASECLASS (parent_type
, i
),
782 do_cleanups (cleanup
);
786 /* Look up a symbol named NESTED_NAME that is nested inside the C++
787 class or namespace given by PARENT_TYPE, from within the context
788 given by BLOCK. Return NULL if there is no such nested type. */
791 cp_lookup_nested_symbol (struct type
*parent_type
,
792 const char *nested_name
,
793 const struct block
*block
)
795 /* type_name_no_tag_required provides better error reporting using the
797 struct type
*saved_parent_type
= parent_type
;
799 CHECK_TYPEDEF (parent_type
);
801 switch (TYPE_CODE (parent_type
))
803 case TYPE_CODE_STRUCT
:
804 case TYPE_CODE_NAMESPACE
:
805 case TYPE_CODE_UNION
:
807 /* NOTE: carlton/2003-11-10: We don't treat C++ class members
808 of classes like, say, data or function members. Instead,
809 they're just represented by symbols whose names are
810 qualified by the name of the surrounding class. This is
811 just like members of namespaces; in particular,
812 lookup_symbol_namespace works when looking them up. */
815 const char *parent_name
= type_name_no_tag_or_error (saved_parent_type
);
817 = cp_lookup_symbol_in_namespace (parent_name
, nested_name
,
818 block
, VAR_DOMAIN
, 0);
819 char *concatenated_name
;
824 /* Now search all static file-level symbols. Not strictly
825 correct, but more useful than an error. We do not try to
826 guess any imported namespace as even the fully specified
827 namespace search is already not C++ compliant and more
828 assumptions could make it too magic. */
830 size
= strlen (parent_name
) + 2 + strlen (nested_name
) + 1;
831 concatenated_name
= alloca (size
);
832 xsnprintf (concatenated_name
, size
, "%s::%s",
833 parent_name
, nested_name
);
834 sym
= lookup_static_symbol_aux (concatenated_name
, VAR_DOMAIN
);
838 /* If no matching symbols were found, try searching any
840 return find_symbol_in_baseclass (parent_type
, nested_name
, block
);
843 internal_error (__FILE__
, __LINE__
,
844 _("cp_lookup_nested_symbol called "
845 "on a non-aggregate type."));
849 /* The C++-version of lookup_transparent_type. */
851 /* FIXME: carlton/2004-01-16: The problem that this is trying to
852 address is that, unfortunately, sometimes NAME is wrong: it may not
853 include the name of namespaces enclosing the type in question.
854 lookup_transparent_type gets called when the type in question
855 is a declaration, and we're trying to find its definition; but, for
856 declarations, our type name deduction mechanism doesn't work.
857 There's nothing we can do to fix this in general, I think, in the
858 absence of debug information about namespaces (I've filed PR
859 gdb/1511 about this); until such debug information becomes more
860 prevalent, one heuristic which sometimes looks is to search for the
861 definition in namespaces containing the current namespace.
863 We should delete this functions once the appropriate debug
864 information becomes more widespread. (GCC 3.4 will be the first
865 released version of GCC with such information.) */
868 cp_lookup_transparent_type (const char *name
)
870 /* First, try the honest way of looking up the definition. */
871 struct type
*t
= basic_lookup_transparent_type (name
);
877 /* If that doesn't work and we're within a namespace, look there
879 scope
= block_scope (get_selected_block (0));
881 if (scope
[0] == '\0')
884 return cp_lookup_transparent_type_loop (name
, scope
, 0);
887 /* Lookup the type definition associated to NAME in namespaces/classes
888 containing SCOPE whose name is strictly longer than LENGTH. LENGTH
889 must be the index of the start of a component of SCOPE. */
892 cp_lookup_transparent_type_loop (const char *name
,
896 int scope_length
= length
+ cp_find_first_component (scope
+ length
);
899 /* If the current scope is followed by "::", look in the next
901 if (scope
[scope_length
] == ':')
904 = cp_lookup_transparent_type_loop (name
, scope
,
911 full_name
= alloca (scope_length
+ 2 + strlen (name
) + 1);
912 strncpy (full_name
, scope
, scope_length
);
913 strncpy (full_name
+ scope_length
, "::", 2);
914 strcpy (full_name
+ scope_length
+ 2, name
);
916 return basic_lookup_transparent_type (full_name
);
919 /* This used to do something but was removed when it became
923 maintenance_cplus_namespace (char *args
, int from_tty
)
925 printf_unfiltered (_("The `maint namespace' command was removed.\n"));
928 /* Provide a prototype to silence -Wmissing-prototypes. */
929 extern initialize_file_ftype _initialize_cp_namespace
;
932 _initialize_cp_namespace (void)
934 struct cmd_list_element
*cmd
;
936 cmd
= add_cmd ("namespace", class_maintenance
,
937 maintenance_cplus_namespace
,
938 _("Deprecated placeholder for removed functionality."),
939 &maint_cplus_cmd_list
);
940 deprecate_cmd (cmd
, NULL
);