From patchwork Mon Sep 16 15:49:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 275234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9B9CC2C00C7 for ; Tue, 17 Sep 2013 01:50:09 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=EoBBDhotojhMq+r0ltgoNKCY+udnZqq5DTLH5PwVWf0vd24e5PheT xZhWvqiNyvr8fhnsY2xYo7tntR0T2hdUlqiYbZTBCdGBDKrkliqp2BfLyuPJh/TH sqpDqTWzmnkm3p1toJjrvS/jZ3NbiTlMWvM+XPvQg/b5APSv+eNqZI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=OzqNGMh2dh0lbpwo3i8nDc2ghcE=; b=pPRrZfl/oHWbJV8J4jvz 7yaqdB3onsf1S2Yr7ZCR+cVAanhGUWAxRVb4E0dWOJ9IOVQf0CPQPCKQytg1vcu2 1oGASfHQuZGdwzDR3c2QHQNhwqpO1PHC83vzZifA8ukEq8/8/ZY8wE44WB/DcxPy Z26uiX5Dr8jrLMp5rO1JyYo= Received: (qmail 23969 invoked by alias); 16 Sep 2013 15:50:03 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 23953 invoked by uid 89); 16 Sep 2013 15:50:02 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Sep 2013 15:50:02 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8GFnxTo020341 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 16 Sep 2013 11:49:59 -0400 Received: from redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r8GFnuLK023400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Mon, 16 Sep 2013 11:49:58 -0400 Date: Mon, 16 Sep 2013 17:49:55 +0200 From: Marek Polacek To: GCC Patches Subject: [PATCH] Handle IDENTIFIER_NODEs in ubsan.c (PR sanitizer/58420) Message-ID: <20130916154955.GC23899@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 PR sanitizer/58420 * ubsan.c (ubsan_type_descriptor): Handle IDENTIFIER_NODEs when determining the type name. Marek --- 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)); + else + tname = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); + } else tname = ""; + if (TREE_CODE (type) == INTEGER_TYPE) { /* For INTEGER_TYPE, this is 0x0000. */