From patchwork Thu Jun 12 20:44:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Sutton X-Patchwork-Id: 359326 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 3A86D140092 for ; Fri, 13 Jun 2014 06:45:23 +1000 (EST) 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=R6XMwPGMX2lKhXfNnP9PWMTbDhEgDUd/Iwm9q7GM8xYvke KicPvMTQRl4XUWMEgxBfV/0dsZVwZxncICDCFVjeZ/W0u0nfjlHfFHFD92ndT1bD kdQil5FVIPigB1tJuy5zDW5o57OyLUFk9w+gRCQ2UH8+vnA9sTwk1zQdnGgTs= 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=mF+vKrpmgJfS2FBiqvh/SrM8Syk=; b=vbHl3/GNAMr6P3vswkwK duIy5ZKRkgnRnHVVS7kYXHExyn2jyEA7TxH8pQ/CL22sZG+KBX9bvBfLza6RzttW wdyjF16+wXU2pLgsflKGNz1E+B/gdcHHzq2jePFeBPfiSdDEAmSfn2i0TGoIEk9b yeeBkGSsxTh9VajubUqZiLc= Received: (qmail 30452 invoked by alias); 12 Jun 2014 20:45: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 30430 invoked by uid 89); 12 Jun 2014 20:45:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f176.google.com Received: from mail-vc0-f176.google.com (HELO mail-vc0-f176.google.com) (209.85.220.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 12 Jun 2014 20:44:57 +0000 Received: by mail-vc0-f176.google.com with SMTP id ik5so1381507vcb.35 for ; Thu, 12 Jun 2014 13:44:55 -0700 (PDT) X-Received: by 10.220.167.2 with SMTP id o2mr46235235vcy.8.1402605894778; Thu, 12 Jun 2014 13:44:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.30.227 with HTTP; Thu, 12 Jun 2014 13:44:32 -0700 (PDT) From: Andrew Sutton Date: Thu, 12 Jun 2014 16:44:32 -0400 Message-ID: Subject: partial-concept-ids To: gcc-patches , Jason Merrill , Braden Obrzut Add support for partial concept ids. Mostly this just refactors the basic support for concept names to also allow a template and extra arguments. Also added the missing .exp file for the test suite. 2014-06-12 Andrew Sutton * gcc/cp/constraint.cc (deduce_constrained_parameter): Refactor common deduction framework into separate function. (build_call_check): New. (build_concept_check): Take additional arguments to support the creation of constrained-type-specifiers from partial-concept-ids. (build_constrained_parameter): Take arguments from a partial-concept-id. * gcc/cp/cp-tree.h (build_concept_check, biuld_constrained_parameter): Take a template argument list, defaulting to NULL_TREE. * gcc/cp/parser.c (cp_parser_template_id): Check to see if a template-id is a concept check. (cp_check_type_concept): Reorder arguments (cp_parser_allows_constrained_type_specifier): New. Check contexts where a constrained-type-specifier is allowed. (cp_maybe_constrained_type_specifier): New. Refactored common rules for concept name checks. (cp_maybe_partial_concept_id): New. Check for constrained-type-specifiers. * gcc/testuite/g++.dg/concepts/partial.C: New tests. * gcc/testuite/g++.dg/concepts/partial-err.C: New tests. * gcc/testuite/g++.dg/concepts/concepts.exp: Add missing test driver. Andrew Sutton Index: partial-err.C =================================================================== --- partial-err.C (revision 0) +++ partial-err.C (revision 0) @@ -0,0 +1,21 @@ +// { dg-options "-std=c++1y" } + +template + concept bool Type() { return true; } + +template + concept bool Same() { return __is_same_as(T, U); } + +template T> struct S1 { }; +template U> struct S2 { }; + +void f(Same q) { } +void g(Type a, Same b) { } + +int main() { + S1 s1; // { dg-error "deduction|invalid" } + S2 s2; // { dg-error "deduction|invalid" } + + f('a'); // { dg-error "matching" } + g(0, 'a'); // { dg-error "matching" } +} Index: concepts.exp =================================================================== --- concepts.exp (revision 0) +++ concepts.exp (revision 0) @@ -0,0 +1,35 @@ +# Copyright (C) 2002-2013 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib g++-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CXXFLAGS +if ![info exists DEFAULT_CXXFLAGS] then { + set DEFAULT_CXXFLAGS " -pedantic-errors -Wno-long-long" +} + +# Initialize `dg'. +dg-init + +# Main loop. +g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] $DEFAULT_CXXFLAGS + +# All done. +dg-finish Index: partial.C =================================================================== --- partial.C (revision 0) +++ partial.C (revision 0) @@ -0,0 +1,33 @@ +// { dg-options "-std=c++1y" } + +template + concept bool Type() { return true; } + +template + concept bool Same() { return __is_same_as(T, U); } + +template + concept bool C1() { return true; } + +template + concept bool C2() { return true; } + +template T> struct S1 { }; +template U> struct S2 { }; + +void f(Same q) { } +void g(Type a, Same b) { } + +void h0(Same* a) { } +void h1(C1* a) { } +void h2(C2* a) { } + +int main() { + S1 s1; + S2 s2; + f(0); + g(0, 1); + h0((int*)0); + h1((int*)0); + h2((int*)0); +}