public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] C++: Fix PR86083
@ 2018-06-20 11:41 Andreas Krebbel
  2018-06-20 15:05 ` Jason Merrill
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andreas Krebbel @ 2018-06-20 11:41 UTC (permalink / raw)
  To: gcc-patches

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  <krebbel@linux.ibm.com>

	PR C++/86082
	* parser.c (make_char_string_pack):
	(cp_parser_userdef_numeric_literal):

gcc/testsuite/ChangeLog:

2018-06-20  Andreas Krebbel  <krebbel@linux.ibm.com>

	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 <char... p> void q();
+template <> void q<'1','2','3'>() {}
+
+template <char... p> void operator""_test() { q<p...> (); }
+
+int
+main ()
+{
+  123_test;
+}
-- 
2.9.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] C++: Fix PR86083
  2018-06-20 11:41 [PATCH] C++: Fix PR86083 Andreas Krebbel
@ 2018-06-20 15:05 ` Jason Merrill
  2018-06-26  9:17 ` Rainer Orth
  2018-07-06  7:20 ` Andreas Krebbel
  2 siblings, 0 replies; 6+ messages in thread
From: Jason Merrill @ 2018-06-20 15:05 UTC (permalink / raw)
  To: Andreas Krebbel; +Cc: gcc-patches List

On Wed, Jun 20, 2018 at 7:41 AM, Andreas Krebbel
<krebbel@linux.vnet.ibm.com> wrote:
> 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  <krebbel@linux.ibm.com>
>
>         PR C++/86082
>         * parser.c (make_char_string_pack):
>         (cp_parser_userdef_numeric_literal):

You're missing a description of the changes.  OK with that corrected.

Jason

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] C++: Fix PR86083
  2018-06-20 11:41 [PATCH] C++: Fix PR86083 Andreas Krebbel
  2018-06-20 15:05 ` Jason Merrill
@ 2018-06-26  9:17 ` Rainer Orth
  2018-06-26  9:19   ` Andreas Krebbel
  2018-07-06  7:20 ` Andreas Krebbel
  2 siblings, 1 reply; 6+ messages in thread
From: Rainer Orth @ 2018-06-26  9:17 UTC (permalink / raw)
  To: Andreas Krebbel; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 824 bytes --]

Hi Andreas,

> 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?

the new testcase FAILs on Solaris

FAIL: g++.dg/pr86082.C   (test for excess errors)

Excess errors:
cc1plus: error: conversion from UTF-8 to IBM1047 not supported by iconv

and, according to gcc-testresults, on powerpc-ibm-aix7.2.0.0.

Fixed as follows, tested on i386-pc-solaris2.11, installed on mainline.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2018-06-26  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* g++.dg/pr86082.C: Require IBM1047 support.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: testsuite-pr86082-ibm1047.patch --]
[-- Type: text/x-patch, Size: 474 bytes --]

# HG changeset patch
# Parent  eeab29b53ad0ae8a16bb9e8d4d0f934e9d5ebebe
Require IBM1047 support in g++.dg/pr86082.C

diff --git a/gcc/testsuite/g++.dg/pr86082.C b/gcc/testsuite/g++.dg/pr86082.C
--- a/gcc/testsuite/g++.dg/pr86082.C
+++ b/gcc/testsuite/g++.dg/pr86082.C
@@ -1,4 +1,5 @@
 /* { dg-do link } */
+/* { dg-require-iconv "IBM1047" } */
 /* { dg-options "-fexec-charset=IBM1047 -std=c++11" } */
 
 /* When turning 123_test into an operator invocation the literal 123

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] C++: Fix PR86083
  2018-06-26  9:17 ` Rainer Orth
@ 2018-06-26  9:19   ` Andreas Krebbel
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Krebbel @ 2018-06-26  9:19 UTC (permalink / raw)
  To: Rainer Orth, Andreas Krebbel; +Cc: gcc-patches

On 06/26/2018 11:17 AM, Rainer Orth wrote:
> Hi Andreas,
> 
>> 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?
> 
> the new testcase FAILs on Solaris
> 
> FAIL: g++.dg/pr86082.C   (test for excess errors)
> 
> Excess errors:
> cc1plus: error: conversion from UTF-8 to IBM1047 not supported by iconv
> 
> and, according to gcc-testresults, on powerpc-ibm-aix7.2.0.0.
> 
> Fixed as follows, tested on i386-pc-solaris2.11, installed on mainline.

Thanks for fixing it!

-Andreas-

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] C++: Fix PR86083
  2018-06-20 11:41 [PATCH] C++: Fix PR86083 Andreas Krebbel
  2018-06-20 15:05 ` Jason Merrill
  2018-06-26  9:17 ` Rainer Orth
@ 2018-07-06  7:20 ` Andreas Krebbel
  2018-07-08 12:45   ` Jason Merrill
  2 siblings, 1 reply; 6+ messages in thread
From: Andreas Krebbel @ 2018-07-06  7:20 UTC (permalink / raw)
  To: gcc-patches

On 06/20/2018 01:41 PM, Andreas Krebbel wrote:
> 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  <krebbel@linux.ibm.com>
> 
> 	PR C++/86082
> 	* parser.c (make_char_string_pack):
> 	(cp_parser_userdef_numeric_literal):
> 
> gcc/testsuite/ChangeLog:
> 
> 2018-06-20  Andreas Krebbel  <krebbel@linux.ibm.com>
> 
> 	PR C++/86082
> 	* g++.dg/pr86082.C: New test.

I've tested the patch also on GCC 7 and 8 branch. Ok to apply there as well?

The backport will include the testcase fix from Rainer:
https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01601.html

-Andreas-

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] C++: Fix PR86083
  2018-07-06  7:20 ` Andreas Krebbel
@ 2018-07-08 12:45   ` Jason Merrill
  0 siblings, 0 replies; 6+ messages in thread
From: Jason Merrill @ 2018-07-08 12:45 UTC (permalink / raw)
  To: Andreas Krebbel; +Cc: gcc-patches List

On Fri, Jul 6, 2018 at 5:20 PM, Andreas Krebbel <krebbel@linux.ibm.com> wrote:
> On 06/20/2018 01:41 PM, Andreas Krebbel wrote:
>> 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  <krebbel@linux.ibm.com>
>>
>>       PR C++/86082
>>       * parser.c (make_char_string_pack):
>>       (cp_parser_userdef_numeric_literal):
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2018-06-20  Andreas Krebbel  <krebbel@linux.ibm.com>
>>
>>       PR C++/86082
>>       * g++.dg/pr86082.C: New test.
>
> I've tested the patch also on GCC 7 and 8 branch. Ok to apply there as well?

Hmm, it seems safe enough, but also seems like a change with a limited
audience.  Would it work for you to include the patch just in your
builds of GCC 7 and 8?

Jason

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-08 12:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-20 11:41 [PATCH] C++: Fix PR86083 Andreas Krebbel
2018-06-20 15:05 ` Jason Merrill
2018-06-26  9:17 ` Rainer Orth
2018-06-26  9:19   ` Andreas Krebbel
2018-07-06  7:20 ` Andreas Krebbel
2018-07-08 12:45   ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).