From patchwork Tue Jul 11 18:41:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 786805 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x6WBs5f99z9s78 for ; Wed, 12 Jul 2017 04:41:41 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZnshlrmE"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=k/narEyZr/BneEd07Yn/ReoBF14zuvkzXUH+Z7H8+csos/ stOWf8nlja6vHlNryzkujHKavrKI8rd67A31ffU8plLeEjr+sChuTp6vvijZvuPy dZ3HFzfHHhLQniVR65Nsas+T+CR8VOS03IzBWESAFPiJdPL4QgLvMeYuJZtZ0= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=nxqtFrovzkcVdb2+uckNhtOJ/Y0=; b=ZnshlrmEHGIAuHKvqgqr 4DLFHlMn1row4aXTsd+VSv8X3ZzwAGNGkJmFEHSVxZWhNfrmKrC037UJqhI05DBV AaTmU73MUB0QJ/vRn3t1P1bkAE3+2SgYJvP8zYjdBKMAzFCfCGGjK0fno3RiM96D ZVTCI0gea5NUvtjXkOGPhDs= Received: (qmail 77578 invoked by alias); 11 Jul 2017 18:41:29 -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 77084 invoked by uid 89); 11 Jul 2017 18:41:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy=Downgrade, 126097 X-HELO: mail-it0-f51.google.com Received: from mail-it0-f51.google.com (HELO mail-it0-f51.google.com) (209.85.214.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Jul 2017 18:41:27 +0000 Received: by mail-it0-f51.google.com with SMTP id k192so408453ith.1 for ; Tue, 11 Jul 2017 11:41:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=WzR1Pmr1dwP3hVvlJ9ymLeiMomjLFlMwIIYgG3zxjGQ=; b=cJYZUzQdDWlj5HoTCEMgsvdDUKEGhUp3MVmCJ1yjIVTFEdgetJ/M4neHrW6u9TOHCK y3ffrhP9QSD/ddURgNBgS1AA46Rbx7B6voA0PYc9lOp3vqR0Wkr3pE3CeLEcnP1giAn8 Qas8pS9HzDYRfQI6SOsvzRyF68RLsCXwvkCr3v1xb8SaggNG0tIIhDCX0XzYCPKg83gI a4vogzW8dnXl3aZVZ2OuFS0Dci1DGGhVltfAPQX8NwSh1v1xzU6cdxGjV6PXpIsYr/Ng k6wdGq4/J6xOJbQbIhNFfJFwSlDQaV4yvIGyJrcJ8ta7KsSCMGSmAlBmnjIeeFlgr8b7 c9Bg== X-Gm-Message-State: AIVw112T6J9mS+Q8P3PIM3cgSt8/fRTQlumr+jo06/XjbsHDVTqLxhvh 74V751QNmo8pFoN+bKZrzfk1GC7VftRyOB4= X-Received: by 10.36.250.199 with SMTP id v190mr4748430ith.116.1499798485774; Tue, 11 Jul 2017 11:41:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.11.105 with HTTP; Tue, 11 Jul 2017 11:41:04 -0700 (PDT) From: Jason Merrill Date: Tue, 11 Jul 2017 14:41:04 -0400 Message-ID: Subject: C++ PATCH for Core DR 393, parm w/ pointer to array of unknown bound To: gcc-patches List X-IsSubscribed: yes Core DR 393 in C++17 removed the restriction on parameters with pointer to array of unknown bound type; accordingly, I've reduced the diagnostic for earlier standards to a pedwarn. Tested x86_64-pc-linux-gnu, applying to trunk. commit a89d6192b65fc0eef3d95592c212a389928b6cba Author: Jason Merrill Date: Tue Jul 11 12:08:10 2017 -0400 Core DR 393 - parameter pointer to array of unknown bound * decl.c (grokparms): Downgrade error about array of unknown bound to pedwarn and disable it for C++17. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 43a94d9..b9b8794 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12591,9 +12591,11 @@ grokparms (tree parmlist, tree *parms) } else if (abstract_virtuals_error (decl, type)) any_error = 1; /* Seems like a good idea. */ - else if (POINTER_TYPE_P (type)) + else if (cxx_dialect < cxx1z + && POINTER_TYPE_P (type)) { - /* [dcl.fct]/6, parameter types cannot contain pointers + /* Before C++17 DR 393: + [dcl.fct]/6, parameter types cannot contain pointers (references) to arrays of unknown bound. */ tree t = TREE_TYPE (type); int ptr = TYPE_PTR_P (type); @@ -12609,7 +12611,8 @@ grokparms (tree parmlist, tree *parms) t = TREE_TYPE (t); } if (TREE_CODE (t) == ARRAY_TYPE) - error (ptr + pedwarn (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic, + ptr ? G_("parameter %qD includes pointer to array of " "unknown bound %qT") : G_("parameter %qD includes reference to array of " diff --git a/gcc/testsuite/g++.dg/cpp1z/dr393.C b/gcc/testsuite/g++.dg/cpp1z/dr393.C new file mode 100644 index 0000000..4a7645a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/dr393.C @@ -0,0 +1,4 @@ +// DR 393 +// { dg-options -Wpedantic } + +void f(int (&)[]); // { dg-warning "unknown bound" "" { target c++14_down } }