1 /* Helper routines for C++ support in GDB.
2 Copyright (C) 2003-2004, 2007-2012 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
= obsavestring (src
, strlen (src
), obstack
);
177 new->import_dest
= obsavestring (dest
, strlen (dest
), obstack
);
180 new->alias
= obsavestring (alias
, strlen (alias
), obstack
);
182 if (declaration
!= NULL
)
183 new->declaration
= obsavestring (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
, obsavestring (processing_current_prefix
,
209 strlen (processing_current_prefix
),
213 else if (SYMBOL_DEMANGLED_NAME (symbol
) != NULL
)
215 /* Try to figure out the appropriate namespace from the
218 /* FIXME: carlton/2003-04-15: If the function in question is
219 a method of a class, the name will actually include the
220 name of the class as well. This should be harmless, but
221 is a little unfortunate. */
223 const char *name
= SYMBOL_DEMANGLED_NAME (symbol
);
224 unsigned int prefix_len
= cp_entire_prefix_len (name
);
226 block_set_scope (block
,
227 obsavestring (name
, prefix_len
, obstack
),
232 /* Test whether or not NAMESPACE looks like it mentions an anonymous
233 namespace; return nonzero if so. */
236 cp_is_anonymous (const char *namespace)
238 return (strstr (namespace, CP_ANONYMOUS_NAMESPACE_STR
)
242 /* The C++-specific version of name lookup for static and global
243 names. This makes sure that names get looked for in all namespaces
244 that are in scope. NAME is the natural name of the symbol that
245 we're looking for, BLOCK is the block that we're searching within,
246 DOMAIN says what kind of symbols we're looking for, and if SYMTAB
247 is non-NULL, we should store the symtab where we found the symbol
251 cp_lookup_symbol_nonlocal (const char *name
,
252 const struct block
*block
,
253 const domain_enum domain
)
256 const char *scope
= block_scope (block
);
258 sym
= lookup_namespace_scope (name
, block
,
263 return cp_lookup_symbol_namespace (scope
, name
,
267 /* Look up NAME in the C++ namespace NAMESPACE. Other arguments are
268 as in cp_lookup_symbol_nonlocal. If SEARCH is non-zero, search
269 through base classes for a matching symbol. */
271 static struct symbol
*
272 cp_lookup_symbol_in_namespace (const char *namespace,
274 const struct block
*block
,
275 const domain_enum domain
, int search
)
277 if (namespace[0] == '\0')
279 return lookup_symbol_file (name
, block
, domain
, 0, search
);
283 char *concatenated_name
= alloca (strlen (namespace) + 2
284 + strlen (name
) + 1);
286 strcpy (concatenated_name
, namespace);
287 strcat (concatenated_name
, "::");
288 strcat (concatenated_name
, name
);
289 return lookup_symbol_file (concatenated_name
, block
, domain
,
290 cp_is_anonymous (namespace), search
);
294 /* Used for cleanups to reset the "searched" flag incase
298 reset_directive_searched (void *data
)
300 struct using_direct
*direct
= data
;
301 direct
->searched
= 0;
304 /* Search for NAME by applying all import statements belonging to
305 BLOCK which are applicable in SCOPE. If DECLARATION_ONLY the
306 search is restricted to using declarations.
314 If SEARCH_PARENTS the search will include imports which are
315 applicable in parents of SCOPE.
325 If SCOPE is "A::B" and SEARCH_PARENTS is true the imports of
326 namespaces X and Y will be considered. If SEARCH_PARENTS is false
327 only the import of Y is considered. */
330 cp_lookup_symbol_imports (const char *scope
,
332 const struct block
*block
,
333 const domain_enum domain
,
334 const int declaration_only
,
335 const int search_parents
)
337 struct using_direct
*current
;
338 struct symbol
*sym
= NULL
;
341 struct cleanup
*searched_cleanup
;
343 /* First, try to find the symbol in the given namespace. */
344 if (!declaration_only
)
345 sym
= cp_lookup_symbol_in_namespace (scope
, name
,
351 /* Go through the using directives. If any of them add new names to
352 the namespace we're searching in, see if we can find a match by
355 for (current
= block_using (block
);
357 current
= current
->next
)
359 const char **excludep
;
361 len
= strlen (current
->import_dest
);
362 directive_match
= (search_parents
363 ? (strncmp (scope
, current
->import_dest
,
364 strlen (current
->import_dest
)) == 0
367 || scope
[len
] == '\0'))
368 : strcmp (scope
, current
->import_dest
) == 0);
370 /* If the import destination is the current scope or one of its
371 ancestors then it is applicable. */
372 if (directive_match
&& !current
->searched
)
374 /* Mark this import as searched so that the recursive call
375 does not search it again. */
376 current
->searched
= 1;
377 searched_cleanup
= make_cleanup (reset_directive_searched
,
380 /* If there is an import of a single declaration, compare the
381 imported declaration (after optional renaming by its alias)
382 with the sought out name. If there is a match pass
383 current->import_src as NAMESPACE to direct the search
384 towards the imported namespace. */
385 if (current
->declaration
386 && strcmp (name
, current
->alias
387 ? current
->alias
: current
->declaration
) == 0)
388 sym
= cp_lookup_symbol_in_namespace (current
->import_src
,
389 current
->declaration
,
392 /* If this is a DECLARATION_ONLY search or a symbol was found
393 or this import statement was an import declaration, the
394 search of this import is complete. */
395 if (declaration_only
|| sym
!= NULL
|| current
->declaration
)
397 current
->searched
= 0;
398 discard_cleanups (searched_cleanup
);
406 /* Do not follow CURRENT if NAME matches its EXCLUDES. */
407 for (excludep
= current
->excludes
; *excludep
; excludep
++)
408 if (strcmp (name
, *excludep
) == 0)
412 discard_cleanups (searched_cleanup
);
416 if (current
->alias
!= NULL
417 && strcmp (name
, current
->alias
) == 0)
418 /* If the import is creating an alias and the alias matches
419 the sought name. Pass current->import_src as the NAME to
420 direct the search towards the aliased namespace. */
422 sym
= cp_lookup_symbol_in_namespace (scope
,
426 else if (current
->alias
== NULL
)
428 /* If this import statement creates no alias, pass
429 current->inner as NAMESPACE to direct the search
430 towards the imported namespace. */
431 sym
= cp_lookup_symbol_imports (current
->import_src
,
435 current
->searched
= 0;
436 discard_cleanups (searched_cleanup
);
446 /* Helper function that searches an array of symbols for one named
449 static struct symbol
*
450 search_symbol_list (const char *name
, int num
,
451 struct symbol
**syms
)
455 /* Maybe we should store a dictionary in here instead. */
456 for (i
= 0; i
< num
; ++i
)
458 if (strcmp (name
, SYMBOL_NATURAL_NAME (syms
[i
])) == 0)
464 /* Like cp_lookup_symbol_imports, but if BLOCK is a function, it
465 searches through the template parameters of the function and the
469 cp_lookup_symbol_imports_or_template (const char *scope
,
471 const struct block
*block
,
472 const domain_enum domain
)
474 struct symbol
*function
= BLOCK_FUNCTION (block
);
476 if (function
!= NULL
&& SYMBOL_LANGUAGE (function
) == language_cplus
)
479 struct cplus_specific
*cps
480 = function
->ginfo
.language_specific
.cplus_specific
;
482 /* Search the function's template parameters. */
483 if (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (function
))
485 struct template_symbol
*templ
486 = (struct template_symbol
*) function
;
487 struct symbol
*result
;
489 result
= search_symbol_list (name
,
490 templ
->n_template_arguments
,
491 templ
->template_arguments
);
496 /* Search the template parameters of the function's defining
498 if (SYMBOL_NATURAL_NAME (function
))
500 struct type
*context
;
501 char *name_copy
= xstrdup (SYMBOL_NATURAL_NAME (function
));
502 struct cleanup
*cleanups
= make_cleanup (xfree
, name_copy
);
503 const struct language_defn
*lang
= language_def (language_cplus
);
504 struct gdbarch
*arch
= SYMBOL_SYMTAB (function
)->objfile
->gdbarch
;
505 const struct block
*parent
= BLOCK_SUPERBLOCK (block
);
509 struct symbol
*result
;
510 unsigned int prefix_len
= cp_entire_prefix_len (name_copy
);
516 name_copy
[prefix_len
] = '\0';
517 context
= lookup_typename (lang
, arch
,
526 = search_symbol_list (name
,
527 TYPE_N_TEMPLATE_ARGUMENTS (context
),
528 TYPE_TEMPLATE_ARGUMENTS (context
));
533 do_cleanups (cleanups
);
537 return cp_lookup_symbol_imports (scope
, name
, block
, domain
, 1, 1);
540 /* Searches for NAME in the current namespace, and by applying
541 relevant import statements belonging to BLOCK and its parents.
542 SCOPE is the namespace scope of the context in which the search is
546 cp_lookup_symbol_namespace (const char *scope
,
548 const struct block
*block
,
549 const domain_enum domain
)
553 /* First, try to find the symbol in the given namespace. */
554 sym
= cp_lookup_symbol_in_namespace (scope
, name
,
559 /* Search for name in namespaces imported to this and parent
561 while (block
!= NULL
)
563 sym
= cp_lookup_symbol_imports (scope
, name
, block
,
569 block
= BLOCK_SUPERBLOCK (block
);
575 /* Lookup NAME at namespace scope (or, in C terms, in static and
576 global variables). SCOPE is the namespace that the current
577 function is defined within; only consider namespaces whose length
578 is at least SCOPE_LEN. Other arguments are as in
579 cp_lookup_symbol_nonlocal.
581 For example, if we're within a function A::B::f and looking for a
582 symbol x, this will get called with NAME = "x", SCOPE = "A::B", and
583 SCOPE_LEN = 0. It then calls itself with NAME and SCOPE the same,
584 but with SCOPE_LEN = 1. And then it calls itself with NAME and
585 SCOPE the same, but with SCOPE_LEN = 4. This third call looks for
586 "A::B::x"; if it doesn't find it, then the second call looks for
587 "A::x", and if that call fails, then the first call looks for
590 static struct symbol
*
591 lookup_namespace_scope (const char *name
,
592 const struct block
*block
,
593 const domain_enum domain
,
599 if (scope
[scope_len
] != '\0')
601 /* Recursively search for names in child namespaces first. */
604 int new_scope_len
= scope_len
;
606 /* If the current scope is followed by "::", skip past that. */
607 if (new_scope_len
!= 0)
609 gdb_assert (scope
[new_scope_len
] == ':');
612 new_scope_len
+= cp_find_first_component (scope
+ new_scope_len
);
613 sym
= lookup_namespace_scope (name
, block
, domain
,
614 scope
, new_scope_len
);
619 /* Okay, we didn't find a match in our children, so look for the
620 name in the current namespace. */
622 namespace = alloca (scope_len
+ 1);
623 strncpy (namespace, scope
, scope_len
);
624 namespace[scope_len
] = '\0';
625 return cp_lookup_symbol_in_namespace (namespace, name
,
629 /* Look up NAME in BLOCK's static block and in global blocks. If
630 ANONYMOUS_NAMESPACE is nonzero, the symbol in question is located
631 within an anonymous namespace. If SEARCH is non-zero, search through
632 base classes for a matching symbol. Other arguments are as in
633 cp_lookup_symbol_nonlocal. */
635 static struct symbol
*
636 lookup_symbol_file (const char *name
,
637 const struct block
*block
,
638 const domain_enum domain
,
639 int anonymous_namespace
, int search
)
641 struct symbol
*sym
= NULL
;
643 sym
= lookup_symbol_static (name
, block
, domain
);
647 if (anonymous_namespace
)
649 /* Symbols defined in anonymous namespaces have external linkage
650 but should be treated as local to a single file nonetheless.
651 So we only search the current file's global block. */
653 const struct block
*global_block
= block_global_block (block
);
655 if (global_block
!= NULL
)
656 sym
= lookup_symbol_aux_block (name
, global_block
, domain
);
660 sym
= lookup_symbol_global (name
, block
, domain
);
668 char *klass
, *nested
;
669 unsigned int prefix_len
;
670 struct cleanup
*cleanup
;
671 struct symbol
*klass_sym
;
673 /* A simple lookup failed. Check if the symbol was defined in
676 cleanup
= make_cleanup (null_cleanup
, NULL
);
678 /* Find the name of the class and the name of the method,
680 prefix_len
= cp_entire_prefix_len (name
);
682 /* If no prefix was found, search "this". */
688 this = lookup_language_this (language_def (language_cplus
), block
);
691 do_cleanups (cleanup
);
695 type
= check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
696 klass
= xstrdup (TYPE_NAME (type
));
697 nested
= xstrdup (name
);
701 /* The class name is everything up to and including PREFIX_LEN. */
702 klass
= savestring (name
, prefix_len
);
704 /* The rest of the name is everything else past the initial scope
706 nested
= xstrdup (name
+ prefix_len
+ 2);
709 /* Add cleanups to free memory for these strings. */
710 make_cleanup (xfree
, klass
);
711 make_cleanup (xfree
, nested
);
713 /* Lookup a class named KLASS. If none is found, there is nothing
714 more that can be done. */
715 klass_sym
= lookup_symbol_global (klass
, block
, domain
);
716 if (klass_sym
== NULL
)
718 do_cleanups (cleanup
);
722 /* Look for a symbol named NESTED in this class. */
723 sym
= cp_lookup_nested_symbol (SYMBOL_TYPE (klass_sym
), nested
, block
);
724 do_cleanups (cleanup
);
730 /* Search through the base classes of PARENT_TYPE for a symbol named
731 NAME in block BLOCK. */
733 static struct symbol
*
734 find_symbol_in_baseclass (struct type
*parent_type
, const char *name
,
735 const struct block
*block
)
739 struct cleanup
*cleanup
;
740 char *concatenated_name
;
743 concatenated_name
= NULL
;
744 cleanup
= make_cleanup (free_current_contents
, &concatenated_name
);
745 for (i
= 0; i
< TYPE_N_BASECLASSES (parent_type
); ++i
)
748 const char *base_name
= TYPE_BASECLASS_NAME (parent_type
, i
);
750 if (base_name
== NULL
)
753 /* Search this particular base class. */
754 sym
= cp_lookup_symbol_namespace (base_name
, name
, block
, VAR_DOMAIN
);
758 len
= strlen (base_name
) + 2 + strlen (name
) + 1;
759 concatenated_name
= xrealloc (concatenated_name
, len
);
760 xsnprintf (concatenated_name
, len
, "%s::%s", base_name
, name
);
761 sym
= lookup_symbol_static (concatenated_name
, block
, VAR_DOMAIN
);
763 /* If there is currently no BLOCK, e.g., the inferior hasn't yet
764 been started, then try searching all STATIC_BLOCK symbols in
768 sym
= lookup_static_symbol_aux (concatenated_name
, VAR_DOMAIN
);
773 /* If this class has base classes, search them next. */
774 if (TYPE_N_BASECLASSES (TYPE_BASECLASS (parent_type
, i
)) > 0)
776 sym
= find_symbol_in_baseclass (TYPE_BASECLASS (parent_type
, i
),
783 do_cleanups (cleanup
);
787 /* Look up a symbol named NESTED_NAME that is nested inside the C++
788 class or namespace given by PARENT_TYPE, from within the context
789 given by BLOCK. Return NULL if there is no such nested type. */
792 cp_lookup_nested_symbol (struct type
*parent_type
,
793 const char *nested_name
,
794 const struct block
*block
)
796 /* type_name_no_tag_required provides better error reporting using the
798 struct type
*saved_parent_type
= parent_type
;
800 CHECK_TYPEDEF (parent_type
);
802 switch (TYPE_CODE (parent_type
))
804 case TYPE_CODE_STRUCT
:
805 case TYPE_CODE_NAMESPACE
:
806 case TYPE_CODE_UNION
:
808 /* NOTE: carlton/2003-11-10: We don't treat C++ class members
809 of classes like, say, data or function members. Instead,
810 they're just represented by symbols whose names are
811 qualified by the name of the surrounding class. This is
812 just like members of namespaces; in particular,
813 lookup_symbol_namespace works when looking them up. */
816 const char *parent_name
= type_name_no_tag_or_error (saved_parent_type
);
818 = cp_lookup_symbol_in_namespace (parent_name
, nested_name
,
819 block
, VAR_DOMAIN
, 0);
820 char *concatenated_name
;
825 /* Now search all static file-level symbols. Not strictly
826 correct, but more useful than an error. We do not try to
827 guess any imported namespace as even the fully specified
828 namespace search is already not C++ compliant and more
829 assumptions could make it too magic. */
831 size
= strlen (parent_name
) + 2 + strlen (nested_name
) + 1;
832 concatenated_name
= alloca (size
);
833 xsnprintf (concatenated_name
, size
, "%s::%s",
834 parent_name
, nested_name
);
835 sym
= lookup_static_symbol_aux (concatenated_name
, VAR_DOMAIN
);
839 /* If no matching symbols were found, try searching any
841 return find_symbol_in_baseclass (parent_type
, nested_name
, block
);
844 internal_error (__FILE__
, __LINE__
,
845 _("cp_lookup_nested_symbol called "
846 "on a non-aggregate type."));
850 /* The C++-version of lookup_transparent_type. */
852 /* FIXME: carlton/2004-01-16: The problem that this is trying to
853 address is that, unfortunately, sometimes NAME is wrong: it may not
854 include the name of namespaces enclosing the type in question.
855 lookup_transparent_type gets called when the type in question
856 is a declaration, and we're trying to find its definition; but, for
857 declarations, our type name deduction mechanism doesn't work.
858 There's nothing we can do to fix this in general, I think, in the
859 absence of debug information about namespaces (I've filed PR
860 gdb/1511 about this); until such debug information becomes more
861 prevalent, one heuristic which sometimes looks is to search for the
862 definition in namespaces containing the current namespace.
864 We should delete this functions once the appropriate debug
865 information becomes more widespread. (GCC 3.4 will be the first
866 released version of GCC with such information.) */
869 cp_lookup_transparent_type (const char *name
)
871 /* First, try the honest way of looking up the definition. */
872 struct type
*t
= basic_lookup_transparent_type (name
);
878 /* If that doesn't work and we're within a namespace, look there
880 scope
= block_scope (get_selected_block (0));
882 if (scope
[0] == '\0')
885 return cp_lookup_transparent_type_loop (name
, scope
, 0);
888 /* Lookup the type definition associated to NAME in namespaces/classes
889 containing SCOPE whose name is strictly longer than LENGTH. LENGTH
890 must be the index of the start of a component of SCOPE. */
893 cp_lookup_transparent_type_loop (const char *name
,
897 int scope_length
= length
+ cp_find_first_component (scope
+ length
);
900 /* If the current scope is followed by "::", look in the next
902 if (scope
[scope_length
] == ':')
905 = cp_lookup_transparent_type_loop (name
, scope
,
912 full_name
= alloca (scope_length
+ 2 + strlen (name
) + 1);
913 strncpy (full_name
, scope
, scope_length
);
914 strncpy (full_name
+ scope_length
, "::", 2);
915 strcpy (full_name
+ scope_length
+ 2, name
);
917 return basic_lookup_transparent_type (full_name
);
920 /* This used to do something but was removed when it became
924 maintenance_cplus_namespace (char *args
, int from_tty
)
926 printf_unfiltered (_("The `maint namespace' command was removed.\n"));
929 /* Provide a prototype to silence -Wmissing-prototypes. */
930 extern initialize_file_ftype _initialize_cp_namespace
;
933 _initialize_cp_namespace (void)
935 struct cmd_list_element
*cmd
;
937 cmd
= add_cmd ("namespace", class_maintenance
,
938 maintenance_cplus_namespace
,
939 _("Deprecated placeholder for removed functionality."),
940 &maint_cplus_cmd_list
);
941 deprecate_cmd (cmd
, NULL
);