internal_error (_("unhandled c_string_type"));
}
- /* Ensure TYPE_LENGTH is valid for TYPE. */
- check_typedef (type);
-
/* If the caller expects an array of some integral type,
satisfy them. If something odder is expected, rely on the
caller to cast. */
objfile ? objfile_name (objfile) : "<arch>");
}
-/* Lookup a typedef or primitive type named NAME, visible in lexical
- block BLOCK. If NOERR is nonzero, return zero if NAME is not
- suitably defined. */
+/* See gdbtypes.h. */
struct type *
lookup_typename (const struct language_defn *language,
sym = lookup_symbol_in_language (name, block, VAR_DOMAIN,
language->la_language, NULL).symbol;
if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
- return sym->type ();
+ {
+ struct type *type = sym->type ();
+ /* Ensure the length of TYPE is valid. */
+ check_typedef (type);
+ return type;
+ }
if (noerr)
return NULL;
extern char *gdb_mangle_name (struct type *, int, int);
-extern struct type *lookup_typename (const struct language_defn *,
- const char *, const struct block *, int);
+/* Lookup a typedef or primitive type named NAME, visible in lexical block
+ BLOCK. If NOERR is nonzero, return zero if NAME is not suitably
+ defined.
+
+ If this function finds a suitable type then check_typedef is called on
+ the type, this ensures that if the type being returned is a typedef
+ then the length of the type will be correct. The original typedef will
+ still be returned, not the result of calling check_typedef. */
+
+extern struct type *lookup_typename (const struct language_defn *language,
+ const char *name,
+ const struct block *block, int noerr);
extern struct type *lookup_template_type (const char *, struct type *,
const struct block *);
--- /dev/null
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2023 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <wchar.h>
+
+const wchar_t wide_str[] = L"wide string";
+
+int
+main (void)
+{
+ return 0;
+}
--- /dev/null
+# Copyright 2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
+ return -1
+}
+
+if {![runto_main]} {
+ return -1
+}
+
+gdb_test {printf "%ls\n", wide_str} "^wide string"