This is the mail archive of the
mailing list for the GCC project.
[PATCH] Handle IDENTIFIER_NODEs in ubsan.c (PR sanitizer/58420)
- From: Marek Polacek <polacek at redhat dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 16 Sep 2013 17:49:55 +0200
- Subject: [PATCH] Handle IDENTIFIER_NODEs in ubsan.c (PR sanitizer/58420)
- Authentication-results: sourceware.org; auth=none
This patch amends the chunk of code where we are determining the
type name; I haven't consider that IDENTIFIER_NODEs require special
handling, since we need to omit the DECL_NAME. I had something similar
in http://gcc.gnu.org/ml/gcc-patches/2013-09/msg00917.html patch, but
there I had a thinko: I need to check that TYPE_NAME is non-NULL first.
Regtested/ran bootstrap-ubsan on x86_64-linux.
Ok for trunk?
2013-09-16 Marek Polacek <firstname.lastname@example.org>
* ubsan.c (ubsan_type_descriptor): Handle IDENTIFIER_NODEs
when determining the type name.
--- gcc/ubsan.c.mp 2013-09-16 14:22:07.195918175 +0200
+++ gcc/ubsan.c 2013-09-16 14:22:10.503929477 +0200
@@ -260,11 +260,18 @@ ubsan_type_descriptor (tree type)
unsigned short tkind, tinfo;
/* At least for INTEGER_TYPE/REAL_TYPE/COMPLEX_TYPE, this should work.
- ??? For e.g. type_unsigned_for (type), the TYPE_NAME would be NULL. */
+ For e.g. type_unsigned_for (type) or bit-fields, the TYPE_NAME
+ would be NULL. */
if (TYPE_NAME (type) != NULL)
- tname = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
+ if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
+ tname = IDENTIFIER_POINTER (TYPE_NAME (type));
+ tname = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
tname = "<unknown>";
if (TREE_CODE (type) == INTEGER_TYPE)
/* For INTEGER_TYPE, this is 0x0000. */