From patchwork Fri Jun 19 14:47:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 50116 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2271E218C9 for ; Fri, 19 Jun 2015 14:47:39 +0000 (UTC) Received: by lbcak1 with SMTP id ak1sf28942799lbc.2 for ; Fri, 19 Jun 2015 07:47:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:date:message-id:subject:from:to :content-type:x-original-sender:x-original-authentication-results; bh=IETOicnGGxQlvug2mhTgT3pWpg81InF/RvirI6DJMoc=; b=av+HpwHnaIvbqzGaqTYpsatZXC/Yxp1A67mYOlJddjrxLilG1Cn0AZobxmvz54pjAr gJYxy+GmuB9LMS3qQmuOWMU5l/zMIJwYHLON/UzDjHtsYjVUslXUCANKnWglUAboeQaL uRVZrfzGZScVAgMgsKyzWdEz3BhyNJ9CpIiaUwrbBfgB6DmEl7owblwqVfPLECOguSZC 5FUfScNaXamBrEgd+fh5qWlXBrCvpySRjSZsI2o2ugBDknUDqOcUTokl3wwJuy2Z4auW XePyUDava9OFBsPiFzEFxCr8MbGv3zSIZrS6guq1jX/9liQ56RvUDSI2M3G2qsqTvI29 kKEQ== X-Gm-Message-State: ALoCoQkal8DhOwLRa4z/9ReDjB3Qnmv8hiC1sBVdcAipJYlTri+5Nklkop15J33IA95oom0DVelz X-Received: by 10.194.58.164 with SMTP id s4mr7969840wjq.3.1434725258050; Fri, 19 Jun 2015 07:47:38 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.70 with SMTP id le6ls636838lac.50.gmail; Fri, 19 Jun 2015 07:47:37 -0700 (PDT) X-Received: by 10.112.24.233 with SMTP id x9mr18639049lbf.7.1434725257880; Fri, 19 Jun 2015 07:47:37 -0700 (PDT) Received: from mail-la0-x229.google.com (mail-la0-x229.google.com. [2a00:1450:4010:c03::229]) by mx.google.com with ESMTPS id ds10si9332415lbc.133.2015.06.19.07.47.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jun 2015 07:47:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::229 as permitted sender) client-ip=2a00:1450:4010:c03::229; Received: by labko7 with SMTP id ko7so75786155lab.2 for ; Fri, 19 Jun 2015 07:47:37 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr18248827lae.19.1434725257700; Fri, 19 Jun 2015 07:47:37 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp645492lbb; Fri, 19 Jun 2015 07:47:36 -0700 (PDT) X-Received: by 10.68.203.231 with SMTP id kt7mr32775439pbc.58.1434725253347; Fri, 19 Jun 2015 07:47:33 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y2si16729037pdc.203.2015.06.19.07.47.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jun 2015 07:47:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-400807-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 116011 invoked by alias); 19 Jun 2015 14:47:20 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 115999 invoked by uid 89); 19 Jun 2015 14:47:19 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f175.google.com Received: from mail-yk0-f175.google.com (HELO mail-yk0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 19 Jun 2015 14:47:17 +0000 Received: by ykfr66 with SMTP id r66so93495293ykf.0 for ; Fri, 19 Jun 2015 07:47:15 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.129.74.135 with SMTP id x129mr20297193ywa.98.1434725235324; Fri, 19 Jun 2015 07:47:15 -0700 (PDT) Received: by 10.37.88.137 with HTTP; Fri, 19 Jun 2015 07:47:15 -0700 (PDT) Date: Fri, 19 Jun 2015 20:17:15 +0530 Message-ID: Subject: [C PATCH] Fix PR44257 From: Prathamesh Kulkarni To: "Joseph S. Myers" , polacek@redhat.com, gcc Patches X-IsSubscribed: yes X-Original-Sender: prathamesh.kulkarni@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::229 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Hi, C FE rejects incomplete type for expression in typeof. struct foo; struct foo *p; typeof (struct foo) *q; // accepted typeof (*p) *q; // error: dereferencing pointer to incomplete type. The attached patch tries to fix it. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. OK for trunk if testing passes ? Thank you, Prathamesh 2015-06-19 Prathamesh Kulkarni PR c/44257 * c-typeck.c (build_indirect_ref): Add check !in_typeof before reporting incomplete type error. * gcc.dg/pr44257: New test-case. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 636e0bb..5dbbea7 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -2389,7 +2389,7 @@ build_indirect_ref (location_t loc, tree ptr, ref_operator errstring) ref = build1 (INDIRECT_REF, t, pointer); - if (!COMPLETE_OR_VOID_TYPE_P (t) && TREE_CODE (t) != ARRAY_TYPE) + if (!COMPLETE_OR_VOID_TYPE_P (t) && TREE_CODE (t) != ARRAY_TYPE && !in_typeof) { if (!C_TYPE_ERROR_REPORTED (TREE_TYPE (ptr))) { diff --git a/gcc/testsuite/gcc.dg/pr44257.c b/gcc/testsuite/gcc.dg/pr44257.c new file mode 100644 index 0000000..9657d2a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr44257.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ + +struct foo; +struct foo *p; +__typeof (*p) *q;