From patchwork Wed Jun 20 11:41:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Krebbel X-Patchwork-Id: 932113 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480096-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="VKGAxYBp"; dkim-atps=neutral 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 419jbF109fz9s8J for ; Wed, 20 Jun 2018 21:41:27 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id; q=dns; s=default; b=i13/Kr74FsM9amn AO0a75t+ebrHUi+9otjhOyrLvGXwePyqRBVeWCJA1TJUnoILJsBzMkKJOqyfUy7F 8aAbuPML3hvU3iLkGNY0sLhxdR4mpCz132ircVfw6TPZ4KtCZqINhEZwD6TXR64L L/d+3NzvHMFDClpl+PonY+ZSdYXc= 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:from :to:subject:date:message-id; s=default; bh=HAW036/aDJgZCnKoJChzU t1I2Q4=; b=VKGAxYBpvpZThc1Vq/KQqao9kH/Ab+0+roXsTW9EOB7MBvOCo66UT aZfOn0LJJ862YcHHqy0G6UM3c76rUJrmUfrbM0M8GqbtSwe+kAZM2ElQkk9Y6qaY Q6tCYesoRNFEf0Dl/vyJ2uNBYfCTkeXOBuhs75i6AqzXRzPuks2Og4= Received: (qmail 35778 invoked by alias); 20 Jun 2018 11:41:20 -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 35764 invoked by uid 89); 20 Jun 2018 11:41:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=sk:tf_warn, error_mark_node X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Jun 2018 11:41:16 +0000 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5KBdAIX020815 for ; Wed, 20 Jun 2018 07:41:15 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jqmbtw5et-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Jun 2018 07:41:14 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Jun 2018 12:41:12 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 20 Jun 2018 12:41:08 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5KBf7rK36241654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 20 Jun 2018 11:41:07 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1FA814C040 for ; Wed, 20 Jun 2018 12:32:07 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 050AF4C046 for ; Wed, 20 Jun 2018 12:32:07 +0100 (BST) Received: from maggie.boeblingen.de.ibm.com (unknown [9.152.212.112]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS for ; Wed, 20 Jun 2018 12:32:06 +0100 (BST) From: Andreas Krebbel To: gcc-patches@gcc.gnu.org Subject: [PATCH] C++: Fix PR86083 Date: Wed, 20 Jun 2018 13:41:07 +0200 X-TM-AS-GCONF: 00 x-cbid: 18062011-0028-0000-0000-000002D2EA1C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062011-0029-0000-0000-0000238A2EAB Message-Id: <20180620114107.11570-1-krebbel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-20_05:, , signatures=0 X-IsSubscribed: yes When turning a user-defined numerical literal into an operator invocation the literal needs to be translated to the execution character set. Bootstrapped and regtested on s390x. x86_64 still running. Ok to apply if x86_64 is clean? Bye, -Andreas- gcc/cp/ChangeLog: 2018-06-20 Andreas Krebbel PR C++/86082 * parser.c (make_char_string_pack): (cp_parser_userdef_numeric_literal): gcc/testsuite/ChangeLog: 2018-06-20 Andreas Krebbel PR C++/86082 * g++.dg/pr86082.C: New test. --- gcc/cp/parser.c | 17 ++++++++++++++++- gcc/testsuite/g++.dg/pr86082.C | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/pr86082.C diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index c6206fc..9522861 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -4291,7 +4291,16 @@ make_char_string_pack (tree value) /* Fill in CHARVEC with all of the parameters. */ charvec = make_tree_vec (len); for (i = 0; i < len; ++i) - TREE_VEC_ELT (charvec, i) = build_int_cst (char_type_node, str[i]); + { + unsigned char s[3] = { '\'', str[i], '\'' }; + cpp_string in = { 3, s }; + cpp_string out = { 0, 0 }; + if (!cpp_interpret_string (parse_in, &in, 1, &out, CPP_STRING)) + return NULL_TREE; + gcc_assert (out.len == 2); + TREE_VEC_ELT (charvec, i) = build_int_cst (char_type_node, + out.text[0]); + } /* Build the argument packs. */ SET_ARGUMENT_PACK_ARGS (argpack, charvec); @@ -4407,6 +4416,12 @@ cp_parser_userdef_numeric_literal (cp_parser *parser) if (decl && decl != error_mark_node) { tree tmpl_args = make_char_string_pack (num_string); + if (tmpl_args == NULL_TREE) + { + error ("failed to translate literal to execution character set %qT", + num_string); + return error_mark_node; + } decl = lookup_template_function (decl, tmpl_args); result = finish_call_expr (decl, &args, false, true, tf_warning_or_error); diff --git a/gcc/testsuite/g++.dg/pr86082.C b/gcc/testsuite/g++.dg/pr86082.C new file mode 100644 index 0000000..c7247cd --- /dev/null +++ b/gcc/testsuite/g++.dg/pr86082.C @@ -0,0 +1,18 @@ +/* { dg-do link } */ +/* { dg-options "-fexec-charset=IBM1047 -std=c++11" } */ + +/* When turning 123_test into an operator invocation the literal 123 + needs to be translated to the execution character set. Failing to + do so results in a link error since '1', '2', and '3' in the + specialization will be translated as string literals. */ + +template void q(); +template <> void q<'1','2','3'>() {} + +template void operator""_test() { q (); } + +int +main () +{ + 123_test; +}