From: Pedro Alves Date: Tue, 14 Mar 2017 00:11:09 +0000 (+0000) Subject: Restore test-cp-name-parser build X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8a6200ba863f207d93467312431d107f50f0e2ab;p=binutils-gdb.git Restore test-cp-name-parser build Commit c8b23b3f89fbb0 ("Add constructor and destructor to demangle_parse_info") a while ago broke the "test-cp-name-parser" build: $ make test-cp-name-parser [...] src/gdb/cp-name-parser.y: In function ‘int main(int, char**)’: src/gdb/cp-name-parser.y:2190:9: error: cannot convert ‘std::unique_ptr’ to ‘demangle_parse_info*’ in assignment result = cp_demangled_name_to_comp (str2, &errmsg); ^ src/gdb/cp-name-parser.y:2199:38: error: ‘cp_demangled_name_parse_free’ was not declared in this scope cp_demangled_name_parse_free (result); ^ src/gdb/cp-name-parser.y:2211:14: error: cannot convert ‘std::unique_ptr’ to ‘demangle_parse_info*’ in assignment result = cp_demangled_name_to_comp (argv[arg], &errmsg); ^ src/gdb/cp-name-parser.y:2219:43: error: ‘cp_demangled_name_parse_free’ was not declared in this scope cp_demangled_name_parse_free (result); ^ Makefile:2107: recipe for target 'test-cp-name-parser.o' failed make: *** [test-cp-name-parser.o] Error 1 This commit restores it. gdb/ChangeLog: 2017-03-14 Pedro Alves * cp-name-parser.y (cp_demangled_name_to_comp): Update comment. (main): Use std::unique_ptr. Remove calls to cp_demangled_name_parse_free. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b5edb572f61..608501b9c63 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-03-14 Pedro Alves + + * cp-name-parser.y (cp_demangled_name_to_comp): Update comment. + (main): Use std::unique_ptr. Remove calls to + cp_demangled_name_parse_free. + 2017-03-13 Simon Marchi * alpha-bsd-nat.c (alphabsd_fetch_inferior_registers, diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index 5278c05afe9..70790fc1a36 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -2057,10 +2057,9 @@ cp_merge_demangle_parse_infos (struct demangle_parse_info *dest, } /* Convert a demangled name to a demangle_component tree. On success, - a structure containing the root of the new tree is returned; it must - be freed by calling cp_demangled_name_parse_free. On error, NULL is - returned, and an error message will be set in *ERRMSG (which does - not need to be freed). */ + a structure containing the root of the new tree is returned. On + error, NULL is returned, and an error message will be set in + *ERRMSG (which does not need to be freed). */ struct std::unique_ptr cp_demangled_name_to_comp (const char *demangled_name, const char **errmsg) @@ -2161,7 +2160,6 @@ main (int argc, char **argv) char buf[65536]; int arg; const char *errmsg; - struct demangle_parse_info *result; arg = 1; if (argv[arg] && strcmp (argv[arg], "--debug") == 0) @@ -2187,7 +2185,9 @@ main (int argc, char **argv) printf ("%s\n", buf); continue; } - result = cp_demangled_name_to_comp (str2, &errmsg); + + std::unique_ptr result + = cp_demangled_name_to_comp (str2, &errmsg); if (result == NULL) { fputs (errmsg, stderr); @@ -2196,7 +2196,6 @@ main (int argc, char **argv) } cp_print (result->tree); - cp_demangled_name_parse_free (result); free (str2); if (c) @@ -2208,7 +2207,8 @@ main (int argc, char **argv) } else { - result = cp_demangled_name_to_comp (argv[arg], &errmsg); + std::unique_ptr result + = cp_demangled_name_to_comp (argv[arg], &errmsg); if (result == NULL) { fputs (errmsg, stderr); @@ -2216,7 +2216,6 @@ main (int argc, char **argv) return 0; } cp_print (result->tree); - cp_demangled_name_parse_free (result); putchar ('\n'); } return 0;