r184165 - r184100 Fix -- Updated test cases for contextual conversion

Richard Smith richard at metafoo.co.uk
Mon Jun 17 18:40:14 PDT 2013


On Mon, Jun 17, 2013 at 6:27 PM, Larisse Voufo <lvoufo at google.com> wrote:
> Author: lvoufo
> Date: Mon Jun 17 20:27:47 2013
> New Revision: 184165
>
> URL: http://llvm.org/viewvc/llvm-project?rev=184165&view=rev
> Log:
> r184100 Fix -- Updated test cases for contextual conversion
>
> Modified:
>     cfe/trunk/lib/Sema/SemaExprCXX.cpp
>     cfe/trunk/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp
>     cfe/trunk/test/SemaCXX/cxx98-compat-pedantic.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=184165&r1=184164&r2=184165&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Jun 17 20:27:47 2013
> @@ -1205,9 +1205,9 @@ Sema::BuildCXXNew(SourceRange Range, boo
>                                                 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'";

This warning is firing in too many cases. For instance:

  int *p = new int[1];

triggers it. This should only warn if the source type is a class type.
Also, you don't need the SFINAE context check here.

>      } else {
>        class SizeConvertDiagnoser : public ICEConvertDiagnoser {
>        protected:
>
> Modified: cfe/trunk/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp?rev=184165&r1=184164&r2=184165&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp (original)
> +++ cfe/trunk/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp Mon Jun 17 20:27:47 2013
> @@ -154,4 +154,24 @@ namespace extended_examples_cxx1y {
>  //expected-error at 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 {
> +
> +  typedef decltype(sizeof(int)) size_t;
> +
> +  struct Foo {
> +    operator size_t();   // @162
> +    operator unsigned short();  // @163
> +  };
> +
> +  void bar() {
> +    Foo x;
> +    int *p = new int[x];        // @168
> +  }
> +}
> +
> +#ifdef CXX1Y
> +#else
> +//expected-error at 168 {{ambiguous conversion of array size expression of type 'extended_examples_array_bounds::Foo' to an integral or enumeration type}}
> +//expected-note at 162 {{conversion to integral type 'size_t'}}
> +//expected-note at 163 {{conversion to integral type 'unsigned short' declared here}}
> +#endif
>
> Modified: cfe/trunk/test/SemaCXX/cxx98-compat-pedantic.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx98-compat-pedantic.cpp?rev=184165&r1=184164&r2=184165&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/cxx98-compat-pedantic.cpp (original)
> +++ cfe/trunk/test/SemaCXX/cxx98-compat-pedantic.cpp Mon Jun 17 20:27:47 2013
> @@ -34,7 +34,7 @@ struct ConvertToInt {
>  };
>  int *ArraySizeConversion = new int[ConvertToInt()];
>  #ifdef CXX1Y2
> -// expected-warning at -2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type}} // 'unsigned long' is incompatible with C++98}}
> +// expected-warning at -2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'size_t' is incompatible with C++98}}
>  #else
>  // expected-warning at -4 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}}
>  #endif
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list