From patchwork Tue Dec 4 08:30:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhouyi Zhou X-Patchwork-Id: 1007479 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-491577-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="OzPEXEUc"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GsffdGL9"; 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 438FSZ2Cl4z9s3Z for ; Tue, 4 Dec 2018 19:31:08 +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:from :to:cc:subject:date:message-id; q=dns; s=default; b=lnCEwFOJWkdj ry4jTeUfak4S1Blr7j/u1a2/Q+qs7SOizghUmCTnkCE4VviwwhAoM2BIu6c71xBc BDctJ2XgcxAFIQp50bwMNl5364cosY8kI8Lw+am9UcWz818BoP1dpTK6i9Z7iTqw AMaD+kBvJGA/Ey5gG6skQ+gJLyFzTyk= 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:from :to:cc:subject:date:message-id; s=default; bh=z71VuUQ9VIzpxz8EF/ nkd/BXEQ4=; b=OzPEXEUcrfsNlBu6rMc/TIjnkczWumlxOgiKhRSyXaNK30Tpd4 8alnYkZk7z0kfQfh2hKAT3dfCf2iRgft43iV240XD3ZuVkxKhUvwClqvVyDQnIb0 TpXtGRJsdtgPLYxzU32zxENPNHgf90/OpXubn3zWxQ+U2OyfxZR+7LOes= Received: (qmail 17251 invoked by alias); 4 Dec 2018 08:31:01 -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 17120 invoked by uid 89); 4 Dec 2018 08:30:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Signedoffby, Signed-off-by, H*r:sk:mail-pf, fall X-HELO: mail-pf1-f182.google.com Received: from mail-pf1-f182.google.com (HELO mail-pf1-f182.google.com) (209.85.210.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Dec 2018 08:30:55 +0000 Received: by mail-pf1-f182.google.com with SMTP id g62so7833542pfd.12 for ; Tue, 04 Dec 2018 00:30:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=4Gme8f8JmORrDwOTFpqNgaJaGx9RXaB03L2hihyB5FE=; b=GsffdGL9Z7jBXm2Il8CNdjH4FZs4+EdkJL0/D08NtfBgBYbU0yc248z0H3Assmy81l mH4VdQf0i+NG1gOqYSMsqwuRQ3X4xNqpUGbOTvl6tqQrYL/AGThzdjVyH+3UVuBK08FF TFkeSx1yMGppm18J9mbw5MjFLpxK5z/xNWGyanyhh0OZMuOMIYrbGdKLJmCViKmpqXeE eVB7yfAPtWvzBgRaPBxih5/lrnxa5tZ+xX5/tBpHiMk7GeL9XjBPLrgpthLIVLGGPBO5 3wpC0JHIGWsh3Vp4F7cge/wyCDGHNCLCqcmus3HCPUYg+03oq6azb0uJWbrhYxW0Pe6e lPGw== Received: from localhost.localdomain ([118.193.167.117]) by smtp.gmail.com with ESMTPSA id q35sm18215348pgk.12.2018.12.04.00.30.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 00:30:40 -0800 (PST) From: Zhouyi Zhou To: gcc-patches@gcc.gnu.org Cc: Zhouyi Zhou Subject: Fix ICE in pp_cxx_unqualified_id (PR c++/88348) Date: Tue, 4 Dec 2018 08:30:12 +0000 Message-Id: <1543912212-9439-1-git-send-email-zhouzhouyi@gmail.com> cxx_pretty_printer::type_id do not treat pointer to pointer to member correctly. this patch handle pointer to pointer to member according to C++ standard 11.3.3. I don't have write access to gcc. Bootstrapped/regtested on x86_64-linux Signed-off-by: Zhouyi Zhou 2018-12-04 Zhouyi Zhou PR c++/88291 * cxx-pretty-print.c (type_id): treat pointer to pointer to member by strip out the pointee, print the type specifier of pointee, then print the rest by calling pp_cxx_ptr_operator. * g++.dg/pr88348.C: New test. diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index b79ff51..106e6af 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -1829,6 +1829,27 @@ cxx_pretty_printer::type_id (tree t) pp_cxx_ws_string (this, "..."); break; + case POINTER_TYPE: + { + tree pointee = strip_pointer_operator(TREE_TYPE(t)); + /* 11.3.3 */ + if (TREE_CODE(pointee) == RECORD_TYPE && + TYPE_PTRMEMFUNC_P(pointee)) { + tree pfm = TYPE_PTRMEMFUNC_FN_TYPE (pointee); + pp_cxx_type_specifier_seq (this, TREE_TYPE (TREE_TYPE (pfm))); + pp_cxx_whitespace (this); + pp_cxx_ptr_operator(this, t); + break; + } else if (TREE_CODE(pointee) == OFFSET_TYPE && + TYPE_PTRMEM_P(pointee)) { + pp_cxx_type_specifier_seq (this, TYPE_PTRMEM_POINTED_TO_TYPE(pointee)); + pp_cxx_whitespace (this); + pp_cxx_ptr_operator(this, t); + break; + } + } + /* fall through */ + default: c_pretty_printer::type_id (t); break; diff --git a/gcc/testsuite/g++.dg/pr88348.C b/gcc/testsuite/g++.dg/pr88348.C new file mode 100644 index 0000000..5713f49 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr88348.C @@ -0,0 +1,16 @@ +// { dg-do compile { target c++11 } } + +void* operator new (__SIZE_TYPE__, void *p) { return p; } + +struct Z { + void f(int = 0) const; + int speed; +}; + +template struct helper {}; + +typedef void (Z::***QF)(int) const; +typedef int Z::***pSpeed; + +template void check1( helper * ) { } // { dg-error "is not a constant expression|type/value mismatch" } +template void check2( helper * ) { } // { dg-error "is not a constant expression|type/value mismatch" }