Thanks! On Thu, Jul 28, 2011 at 6:08 PM, Douglas Gregor <[email protected]> wrote: > Author: dgregor > Date: Thu Jul 28 20:08:54 2011 > New Revision: 136443 > > URL: http://llvm.org/viewvc/llvm-project?rev=136443&view=rev > Log: > This patch makes the string/character literal tests run in C, > C++98/03, and C++0x mode, from Craig Topper! > > Added: > cfe/trunk/test/SemaCXX/cxx0x-type-convert-construct.cpp (with props) > Modified: > cfe/trunk/test/CXX/lex/lex.literal/lex.ccon/p1.cpp > cfe/trunk/test/CodeGen/char-literal.c > cfe/trunk/test/CodeGen/string-literal.c > cfe/trunk/test/Parser/char-literal-printing.c > cfe/trunk/test/SemaCXX/type-convert-construct.cpp > > Modified: cfe/trunk/test/CXX/lex/lex.literal/lex.ccon/p1.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/lex/lex.literal/lex.ccon/p1.cpp?rev=136443&r1=136442&r2=136443&view=diff > ============================================================================== > --- cfe/trunk/test/CXX/lex/lex.literal/lex.ccon/p1.cpp (original) > +++ cfe/trunk/test/CXX/lex/lex.literal/lex.ccon/p1.cpp Thu Jul 28 20:08:54 > 2011 > @@ -1,5 +1,5 @@ > +// RUN: %clang_cc1 -fsyntax-only -verify %s > // RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s > -// Runs in c++0x mode so that char16_t and char32_t are available. > > // Check types of char literals > extern char a; > @@ -8,7 +8,9 @@ > extern __typeof('asdf') b; > extern wchar_t c; > extern __typeof(L'a') c; > +#if __cplusplus >= 201103L > extern char16_t d; > extern __typeof(u'a') d; > extern char32_t e; > extern __typeof(U'a') e; > +#endif > > Modified: cfe/trunk/test/CodeGen/char-literal.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/char-literal.c?rev=136443&r1=136442&r2=136443&view=diff > ============================================================================== > --- cfe/trunk/test/CodeGen/char-literal.c (original) > +++ cfe/trunk/test/CodeGen/char-literal.c Thu Jul 28 20:08:54 2011 > @@ -1,75 +1,93 @@ > -// RUN: %clang_cc1 -x c++ -std=c++0x -triple i386-unknown-unknown -emit-llvm > %s -o - | FileCheck %s > -// Runs in c++0x mode so that wchar_t, char16_t, and char32_t are available. > +// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | > FileCheck -check-prefix=C %s > +// RUN: %clang_cc1 -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | > FileCheck -check-prefix=C %s > +// RUN: %clang_cc1 -x c++ -std=c++0x -triple i386-unknown-unknown -emit-llvm > %s -o - | FileCheck -check-prefix=CPP0X %s > + > +#include <stddef.h> > > int main() { > - // CHECK: store i8 97 > + // CHECK-C: store i8 97 > + // CHECK-CPP0X: store i8 97 > char a = 'a'; > > // Should pick second character. > - // CHECK: store i8 98 > + // CHECK-C: store i8 98 > + // CHECK-CPP0X: store i8 98 > char b = 'ab'; > > - // CHECK: store i32 97 > + // CHECK-C: store i32 97 > + // CHECK-CPP0X: store i32 97 > wchar_t wa = L'a'; > > // Should pick second character. > - // CHECK: store i32 98 > + // CHECK-C: store i32 98 > + // CHECK-CPP0X: store i32 98 > wchar_t wb = L'ab'; > > - // CHECK: store i16 97 > +#if __cplusplus >= 201103L > + // CHECK-CPP0X: store i16 97 > char16_t ua = u'a'; > > // Should pick second character. > - // CHECK: store i16 98 > + // CHECK-CPP0X: store i16 98 > char16_t ub = u'ab'; > > - // CHECK: store i32 97 > + // CHECK-CPP0X: store i32 97 > char32_t Ua = U'a'; > > // Should pick second character. > - // CHECK: store i32 98 > + // CHECK-CPP0X: store i32 98 > char32_t Ub = U'ab'; > +#endif > > // Should pick last character and store its lowest byte. > // This does not match gcc, which takes the last character, converts it to > // utf8, and then picks the second-lowest byte of that (they probably store > // the utf8 in uint16_ts internally and take the lower byte of that). > - // CHECK: store i8 48 > + // CHECK-C: store i8 48 > + // CHECK-CPP0X: store i8 48 > char c = '\u1120\u0220\U00102030'; > > - // CHECK: store i32 61451 > + // CHECK-C: store i32 61451 > + // CHECK-CPP0X: store i32 61451 > wchar_t wc = L'\uF00B'; > > +#if __cplusplus >= 201103L > // -4085 == 0xf00b > - // CHECK: store i16 -4085 > + // CHECK-CPP0X: store i16 -4085 > char16_t uc = u'\uF00B'; > > - // CHECK: store i32 61451 > + // CHECK-CPP0X: store i32 61451 > char32_t Uc = U'\uF00B'; > +#endif > > - // CHECK: store i32 1110027 > + // CHECK-C: store i32 1110027 > + // CHECK-CPP0X: store i32 1110027 > wchar_t wd = L'\U0010F00B'; > > +#if __cplusplus >= 201103L > // Should take lower word of the 4byte UNC sequence. This does not match > // gcc. I don't understand what gcc does (it looks like it converts to > utf16, > // then takes the second (!) utf16 word, swaps the lower two nibbles, and > // stores that?). > - // CHECK: store i16 -4085 > + // CHECK-CPP0X: store i16 -4085 > char16_t ud = u'\U0010F00B'; // has utf16 encoding dbc8 dcb0 > > - // CHECK: store i32 1110027 > + // CHECK-CPP0X: store i32 1110027 > char32_t Ud = U'\U0010F00B'; > +#endif > > // Should pick second character. > - // CHECK: store i32 1110027 > + // CHECK-C: store i32 1110027 > + // CHECK-CPP0X: store i32 1110027 > wchar_t we = L'\u1234\U0010F00B'; > > +#if __cplusplus >= 201103L > // Should pick second character. > - // CHECK: store i16 -4085 > + // CHECK-CPP0X: store i16 -4085 > char16_t ue = u'\u1234\U0010F00B'; > > // Should pick second character. > - // CHECK: store i32 1110027 > + // CHECK-CPP0X: store i32 1110027 > char32_t Ue = U'\u1234\U0010F00B'; > - > +#endif > } > > Modified: cfe/trunk/test/CodeGen/string-literal.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/string-literal.c?rev=136443&r1=136442&r2=136443&view=diff > ============================================================================== > --- cfe/trunk/test/CodeGen/string-literal.c (original) > +++ cfe/trunk/test/CodeGen/string-literal.c Thu Jul 28 20:08:54 2011 > @@ -1,33 +1,42 @@ > -// RUN: %clang_cc1 -x c++ -std=c++0x -triple i386-unknown-unknown -emit-llvm > %s -o - | FileCheck %s > -// Runs in c++0x mode so that wchar_t, char16_t, and char32_t are available. > +// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | > FileCheck -check-prefix=C %s > +// RUN: %clang_cc1 -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | > FileCheck -check-prefix=C %s > +// RUN: %clang_cc1 -x c++ -std=c++0x -triple i386-unknown-unknown -emit-llvm > %s -o - | FileCheck -check-prefix=C %s > + > +#include <stddef.h> > > int main() { > - // CHECK: internal unnamed_addr constant [10 x i8] > c"abc\00\00\00\00\00\00\00", align 1 > + // CHECK-C: internal unnamed_addr constant [10 x i8] > c"abc\00\00\00\00\00\00\00", align 1 > + // CHECK-CPP0X: internal unnamed_addr constant [10 x i8] > c"abc\00\00\00\00\00\00\00", align 1 > char a[10] = "abc"; > > // This should convert to utf8. > - // CHECK: internal unnamed_addr constant [10 x i8] > c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1 > + // CHECK-C: internal unnamed_addr constant [10 x i8] > c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1 > + // CHECK-CPP0X: internal unnamed_addr constant [10 x i8] > c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1 > char b[10] = "\u1120\u0220\U00102030"; > > - // CHECK: private unnamed_addr constant [12 x i8] > c"A\00\00\00B\00\00\00\00\00\00\00", align 1 > + // CHECK-C: private unnamed_addr constant [12 x i8] > c"A\00\00\00B\00\00\00\00\00\00\00", align 1 > + // CHECK-CPP0X: private unnamed_addr constant [12 x i8] > c"A\00\00\00B\00\00\00\00\00\00\00", align 1 > const wchar_t *foo = L"AB"; > > - // CHECK: private unnamed_addr constant [12 x i8] > c"4\12\00\00\0B\F0\10\00\00\00\00\00", align 1 > + // CHECK-C: private unnamed_addr constant [12 x i8] > c"4\12\00\00\0B\F0\10\00\00\00\00\00", align 1 > + // CHECK-CPP0X: private unnamed_addr constant [12 x i8] > c"4\12\00\00\0B\F0\10\00\00\00\00\00", align 1 > const wchar_t *bar = L"\u1234\U0010F00B"; > > - // CHECK: private unnamed_addr constant [12 x i8] > c"C\00\00\00D\00\00\00\00\00\00\00", align 1 > +#if __cplusplus >= 201103L > + // CHECK-CPP0X: private unnamed_addr constant [12 x i8] > c"C\00\00\00D\00\00\00\00\00\00\00", align 1 > const char32_t *c = U"CD"; > > - // CHECK: private unnamed_addr constant [12 x i8] > c"5\12\00\00\0C\F0\10\00\00\00\00\00", align 1 > + // CHECK-CPP0X: private unnamed_addr constant [12 x i8] > c"5\12\00\00\0C\F0\10\00\00\00\00\00", align 1 > const char32_t *d = U"\u1235\U0010F00C"; > > - // CHECK: private unnamed_addr constant [6 x i8] c"E\00F\00\00\00", align 1 > + // CHECK-CPP0X: private unnamed_addr constant [6 x i8] c"E\00F\00\00\00", > align 1 > const char16_t *e = u"EF"; > > // This should convert to utf16. > - // CHECK: private unnamed_addr constant [10 x i8] c" \11 > \02\C8\DB0\DC\00\00", align 1 > + // CHECK-CPP0X: private unnamed_addr constant [10 x i8] c" \11 > \02\C8\DB0\DC\00\00", align 1 > const char16_t *f = u"\u1120\u0220\U00102030"; > > - // CHECK: private unnamed_addr constant [4 x i8] c"def\00", align 1 > + // CHECK-CPP0X: private unnamed_addr constant [4 x i8] c"def\00", align 1 > const char *g = u8"def"; > +#endif > } > > Modified: cfe/trunk/test/Parser/char-literal-printing.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/char-literal-printing.c?rev=136443&r1=136442&r2=136443&view=diff > ============================================================================== > --- cfe/trunk/test/Parser/char-literal-printing.c (original) > +++ cfe/trunk/test/Parser/char-literal-printing.c Thu Jul 28 20:08:54 2011 > @@ -1,5 +1,8 @@ > +// RUN: %clang_cc1 -ast-print %s > +// RUN: %clang_cc1 -x c++ -ast-print %s > // RUN: %clang_cc1 -x c++ -std=c++0x -ast-print %s > -// Runs in c++0x mode so that wchar_t, char16_t, and char32_t are available. > + > +#include <stddef.h> > > char test1(void) { return '\\'; } > wchar_t test2(void) { return L'\\'; } > @@ -29,6 +32,7 @@ > > wchar_t test25(void) { return L'\x333'; } > > +#if __cplusplus >= 201103L > char16_t test26(void) { return u'\\'; } > char16_t test27(void) { return u'\''; } > char16_t test28(void) { return u'\a'; } > @@ -60,3 +64,4 @@ > char32_t test50(void) { return U'\x3'; } > > char32_t test51(void) { return U'\x333'; } > +#endif > > Added: 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=136443&view=auto > ============================================================================== > --- cfe/trunk/test/SemaCXX/cxx0x-type-convert-construct.cpp (added) > +++ cfe/trunk/test/SemaCXX/cxx0x-type-convert-construct.cpp Thu Jul 28 > 20:08:54 2011 > @@ -0,0 +1,10 @@ > +// RUN: %clang_cc1 -std=gnu++0x -fsyntax-only -verify %s > + > +void f() { > + char *u8str; > + u8str = u8"a UTF-8 string"; // expected-error {{assigning to 'char *' from > incompatible type 'const char [15]'}} > + char16_t *ustr; > + 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]'}} > +} > > Propchange: cfe/trunk/test/SemaCXX/cxx0x-type-convert-construct.cpp > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: cfe/trunk/test/SemaCXX/cxx0x-type-convert-construct.cpp > ------------------------------------------------------------------------------ > svn:keywords = Id > > Propchange: cfe/trunk/test/SemaCXX/cxx0x-type-convert-construct.cpp > ------------------------------------------------------------------------------ > svn:mime-type = text/plain > > Modified: cfe/trunk/test/SemaCXX/type-convert-construct.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-convert-construct.cpp?rev=136443&r1=136442&r2=136443&view=diff > ============================================================================== > --- cfe/trunk/test/SemaCXX/type-convert-construct.cpp (original) > +++ cfe/trunk/test/SemaCXX/type-convert-construct.cpp Thu Jul 28 20:08:54 2011 > @@ -1,5 +1,4 @@ > -// RUN: %clang_cc1 -std=gnu++0x -fsyntax-only -verify %s > -// Runs in c++0x mode so that char16_t and char32_t are available. > +// RUN: %clang_cc1 -fsyntax-only -verify %s > > void f() { > float v1 = float(1); > @@ -15,8 +14,4 @@ > str = "a string"; // expected-warning{{conversion from string literal to > 'char *' is deprecated}} > wchar_t *wstr; > wstr = L"a wide string"; // expected-warning{{conversion from string > literal to 'wchar_t *' is deprecated}} > - char16_t *ustr; > - 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]'}} > } > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
