{
tree args = CLASSTYPE_TI_ARGS (type);
if (TREE_VEC_LENGTH (args) == 3
- && TREE_VEC_ELT (args, 0) == char_type_node
+ && same_type_p (TREE_VEC_ELT (args, 0), char_type_node)
&& is_std_substitution_char (TREE_VEC_ELT (args, 1),
SUBID_CHAR_TRAITS)
&& is_std_substitution_char (TREE_VEC_ELT (args, 2),
args <char, std::char_traits<char> > . */
tree args = CLASSTYPE_TI_ARGS (type);
if (TREE_VEC_LENGTH (args) == 2
- && TREE_VEC_ELT (args, 0) == char_type_node
+ && same_type_p (TREE_VEC_ELT (args, 0), char_type_node)
&& is_std_substitution_char (TREE_VEC_ELT (args, 1),
SUBID_CHAR_TRAITS))
{
}
/* <encoding> ::= <function name> <bare-function-type>
- ::= <data name>
- ::= <substitution> */
+ ::= <data name> */
static void
write_encoding (decl)
{
MANGLE_TRACE_TREE ("encoding", decl);
- if (find_substitution (decl))
- return;
-
if (DECL_LANG_SPECIFIC (decl) && DECL_EXTERN_C_FUNCTION_P (decl))
{
write_source_name (DECL_NAME (decl));
write_bare_function_type (fn_type, DECL_TEMPLATE_ID_P (decl));
}
-
- add_substitution (decl);
}
/* <name> ::= <unscoped-name>
<encoding> ::= <function name> <bare-function-type>
::= <data name>
- ::= <substitution> */
+ ::= <special-name> */
static status_t
demangle_encoding (dm)
demangling_t dm;
{
int template_p;
- int special_std_substitution;
int start_position;
- int start = substitution_start (dm);
template_arg_list_t old_arg_list = current_template_arg_list (dm);
char peek = peek_char (dm);
function, we'll have to insert the return type here. */
start_position = result_length (dm);
- if (peek == 'S')
- {
- RETURN_IF_ERROR (demangle_substitution (dm, &template_p,
- &special_std_substitution));
- if (special_std_substitution)
- {
- /* This was the magic `std::' substitution. */
- RETURN_IF_ERROR (result_append (dm, "::"));
- RETURN_IF_ERROR (demangle_encoding (dm));
- }
- }
- else if (peek == 'G' || peek == 'T')
+ if (peek == 'G' || peek == 'T')
RETURN_IF_ERROR (demangle_special_name (dm));
else
{
RETURN_IF_ERROR
(demangle_bare_function_type (dm, BFT_NO_RETURN_TYPE));
}
-
- RETURN_IF_ERROR (substitution_add (dm, start, template_p,
- NOT_TEMPLATE_PARM));
}
/* Pop off template argument lists that were built during the
case 'S':
/* The `St' substitution allows a name nested in std:: to appear
- without being enclosed in a nested name.
- <name> ::= St <unqualified-name> # ::std:: */
+ without being enclosed in a nested name. */
if (peek_char_next (dm) == 't')
{
(void) next_char (dm);
RETURN_IF_ERROR (demangle_name (dm, template_p));
}
}
+ /* Check if a template argument list immediately follows.
+ If so, then we just demangled an <unqualified-template-name>. */
+ if (peek_char (dm) == 'I')
+ {
+ RETURN_IF_ERROR (substitution_add (dm, start, 0,
+ NOT_TEMPLATE_PARM));
+ RETURN_IF_ERROR (demangle_template_args (dm));
+ }
break;
default:
{
int start = substitution_start (dm);
char peek = peek_char (dm);
+ char peek_next;
int template_p = 0;
int special_std_substitution;
int is_builtin_type = 0;
break;
case 'S':
- RETURN_IF_ERROR (demangle_substitution (dm, &template_p,
- &special_std_substitution));
- if (special_std_substitution)
- {
- /* This was the magic `std::' substitution. What follows
- must be a class name in that namespace. */
- RETURN_IF_ERROR (result_append (dm, "::"));
- RETURN_IF_ERROR (demangle_class_enum_type (dm, &template_p));
- }
+ /* First check if this is a special substitution. If it is,
+ this is a <class-enum-type>. Special substitutions have a
+ letter following the `S'; other substitutions have a digit
+ or underscore. */
+ peek_next = peek_char_next (dm);
+ if (IS_DIGIT (peek_next) || peek_next == '_')
+ RETURN_IF_ERROR (demangle_substitution (dm, &template_p,
+ &special_std_substitution));
+ else
+ demangle_class_enum_type (dm, &template_p);
break;
case 'P':
case 'a':
RETURN_IF_ERROR (result_append (dm, "std::allocator"));
new_last_source_name = "allocator";
+ *template_p = 1;
break;
case 'b':
RETURN_IF_ERROR (result_append (dm, "std::basic_string"));
new_last_source_name = "basic_string";
+ *template_p = 1;
break;
case 's':
RETURN_IF_ERROR (result_append (dm, "std::basic_string<char, std::char_traits<char>, std::allocator<char> >"));
new_last_source_name = "basic_string";
}
+ *template_p = 0;
break;
case 'i':
RETURN_IF_ERROR (result_append (dm, "std::basic_istream<char, std::char_traints<char> >"));
new_last_source_name = "basic_istream";
}
+ *template_p = 0;
break;
case 'o':
RETURN_IF_ERROR (result_append (dm, "std::basic_ostream<char, std::char_traits<char> >"));
new_last_source_name = "basic_ostream";
}
+ *template_p = 0;
break;
case 'd':
RETURN_IF_ERROR (result_append (dm, "std::basic_iostream<char, std::char_traits<char> >"));
new_last_source_name = "basic_iostream";
}
+ *template_p = 0;
break;
default:
substitution, `S0_' is the second-most-recent, etc., shift the
numbering by one. */
text = substitution_get (dm, seq_id + 1, template_p);
- if (text == NULL)
+ if (text == NULL)
return "Substitution number out of range.";
/* Emit the substitution text. */
if (STATUS_NO_ERROR (status))
printf ("%s\n", dyn_string_buf (result));
/* Abort on allocaiton failures. */
- if (status == STATUS_ALLOCATION_FAILED)
+ else if (status == STATUS_ALLOCATION_FAILED)
{
fprintf (stderr, "Memory allocaiton failed.\n");
- abort ():
+ abort ();
}
/* If not, print the error message to stderr instead. */
else