From patchwork Fri Aug 22 17:53:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 382309 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 BA5CD1400B7 for ; Sat, 23 Aug 2014 03:53:51 +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 :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=bwseVUCNXbyQGiRTaVNIiC7iyh+D1pTEe4UlBYi20TT Kz0Db09ZCpPzvNJ51zm72brOwIDxG9wTp7IouBtHSqYxFk0D+vvJXe/coGOckGt3 aQXcCRker+sUTMG1M0QFAHFSA8SF3EiUYr1eoG0YOEqCpVBe4TFsE2G4N1f0nCvU = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=qstkSFY+3h0+4x7omhgJkkco4EA=; b=cswrgCyfhbhPR5LGZ i9UP1lNnA1ZzorMBYAaILCJrogN49ckQ8xqNJYyk0tujezYUMbR6Mueae39jgw3P BP8te/ReWzzYS6RW8Js4t6W1mVnd38fSrY00eC0P0XY4vk19i1N4DOZHO6l9jXXi 23M0Q9RbfWau7+PMEQaq64NxTA= Received: (qmail 3185 invoked by alias); 22 Aug 2014 17:53:39 -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 3022 invoked by uid 89); 22 Aug 2014 17:53:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 22 Aug 2014 17:53:37 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s7MHrYHE012827 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 22 Aug 2014 17:53:35 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s7MHrYiG018248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 22 Aug 2014 17:53:34 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s7MHrW1v027707; Fri, 22 Aug 2014 17:53:32 GMT Received: from [192.168.1.4] (/79.12.211.101) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 Aug 2014 10:53:31 -0700 Message-ID: <53F78398.2000908@oracle.com> Date: Fri, 22 Aug 2014 19:53:28 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ RFC/Patch] PR 34938 X-IsSubscribed: yes Hi, maybe this old issue is already fixed. We used to ICE on: typedef void (*fptr)() __attribute((noreturn)); template void foo(); template void bar(); fptr f = bar< foo<0> >; but lately we simply reject it: 34938.C:5:10: error: no matches converting function ‘bar’ to type ‘fptr {aka void (*)() volatile}’ fptr f = bar< foo<0> >; ^ 34938.C:3:21: note: candidate is: template)() volatile> void bar() template void bar(); ^ is that Ok? clang behaves like us, EDG accepts the code. A secondary issue I noticed is that we print 'volatile' instead of the attribute, that is fixed by the patchlet below. Thanks, Paolo. ////////////////////////// Index: c/c-objc-common.c =================================================================== --- c/c-objc-common.c (revision 214335) +++ c/c-objc-common.c (working copy) @@ -165,7 +165,8 @@ c_tree_printer (pretty_printer *pp, text_info *tex return true; case 'v': - pp_c_cv_qualifiers (cpp, va_arg (*text->args_ptr, int), hash); + pp_c_cv_qualifiers (cpp, va_arg (*text->args_ptr, int), hash, + /*method_type*/false); return true; default: Index: c-family/c-pretty-print.c =================================================================== --- c-family/c-pretty-print.c (revision 214335) +++ c-family/c-pretty-print.c (working copy) @@ -168,7 +168,8 @@ pp_c_exclamation (c_pretty_printer *pp) /* Print out the external representation of QUALIFIERS. */ void -pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type) +pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, + bool func_type, bool method_type) { const char *p = pp_last_position_in_text (pp); bool previous = false; @@ -192,7 +193,8 @@ void { if (previous) pp_c_whitespace (pp); - pp_c_ws_string (pp, func_type ? "__attribute__((const))" : "const"); + pp_c_ws_string (pp, (func_type && !method_type + ? "__attribute__((const))" : "const")); previous = true; } @@ -200,7 +202,8 @@ void { if (previous) pp_c_whitespace (pp); - pp_c_ws_string (pp, func_type ? "__attribute__((noreturn))" : "volatile"); + pp_c_ws_string (pp, (func_type || method_type + ? "__attribute__((noreturn))" : "volatile")); previous = true; } @@ -273,7 +276,8 @@ pp_c_type_qualifier_list (c_pretty_printer *pp, tr qualifiers = TYPE_QUALS (t); pp_c_cv_qualifiers (pp, qualifiers, - TREE_CODE (t) == FUNCTION_TYPE); + TREE_CODE (t) == FUNCTION_TYPE, + TREE_CODE (t) == METHOD_TYPE); if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (t))) { Index: c-family/c-pretty-print.h =================================================================== --- c-family/c-pretty-print.h (revision 214335) +++ c-family/c-pretty-print.h (working copy) @@ -119,7 +119,8 @@ void pp_c_tree_decl_identifier (c_pretty_printer * void pp_c_function_definition (c_pretty_printer *, tree); void pp_c_attributes (c_pretty_printer *, tree); void pp_c_attributes_display (c_pretty_printer *, tree); -void pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type); +void pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, + bool func_type, bool method_type); void pp_c_type_qualifier_list (c_pretty_printer *, tree); void pp_c_parameter_type_list (c_pretty_printer *, tree); void pp_c_specifier_qualifier_list (c_pretty_printer *, tree); Index: cp/cxx-pretty-print.h =================================================================== --- cp/cxx-pretty-print.h (revision 214335) +++ cp/cxx-pretty-print.h (working copy) @@ -59,8 +59,8 @@ struct cxx_pretty_printer : c_pretty_printer #define pp_cxx_cv_qualifier_seq(PP, T) \ pp_c_type_qualifier_list (PP, T) -#define pp_cxx_cv_qualifiers(PP, CV) \ - pp_c_cv_qualifiers (PP, CV, false) +#define pp_cxx_cv_qualifiers(PP, CV, FT, MT) \ + pp_c_cv_qualifiers (PP, CV, FT, MT) #define pp_cxx_whitespace(PP) pp_c_whitespace (PP) #define pp_cxx_left_paren(PP) pp_c_left_paren (PP) Index: cp/error.c =================================================================== --- cp/error.c (revision 214335) +++ cp/error.c (working copy) @@ -839,7 +839,9 @@ dump_type_suffix (cxx_pretty_printer *pp, tree t, dump_parameters (pp, arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS); pp->padding = pp_before; - pp_cxx_cv_qualifiers (pp, type_memfn_quals (t)); + pp_cxx_cv_qualifiers (pp, type_memfn_quals (t), + TREE_CODE (t) == FUNCTION_TYPE, + TREE_CODE (t) == METHOD_TYPE); dump_ref_qualifier (pp, t, flags); dump_exception_spec (pp, TYPE_RAISES_EXCEPTIONS (t), flags); dump_type_suffix (pp, TREE_TYPE (t), flags);