public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55582] New: [C++11] Unable to define string user-defined literal without leading underscore.
@ 2012-12-03 22:57 3dw4rd at verizon dot net
  2012-12-04  0:35 ` [Bug c++/55582] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: 3dw4rd at verizon dot net @ 2012-12-03 22:57 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55582

             Bug #: 55582
           Summary: [C++11] Unable to define string user-defined literal
                    without leading underscore.
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: 3dw4rd@verizon.net


This bug is brought to you by the letter 's'.

Now that PR54413 is fixed I tried to implement the user-defined literal
suffixes proposed by Peter Sommerlad in his paper n3468.pdf

I ran into trouble with the string literal suffix 's'.  The hangup is the
-Wliteral-suffix flag which was added for PR52538 in 2012-04-27 by Ollie Wild
aww@google.com which treats any character or string suffix that does *not*
start with '_' as a separate token.  This to fix broken code with printing
macros in inttype.h.

With the paper presented by Peter Sommerlad above, the suffix 's' is proposed
to create std::string, etc.  This wont work with the tokenization introduced
for PR52538.

Basically, I think some deal needs to be struck and could be struck here.

I see five possibilities:
 * let the letter 's' go by as a user-defined literal (with appropriate
comment)
 * If the macros in  are all upper case we could let lower case suffixes go.
 * We could try to figure out if a suffix has been defined as a literal and let
   those through.
 * All the inttype.h macros start with PRI or SCN AFAICS.  Just split those.
 * This problem is above my pay grade.

Test case is forthcoming.

Ideas?

Ed


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

* [Bug c++/55582] [C++11] Unable to define string user-defined literal without leading underscore.
  2012-12-03 22:57 [Bug c++/55582] New: [C++11] Unable to define string user-defined literal without leading underscore 3dw4rd at verizon dot net
@ 2012-12-04  0:35 ` redi at gcc dot gnu.org
  2012-12-05 13:19 ` 3dw4rd at verizon dot net
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2012-12-04  0:35 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55582

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-12-04 00:35:24 UTC ---
(In reply to comment #0)
>  * let the letter 's' go by as a user-defined literal (with appropriate
> comment)

IMHO special cases to allow std-defined literals would make sense.


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

* [Bug c++/55582] [C++11] Unable to define string user-defined literal without leading underscore.
  2012-12-03 22:57 [Bug c++/55582] New: [C++11] Unable to define string user-defined literal without leading underscore 3dw4rd at verizon dot net
  2012-12-04  0:35 ` [Bug c++/55582] " redi at gcc dot gnu.org
@ 2012-12-05 13:19 ` 3dw4rd at verizon dot net
  2012-12-05 13:23 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: 3dw4rd at verizon dot net @ 2012-12-05 13:19 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55582

--- Comment #2 from Ed Smith-Rowland <3dw4rd at verizon dot net> 2012-12-05 13:18:36 UTC ---
Created attachment 28882
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28882
Patch

This patch lexes "string"XYZ user-defined literals as *two* tokens if the
suffix starts with a letter unless the letter is a lower-case 's'.  i.e. don't
parse as a user-defined literal but as a sequence of string and macro unless
starts with lower case 's'.

The original code parsed all string literals not beginning with any letter as a
sequence of string and macro.


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

* [Bug c++/55582] [C++11] Unable to define string user-defined literal without leading underscore.
  2012-12-03 22:57 [Bug c++/55582] New: [C++11] Unable to define string user-defined literal without leading underscore 3dw4rd at verizon dot net
  2012-12-04  0:35 ` [Bug c++/55582] " redi at gcc dot gnu.org
  2012-12-05 13:19 ` 3dw4rd at verizon dot net
@ 2012-12-05 13:23 ` paolo.carlini at oracle dot com
  2012-12-05 13:45 ` 3dw4rd at verizon dot net
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-05 13:23 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55582

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-05 13:23:24 UTC ---
Note that std::u16string and std::u32string aren't unconditionally available, I
think you need something like:

// { dg-require-effective-target stdint_types }


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

* [Bug c++/55582] [C++11] Unable to define string user-defined literal without leading underscore.
  2012-12-03 22:57 [Bug c++/55582] New: [C++11] Unable to define string user-defined literal without leading underscore 3dw4rd at verizon dot net
                   ` (2 preceding siblings ...)
  2012-12-05 13:23 ` paolo.carlini at oracle dot com
@ 2012-12-05 13:45 ` 3dw4rd at verizon dot net
  2012-12-09  0:37 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: 3dw4rd at verizon dot net @ 2012-12-05 13:45 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55582

Ed Smith-Rowland <3dw4rd at verizon dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #28882|0                           |1
        is obsolete|                            |

--- Comment #4 from Ed Smith-Rowland <3dw4rd at verizon dot net> 2012-12-05 13:45:26 UTC ---
Created attachment 28883
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28883
New patch adds dg-require-effective-target stdint_types to test.

Done.  Thanks.

Built and tested on x86_64-linux.


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

* [Bug c++/55582] [C++11] Unable to define string user-defined literal without leading underscore.
  2012-12-03 22:57 [Bug c++/55582] New: [C++11] Unable to define string user-defined literal without leading underscore 3dw4rd at verizon dot net
                   ` (3 preceding siblings ...)
  2012-12-05 13:45 ` 3dw4rd at verizon dot net
@ 2012-12-09  0:37 ` pinskia at gcc dot gnu.org
  2013-02-14  2:56 ` emsr at gcc dot gnu.org
  2013-02-26 18:27 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-12-09  0:37 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55582

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-12-09
     Ever Confirmed|0                           |1

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-12-09 00:37:26 UTC ---
.


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

* [Bug c++/55582] [C++11] Unable to define string user-defined literal without leading underscore.
  2012-12-03 22:57 [Bug c++/55582] New: [C++11] Unable to define string user-defined literal without leading underscore 3dw4rd at verizon dot net
                   ` (4 preceding siblings ...)
  2012-12-09  0:37 ` pinskia at gcc dot gnu.org
@ 2013-02-14  2:56 ` emsr at gcc dot gnu.org
  2013-02-26 18:27 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: emsr at gcc dot gnu.org @ 2013-02-14  2:56 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55582

--- Comment #6 from emsr at gcc dot gnu.org 2013-02-14 02:55:48 UTC ---
Author: emsr
Date: Thu Feb 14 02:55:42 2013
New Revision: 196041

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196041
Log:
gcc/libcpp/

2013-02-13  Ed Smith-Rowland  <3dw4rd@verizon.net>

    PR c++/55582
    * libcpp/lex.c (lex_raw_string): Allow string literal with suffix
    beginning with 's' to be parsed as a C++11 user-defined literal.


gcc/testsuite/

2013-02-13  Ed Smith-Rowland  <3dw4rd@verizon.net>

    PR c++/55582
    * g++.dg/cpp0x/udlit-string-literal.h: New.
    * g++.dg/cpp0x/udlit-string-literal.C: New.


Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.C
    trunk/gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libcpp/ChangeLog
    trunk/libcpp/lex.c


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

* [Bug c++/55582] [C++11] Unable to define string user-defined literal without leading underscore.
  2012-12-03 22:57 [Bug c++/55582] New: [C++11] Unable to define string user-defined literal without leading underscore 3dw4rd at verizon dot net
                   ` (5 preceding siblings ...)
  2013-02-14  2:56 ` emsr at gcc dot gnu.org
@ 2013-02-26 18:27 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2013-02-26 18:27 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55582

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|jason at redhat dot com     |jason at gcc dot gnu.org
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.0

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2013-02-26 18:27:14 UTC ---
Fixed for 4.8.


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

end of thread, other threads:[~2013-02-26 18:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-03 22:57 [Bug c++/55582] New: [C++11] Unable to define string user-defined literal without leading underscore 3dw4rd at verizon dot net
2012-12-04  0:35 ` [Bug c++/55582] " redi at gcc dot gnu.org
2012-12-05 13:19 ` 3dw4rd at verizon dot net
2012-12-05 13:23 ` paolo.carlini at oracle dot com
2012-12-05 13:45 ` 3dw4rd at verizon dot net
2012-12-09  0:37 ` pinskia at gcc dot gnu.org
2013-02-14  2:56 ` emsr at gcc dot gnu.org
2013-02-26 18:27 ` jason at gcc dot gnu.org

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).