From patchwork Tue Nov 15 14:13:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 695039 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 3tJ8Wt42Pgz9sCZ for ; Wed, 16 Nov 2016 01:14:02 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="USiqcaTB"; 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=ukDPm6K2YNb2QBtQ04GjZDQBK9Zfr UVPWHVcdlQvazWNpP83NPfr1VrsfgAr+KmoNWJEdgSY1JMyLXIkc8lJlQVYJy+hP HrIDRsDzPwBKK9ni13WHpqgwr9uZ7+SvvhVNjiuD+i2ROKSu6bJDfdR6+Bp7FfO6 4UdmU58vfR/voU= 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=ncSwoDufDRd/1dZN2CHZlJsnOVU=; b=USi qcaTBZSKSj6oFRjPv6ZbXNANXOrVZKAgbhH0F38I1ZOUm+nrT5Ne1rMDIHSMiSh9 QeZFCztqfUL5C2Aj7RMU4gsma30IvqP2B2WuyuZ9xjoJawjFJDUfv6trmol4Xgbw wZvsqpC/BEv0MGaOQ4e7FAGBDuK9mvx+sAa11EUE= Received: (qmail 100531 invoked by alias); 15 Nov 2016 14:13:50 -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 100515 invoked by uid 89); 15 Nov 2016 14:13:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=friend 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; Tue, 15 Nov 2016 14:13:48 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8152201EA for ; Tue, 15 Nov 2016 14:13:47 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-19.brq.redhat.com [10.40.204.19]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAFEDkJB001037 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Nov 2016 09:13:47 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id uAFEDiL3027961; Tue, 15 Nov 2016 15:13:45 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id uAFEDiWl027960; Tue, 15 Nov 2016 15:13:44 +0100 Date: Tue, 15 Nov 2016 15:13:44 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] SOme further g++.dg/cpp1z/decomp*.C tests Message-ID: <20161115141344.GG3541@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi! This patch adds 3 new tests. Tested on x86_64-linux, ok for trunk? 2016-11-15 Jakub Jelinek * g++.dg/cpp1z/decomp13.C: New test. * g++.dg/cpp1z/decomp14.C: New test. * g++.dg/cpp1z/decomp15.C: New test. Jakub --- gcc/testsuite/g++.dg/cpp1z/decomp13.C.jj 2016-11-15 14:25:18.902048735 +0100 +++ gcc/testsuite/g++.dg/cpp1z/decomp13.C 2016-11-15 14:48:12.795463351 +0100 @@ -0,0 +1,30 @@ +// { dg-do compile { target c++11 } } +// { dg-options "" } + +struct A { int f; }; +struct B { int b; }; +struct C : virtual A {}; +struct D : virtual A {}; +struct E { int f; }; +struct F : A { int f; }; +struct G : A, E {}; +struct H : C, D {}; +struct I : A, C {}; // { dg-warning "due to ambiguity" } +struct J : B {}; +struct K : B, virtual J {}; // { dg-warning "due to ambiguity" } +struct L : virtual J {}; +struct M : virtual J, L {}; + +void +foo (C &c, F &f, G &g, H &h, I &i, K &k, M &m) +{ + auto [ ci ] = c; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } } + auto [ fi ] = f; // { dg-error "cannot decompose class type 'F': both it and its base class 'A' have non-static data members" } + // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .-1 } + auto [ gi ] = g; // { dg-error "cannot decompose class type 'G': its base classes 'A' and 'E' have non-static data members" } + // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .-1 } + auto [ hi ] = h; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } } + auto [ ki ] = k; // { dg-error "'B' is an ambiguous base of 'K'" } + // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .-1 } + auto [ mi ] = m; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } } +} --- gcc/testsuite/g++.dg/cpp1z/decomp14.C.jj 2016-11-15 14:30:40.296941834 +0100 +++ gcc/testsuite/g++.dg/cpp1z/decomp14.C 2016-11-15 14:50:32.361678491 +0100 @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-std=c++1z" } + +struct A { bool a, b; }; +struct B { int a, b; }; + +void +foo () +{ + auto [ a, b ] = A (); + for (auto [ a, b ] = A (); a; ) + ; + if (auto [ a, b ] = A (); a) + ; + switch (auto [ a, b ] = B (); b) + { + case 2: + break; + } + auto && [ c, d ] = A (); + [[maybe_unused]] auto [ e, f ] = A (); + alignas (A) auto [ g, h ] = A (); + __attribute__((unused)) auto [ i, j ] = A (); +} --- gcc/testsuite/g++.dg/cpp1z/decomp15.C.jj 2016-11-15 14:38:55.198602649 +0100 +++ gcc/testsuite/g++.dg/cpp1z/decomp15.C 2016-11-15 14:46:33.000000000 +0100 @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-std=c++1z" } + +struct A { bool a, b; }; +struct B { int a, b; }; + +void +foo () +{ + auto [ a, b ] = A (); + for (; auto [ a, b ] = A (); ) // { dg-error "expected" } + ; + for (; false; auto [ a, b ] = A ()) // { dg-error "expected" } + ; + if (auto [ a, b ] = A ()) // { dg-error "expected" } + ; + if (auto [ a, b ] = A (); auto [ c, d ] = A ()) // { dg-error "expected" } + ; + if (int d = 5; auto [ a, b ] = A ()) // { dg-error "expected" } + ; + switch (auto [ a, b ] = B ()) // { dg-error "expected" } + { + case 2: + break; + } + switch (int d = 5; auto [ a, b ] = B ()) // { dg-error "expected" } + { + case 2: + break; + } + A e = A (); + auto && [ c, d ] = e; + auto [ i, j ] = A (), [ k, l ] = A (); // { dg-error "expected" } + auto m = A (), [ n, o ] = A (); // { dg-error "expected" } +} + +template +auto [ a, b ] = A (); // { dg-error "expected" } + +struct C +{ + auto [ e, f ] = A (); // { dg-error "expected" } + mutable auto [ g, h ] = A (); // { dg-error "expected" } + virtual auto [ i, j ] = A (); // { dg-error "expected" } + explicit auto [ k, l ] = A (); // { dg-error "expected" } + friend auto [ m, n ] = A (); // { dg-error "expected" } +};