[cfe-commits] r137298 - in /cfe/trunk: include/clang/Basic/DiagnosticLexKinds.td include/clang/Lex/Lexer.h include/clang/Lex/LiteralSupport.h lib/Lex/Lexer.cpp lib/Lex/LiteralSupport.cpp lib/Lex/TokenConcatenation.cpp test/CodeGen/string-literal.

Craig Topper craig.topper at gmail.com
Thu Aug 11 14:52:42 PDT 2011


On Thu, Aug 11, 2011 at 2:35 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> Hi,
>
> On Thu, August 11, 2011 05:06, Craig Topper wrote:
>> Author: ctopper
>> Date: Wed Aug 10 23:06:15 2011
>> New Revision: 137298
>>
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=137298&view=rev
>> Log:
>> Add support for C++0x raw string literals.
> [...]
>> Added: cfe/trunk/test/Lexer/cxx0x_raw_string_delim_length.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx0x_raw_string_del
>> im_length.cpp?rev=137298&view=auto
>> =============================================================================
>> =
>> --- cfe/trunk/test/Lexer/cxx0x_raw_string_delim_length.cpp (added)
>> +++ cfe/trunk/test/Lexer/cxx0x_raw_string_delim_length.cpp Wed Aug 10 23:06:15
>> 2011
>> @@ -0,0 +1,6 @@
>> +// RUN: %clang_cc1 -std=c++0x -E %s 2>&1 | grep 'error: raw string delimiter
>> longer than 16 characters' +
>> +const char *str =
>> R"abcdefghijkmnopqrstuvwxyz(abcdef)abcdefghijkmnopqrstuvwxyz";
>> +// RUN: %clang_cc1 -std=c++0x -E %s 2>&1 | grep 'error: raw string delimiter
>> longer than 16 characters' +
>> +const char *str =
>> R"abcdefghijkmnopqrstuvwxyz(abcdef)abcdefghijkmnopqrstuvwxyz";
>
> Using -verify rather than grep would be beneficial here to check we get a
> useful source location.

I originally did it this way because raw string lexing errors were
leaving the lexer lost which would have prevented it from finding the
comment needed for verify. I think now that we try to recover by
lexing up to the next quote, I might be able to fix this.

>
> Also, there are two copies of the contents of this file. Did a patch get
> applied twice?
>

That seems to have been an accident. I'll fix it tonight.

>> Added: cfe/trunk/test/Lexer/cxx0x_raw_string_unterminated.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx0x_raw_string_unt
>> erminated.cpp?rev=137298&view=auto
>> =============================================================================
>> =
>> --- cfe/trunk/test/Lexer/cxx0x_raw_string_unterminated.cpp (added)
>> +++ cfe/trunk/test/Lexer/cxx0x_raw_string_unterminated.cpp Wed Aug 10 23:06:15
>> 2011
>> @@ -0,0 +1,8 @@
>> +// RUN: %clang_cc1 -std=c++0x -E %s 2>&1 | grep 'error: raw string missing
>> terminating delimiter )foo"' +
>> +const char *str = R"foo(abc
>> +def)bar";
>> +// RUN: %clang_cc1 -std=c++0x -E %s 2>&1 | grep 'error: raw string missing
>> terminating delimiter )foo"' +
>> +const char *str = R"foo(abc
>> +def)bar";
>
> Likewise on both counts.
>
>> Modified: cfe/trunk/test/SemaCXX/cxx0x-type-convert-construct.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-type-convert
>> -construct.cpp?rev=137298&r1=137297&r2=137298&view=diff
>> ==============================================================================
>>  --- cfe/trunk/test/SemaCXX/cxx0x-type-convert-construct.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/cxx0x-type-convert-construct.cpp Wed Aug 10
>> 23:06:15 2011
>> @@ -7,4 +7,15 @@
>> ustr = u"a UTF-16 string"; // expected-error {{assigning to 'char16_t *' from
>> incompatible type 'const char16_t [16]'}} char32_t *Ustr; Ustr = U"a UTF-32
>> string"; // expected-error {{assigning to 'char32_t *' from incompatible type
>> 'const char32_t [16]'}}
>> +
>> +  char *Rstr;
>> +  Rstr = "a raw string"; // expected-warning{{conversion from string literal
>> to 'char *' is deprecated}} +  wchar_t *LRstr;
>
> Was this intended to be R"a raw string"?
>

Yes it was.

>> +  LRstr = LR"foo(a wide raw string)foo"; // expected-warning{{conversion from
>> string literal to 'wchar_t *' is deprecated}} +  char *u8Rstr;
>> +  u8Rstr = u8R"foo(a UTF-8 raw string)foo"; // expected-error {{assigning to
>> 'char *' from incompatible type 'const char [19]'}}
>> +  char16_t *uRstr;
>> +  uRstr = uR"foo(a UTF-16 raw string)foo"; // expected-error {{assigning to
>> 'char16_t *' from incompatible type 'const char16_t [20]'}}
>> +  char32_t *URstr;
>> +  URstr = UR"foo(a UTF-32 raw string)foo"; // expected-error {{assigning to
>> 'char32_t *' from incompatible type 'const char32_t [20]'}}
>> }
>
> Thanks,
> Richard
>
>



-- 
~Craig




More information about the cfe-commits mailing list