From patchwork Wed Oct 10 09:17:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 981768 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-487244-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="nIdzxUZ6"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42VTCD36jZz9s8r for ; Wed, 10 Oct 2018 20:22:32 +1100 (AEDT) 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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=CXx2a+25XA44MtqzA4Y/x7nk8C5uD +0jJVQGZBUtHYr+cDmq4BvuTIKj3wTPhQ/OVbxqChXoWuxxaIi7QrZMuuCr7wlzj KmouIBZVA7gjubOrkeuSlD6sql+36UsbVZPvKOA/vF0+k1Sg5ZfxwC7N5V2Gbrcj CE6uxGUW/wB9Rc= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=LoDlCLgDzfc/WhAZBxBf5ENpD7Q=; b=nId zxUZ6UJtnqP801yToUTOO7/CpOlVzMu8NJHtk3302e5nuBQgPzM6muKqtV/d2q7W w/+iFqQrWTIKB4X9RaG/jSCBkyNUQy+2IgmQy4aUoDNZJdixFFxcdoHeiRzjKwmA M55KM5v/WTwlHFg0iC+C03kNZYjcOF9Tnn/iOdko= Received: (qmail 46085 invoked by alias); 10 Oct 2018 09:21:13 -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 41874 invoked by uid 89); 10 Oct 2018 09:17:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=sc, sd, s.c X-HELO: mx1.redhat.com 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; Wed, 10 Oct 2018 09:17:36 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B5CF43164981 for ; Wed, 10 Oct 2018 09:17:34 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-222.ams2.redhat.com [10.36.117.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 31DBA68870; Wed, 10 Oct 2018 09:17:34 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w9A9HWAD009855; Wed, 10 Oct 2018 11:17:32 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w9A9HV79009854; Wed, 10 Oct 2018 11:17:31 +0200 Date: Wed, 10 Oct 2018 11:17:31 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix up bitfield handling in typeid (PR c++/87547) Message-ID: <20181010091731.GT11625@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! typeid of an expression that is a bitfield right now returns various weird results, depending on what exact type ignoring precision we choose for the bitfield. Haven't found exact wording in the standard that would back this out though. clang++ agrees with the patched g++ though. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-10-10 Jakub Jelinek PR c++/87547 * rtti.c (get_tinfo_decl_dynamic): Use unlowered_expr_type instead of TREE_TYPE. * g++.dg/rtti/typeid12.C: New test. Jakub --- gcc/cp/rtti.c.jj 2018-08-27 17:50:43.782489578 +0200 +++ gcc/cp/rtti.c 2018-10-09 10:52:42.348604424 +0200 @@ -273,7 +273,7 @@ get_tinfo_decl_dynamic (tree exp, tsubst exp = resolve_nondeduced_context (exp, complain); /* peel back references, so they match. */ - type = non_reference (TREE_TYPE (exp)); + type = non_reference (unlowered_expr_type (exp)); /* Peel off cv qualifiers. */ type = TYPE_MAIN_VARIANT (type); --- gcc/testsuite/g++.dg/rtti/typeid12.C.jj 2018-10-09 10:42:19.580094220 +0200 +++ gcc/testsuite/g++.dg/rtti/typeid12.C 2018-10-09 10:42:04.105354872 +0200 @@ -0,0 +1,16 @@ +// PR c++/87547 +// { dg-do run } + +#include + +struct S { unsigned int a : 4; unsigned int b : 12; int c; unsigned long d : 8; } s; + +int +main () +{ + if (typeid (s.a) != typeid (unsigned int) + || typeid (s.b) != typeid (unsigned int) + || typeid (s.c) != typeid (int) + || typeid (s.d) != typeid (unsigned long)) + __builtin_abort (); +}