[LLVMbugs] [Bug 12383] New: Lexer chokes on token-pasted string in C++11 mode

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Mar 28 02:49:10 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12383

             Bug #: 12383
           Summary: Lexer chokes on token-pasted string in C++11 mode
           Product: clang
           Version: trunk
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: johnw at boostpro.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


This bug just recently popped:

#define bar(x) #x
const char * f() {
  return "foo"bar("bar")"baz";
}

This gives the following error:

bug.cpp:4:15: error: invalid suffix on literal; C++11 requires a space between 
literal and
      identifier [-Wreserved-user-defined-literal]
  return "foo"bar("bar")"baz";
              ^

1 error generated.

The error is caused by this new code in Lexer.cpp:

    // C++11 [lex.ext]p10, [usrlit.suffix]p1: A program containing a ud-suffix
    // that does not start with an underscore is ill-formed. As a conforming
    // extension, we treat all such suffixes as if they had whitespace before
    // them.
    if (C != '_') {
      if (!isLexingRawMode())
        Diag(CurPtr, diag::ext_reserved_user_defined_literal)
          << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " ");
      return CurPtr;
    }

Since the Windows SDK headers use this kind of construct, I think the error 
check is too restrictive.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list