From: Larisse Voufo Date: Mon, 17 Jun 2013 18:41:38 +0000 (+0000) Subject: Updated test cases for contextual conversion X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37aba4797703ebadbd480b757ce40b81036539bc;p=clang Updated test cases for contextual conversion git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184100 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 40af2075c3..d723c1fe77 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1205,9 +1205,9 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, AA_Converting); if (!isSFINAEContext()) - // Diagnose the compatibility of this conversion. - Diag(StartLoc, diag::warn_cxx98_compat_array_size_conversion) - << ArraySize->getType() << 0 << Context.getSizeType(); + // Diagnose the compatibility of this conversion. + Diag(StartLoc, diag::warn_cxx98_compat_array_size_conversion) + << ArraySize->getType() << 0 << "'size_t'"; } else { class SizeConvertDiagnoser : public ICEConvertDiagnoser { protected: diff --git a/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp b/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp index f00bf1ea31..c91c361544 100644 --- a/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp +++ b/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp @@ -154,4 +154,22 @@ namespace extended_examples_cxx1y { //expected-error@143 {{cannot initialize object parameter of type 'extended_examples_cxx1y::D' with an expression of type 'extended_examples_cxx1y::D'}} #endif -// FIXME: Extend with more examples, including [expr.const] and [expr.new]. +namespace extended_examples_array_bounds { + + struct Foo { + operator unsigned long(); // @160 + operator unsigned short(); // @161 + }; + + void bar() { + Foo x; + int *p = new int[x]; // @166 + } +} + +#ifdef CXX1Y +#else +//expected-error@166 {{ambiguous conversion of array size expression of type 'extended_examples_array_bounds::Foo' to an integral or enumeration type}} +//expected-note@160 {{conversion to integral type 'unsigned long' declared here}} +//expected-note@161 {{conversion to integral type 'unsigned short' declared here}} +#endif diff --git a/test/SemaCXX/cxx98-compat-pedantic.cpp b/test/SemaCXX/cxx98-compat-pedantic.cpp index 5fe7980994..50ce6a4900 100644 --- a/test/SemaCXX/cxx98-compat-pedantic.cpp +++ b/test/SemaCXX/cxx98-compat-pedantic.cpp @@ -34,7 +34,7 @@ struct ConvertToInt { }; int *ArraySizeConversion = new int[ConvertToInt()]; #ifdef CXX1Y2 -// expected-warning@-2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type}} // 'unsigned long' is incompatible with C++98}} +// expected-warning@-2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'size_t' is incompatible with C++98}} #else // expected-warning@-4 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}} #endif