diff options
author | Charles Li <charles.li@sony.com> | 2017-02-24 22:22:05 +0000 |
---|---|---|
committer | Charles Li <charles.li@sony.com> | 2017-02-24 22:22:05 +0000 |
commit | ccb64f9e8de2c576b8c5fbace40af378901b0493 (patch) | |
tree | 3d953787d5f54fcdd91596dce85d857bf9b0e2fc /test/SemaTemplate | |
parent | 0002bae4835445aad74b973328771dc11f9bc2e5 (diff) |
[Test] Make Lit tests C++11 compatible #9
[Test] Make Lit tests C++11 compatible #9
Differential Revision: https://reviews.llvm.org/D20710
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296184 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r-- | test/SemaTemplate/instantiate-c99.cpp | 19 | ||||
-rw-r--r-- | test/SemaTemplate/temp_explicit.cpp | 25 | ||||
-rw-r--r-- | test/SemaTemplate/value-dependent-null-pointer-constant.cpp | 15 |
3 files changed, 54 insertions, 5 deletions
diff --git a/test/SemaTemplate/instantiate-c99.cpp b/test/SemaTemplate/instantiate-c99.cpp index ae1552887b..07d3fc7920 100644 --- a/test/SemaTemplate/instantiate-c99.cpp +++ b/test/SemaTemplate/instantiate-c99.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // Test template instantiation for C99-specific features. @@ -9,8 +11,13 @@ template<typename T, typename XType, typename YType> struct DesigInit0 { void f(XType x, YType y) { T agg = { +#if __cplusplus <= 199711L .y = y, // expected-error{{does not refer}} .x = x // expected-error{{does not refer}} +#else + .y = static_cast<float>(y), // expected-error{{does not refer}} + .x = static_cast<float>(x) // expected-error{{does not refer}} +#endif }; } }; @@ -44,7 +51,11 @@ template<typename T, int Subscript1, int Subscript2, struct DesigArrayInit0 { void f(Val1 val1, Val2 val2) { T array = { +#if __cplusplus <= 199711L [Subscript1] = val1, +#else + [Subscript1] = static_cast<int>(val1), +#endif [Subscript2] = val2 // expected-error{{exceeds array bounds}} }; @@ -60,7 +71,11 @@ template<typename T, int Subscript1, int Subscript2, struct DesigArrayRangeInit0 { void f(Val1 val1) { T array = { +#if __cplusplus <= 199711L [Subscript1...Subscript2] = val1 // expected-error{{exceeds}} +#else + [Subscript1...Subscript2] = static_cast<int>(val1) // expected-error{{exceeds}} +#endif }; } }; @@ -74,7 +89,11 @@ template struct DesigArrayRangeInit0<int[8], 5, 13, float>; // expected-note{{in template<typename T, typename Arg1, typename Arg2> struct CompoundLiteral0 { T f(Arg1 a1, Arg2 a2) { +#if __cplusplus <= 199711L return (T){a1, a2}; +#else + return (T){static_cast<float>(a1), a2}; +#endif } }; diff --git a/test/SemaTemplate/temp_explicit.cpp b/test/SemaTemplate/temp_explicit.cpp index e8c9dfb5f5..0bb0cfad61 100644 --- a/test/SemaTemplate/temp_explicit.cpp +++ b/test/SemaTemplate/temp_explicit.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s // // Tests explicit instantiation of templates. template<typename T, typename U = T> class X0 { }; @@ -98,7 +100,12 @@ void f4(X5<float&>::Inner2); template struct X5<float&>::Inner2; // expected-note{{instantiation}} namespace N3 { - template struct N2::X5<int>::Inner2; // expected-warning {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}} + template struct N2::X5<int>::Inner2; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}} +#else +// expected-error@-4 {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}} +#endif } struct X6 { @@ -145,7 +152,17 @@ template struct ::N1::Inner::X8<float>; namespace N2 { using namespace N1; - template struct X7<double>; // expected-warning{{must occur in namespace}} - - template struct X9<float>; // expected-warning{{must occur at global scope}} + template struct X7<double>; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'N1::X7' must occur in namespace 'N1'}} +#else +// expected-error@-4 {{explicit instantiation of 'N1::X7' must occur in namespace 'N1'}} +#endif + + template struct X9<float>; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'X9' must occur at global scope}} +#else +// expected-error@-4 {{explicit instantiation of 'X9' must occur at global scope}} +#endif } diff --git a/test/SemaTemplate/value-dependent-null-pointer-constant.cpp b/test/SemaTemplate/value-dependent-null-pointer-constant.cpp index 223500eac4..29fd15e395 100644 --- a/test/SemaTemplate/value-dependent-null-pointer-constant.cpp +++ b/test/SemaTemplate/value-dependent-null-pointer-constant.cpp @@ -1,17 +1,30 @@ -// RUN: %clang_cc1 -fsyntax-only %s +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s template<typename T, int N> struct X0 { const char *f0(bool Cond) { return Cond? "honk" : N; +#if __cplusplus >= 201103L +// expected-error@-2 {{incompatible operand types ('const char *' and 'int')}} +#else +// expected-no-diagnostics +#endif } const char *f1(bool Cond) { return Cond? N : "honk"; +#if __cplusplus >= 201103L +// expected-error@-2 {{incompatible operand types ('int' and 'const char *')}} +#endif } bool f2(const char *str) { return str == N; +#if __cplusplus >= 201103L +// expected-error@-2 {{comparison between pointer and integer ('const char *' and 'int')}} +#endif } }; |