From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108299 invoked by alias); 31 May 2019 19:06:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 108233 invoked by uid 89); 31 May 2019 19:06:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=van, H*RU:sk:mail.gi, H*F:D*nl, H*r:sk:mail.gi X-HELO: mail.gigawatt.nl Received: from mail.gigawatt.nl (HELO mail.gigawatt.nl) (51.68.198.76) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 31 May 2019 19:06:44 +0000 Received: from [192.168.43.159] (188.29.164.212.threembb.co.uk [188.29.164.212]) by mail.gigawatt.nl (Postfix) with ESMTPSA id BC197451 for ; Fri, 31 May 2019 21:06:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.gigawatt.nl BC197451 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gigawatt.nl; s=default; t=1559329602; bh=CLARWNZa+02Q4Za3XrCTm0UtAhJI7NsH3W7R9SY+qJI=; h=Subject:From:To:References:Date:In-Reply-To:From; b=fQeiMGRC5H+yLJMEFfjNzqHEjfW2SEf3sIJWmxm83AgByu2wur+zHfgPsZ5LiQDtF 1EXb+C4s2RvxDJY3bmakEXbxvnc/NcZc3xomO8e9P6kUsYT3nVHbwcOhlMBi33Wn+7 2Lc2wFShFSTtAHqBzcwNy3xH7mpT/gtVi7yq3p4Q= Subject: [C++ PATCH, PING^3] PR60531 - Wrong error about unresolved overloaded function From: Harald van Dijk To: gcc-patches@gcc.gnu.org References: <483341a8-e487-5032-b918-641f001c1172@gigawatt.nl> <0c999e4a-8d9c-d77f-cc0d-662b1e72f9fc@gigawatt.nl> Message-ID: Date: Fri, 31 May 2019 19:17:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Thunderbird/67.0 MIME-Version: 1.0 In-Reply-To: <0c999e4a-8d9c-d77f-cc0d-662b1e72f9fc@gigawatt.nl> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2019-05/txt/msg02164.txt.bz2 another ping On 12/05/2019 17:57, Harald van Dijk wrote: > ping again > > On 26/04/2019 19:58, Harald van Dijk wrote: >> ping >> >> On 13/04/2019 10:01, Harald van Dijk wrote: >>> Hi, >>> >>> For PR60531, GCC wrongly rejects function templates with explicitly >>> specified template arguments as overloaded. They are resolved by >>> resolve_nondeduced_context, which is normally called by >>> cp_default_conversion through decay_conversion, but the latter have >>> extra effects making them unusable here. Calling the former directly >>> does work. >>> >>> Bootstrapped on x86_64-pc-linux-gnu on top of r270264 with >>> --enable-languages=all; make check shows no regressions. >>> >>> Does this look okay? >>> >>> This is my first code contribution to GCC, please let me know if >>> anything is missing. I have not signed any copyright disclaimer or >>> copyright assignment; says that is not necessary >>> for small changes, which I trust this is. If it is needed after all, >>> please let me know what specifically will be required. >>> >>> Cheers, >>> Harald van Dijk >>> >>>      PR c++/60531 >>>      * typeck.c (cp_build_binary_op): See if overload can be resolved. >>>      (cp_build_unary_op): Ditto. >>> >>>      * g++.dg/template/operator15.C: New test. >>> >>> diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c >>> index 03b14024738..e1ffe88ce2c 100644 >>> --- a/gcc/cp/typeck.c >>> +++ b/gcc/cp/typeck.c >>> @@ -4384,10 +4384,6 @@ cp_build_binary_op (const op_location_t &location, >>>     /* True if both operands have arithmetic type.  */ >>>     bool arithmetic_types_p; >>> >>> -  /* Apply default conversions.  */ >>> -  op0 = orig_op0; >>> -  op1 = orig_op1; >>> - >>>     /* Remember whether we're doing / or %.  */ >>>     bool doing_div_or_mod = false; >>> >>> @@ -4397,6 +4393,10 @@ cp_build_binary_op (const op_location_t &location, >>>     /* Tree holding instrumentation expression.  */ >>>     tree instrument_expr = NULL_TREE; >>> >>> +  /* Apply default conversions.  */ >>> +  op0 = resolve_nondeduced_context (orig_op0, complain); >>> +  op1 = resolve_nondeduced_context (orig_op1, complain); >>> + >>>     if (code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR >>>         || code == TRUTH_OR_EXPR || code == TRUTH_ORIF_EXPR >>>         || code == TRUTH_XOR_EXPR) >>> @@ -6204,11 +6204,13 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert, >>>     if (!arg || error_operand_p (arg)) >>>       return error_mark_node; >>> >>> +  arg = resolve_nondeduced_context (arg, complain); >>> + >>>     if ((invalid_op_diag >>>          = targetm.invalid_unary_op ((code == UNARY_PLUS_EXPR >>>                       ? CONVERT_EXPR >>>                       : code), >>> -                   TREE_TYPE (xarg)))) >>> +                   TREE_TYPE (arg)))) >>>       { >>>         if (complain & tf_error) >>>       error (invalid_op_diag); >>> diff --git a/gcc/testsuite/g++.dg/template/operator15.C b/gcc/testsuite/g++.dg/template/operator15.C >>> new file mode 100644 >>> index 00000000000..755442266bb >>> --- /dev/null >>> +++ b/gcc/testsuite/g++.dg/template/operator15.C >>> @@ -0,0 +1,6 @@ >>> +// PR c++/60531 >>> + >>> +template < class T > T foo (); >>> + >>> +bool b1 = foo == foo; >>> +int (*fp1)() = +foo; >>>