r310427 - Sema: disable implicit conversion from _Complex to real types in C++.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 9 18:09:47 PST 2018


On 8 August 2017 at 16:18, Tim Northover via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: tnorthover
> Date: Tue Aug  8 16:18:05 2017
> New Revision: 310427
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310427&view=rev
> Log:
> Sema: disable implicit conversion from _Complex to real types in C++.
>
> Converting a _Complex type to a real one simply discards the imaginary
> part.
> This can easily lead to loss of information so for safety (and GCC
> compatibility) this patch disallows that when the conversion would be
> implicit.
>
> The one exception is bool, which actually compares both real and imaginary
> parts and so is safe.
>

This change is missing the corresponding change to formation of
initialization sequences. The result is surprising behavior in overload
resolution:

_Complex double cd;

double d = cd; // error, can't convert

void f(double); // #1
int f(...);   // #2
int n = f(cd); // error, selects #1 instead of #2

Note that GCC selects overload #2 in the above case.


> Added:
>     cfe/trunk/test/SemaCXX/complex-conversion.cpp
> Modified:
>     cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>     cfe/trunk/lib/Sema/SemaChecking.cpp
>     cfe/trunk/lib/Sema/SemaExpr.cpp
>     cfe/trunk/test/CodeGenCXX/stmtexpr.cpp
>     cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp
>     cfe/trunk/test/OpenMP/atomic_update_codegen.cpp
>     cfe/trunk/test/SemaCXX/complex-overload.cpp
>     cfe/trunk/test/SemaCXX/integer-overflow.cpp
>     cfe/trunk/test/SemaCXX/warn-absolute-value.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=310427&r1=310426&r2=310427&view=diff
> ============================================================
> ==================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug  8
> 16:18:05 2017
> @@ -3087,6 +3087,8 @@ def warn_impcast_vector_scalar : Warning
>  def warn_impcast_complex_scalar : Warning<
>    "implicit conversion discards imaginary component: %0 to %1">,
>    InGroup<Conversion>, DefaultIgnore;
> +def err_impcast_complex_scalar : Error<
> +  "implicit conversion from %0 to %1 is not permitted in C++">;
>  def warn_impcast_float_precision : Warning<
>    "implicit conversion loses floating-point precision: %0 to %1">,
>    InGroup<Conversion>, DefaultIgnore;
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaChecking.cpp?rev=310427&r1=310426&r2=310427&view=diff
> ============================================================
> ==================
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Aug  8 16:18:05 2017
> @@ -9431,10 +9431,13 @@ void CheckImplicitConversion(Sema &S, Ex
>    // Strip complex types.
>    if (isa<ComplexType>(Source)) {
>      if (!isa<ComplexType>(Target)) {
> -      if (S.SourceMgr.isInSystemMacro(CC))
> +      if (S.SourceMgr.isInSystemMacro(CC) || Target->isBooleanType())
>          return;
>
> -      return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_complex_
> scalar);
> +      return DiagnoseImpCast(S, E, T, CC,
> +                             S.getLangOpts().CPlusPlus
> +                                 ? diag::err_impcast_complex_scalar
> +                                 : diag::warn_impcast_complex_scalar);
>      }
>
>      Source = cast<ComplexType>(Source)->getElementType().getTypePtr();
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaExpr.cpp?rev=310427&r1=310426&r2=310427&view=diff
> ============================================================
> ==================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug  8 16:18:05 2017
> @@ -7530,6 +7530,12 @@ Sema::CheckAssignmentConstraints(QualTyp
>    if (unsupportedTypeConversion(*this, LHSType, RHSType))
>      return Incompatible;
>
> +  // Disallow assigning a _Complex to a real type in C++ mode since it
> simply
> +  // discards the imaginary part.
> +  if (getLangOpts().CPlusPlus && RHSType->getAs<ComplexType>() &&
> +      !LHSType->getAs<ComplexType>())
> +    return Incompatible;
> +
>    // Arithmetic conversions.
>    if (LHSType->isArithmeticType() && RHSType->isArithmeticType() &&
>        !(getLangOpts().CPlusPlus && LHSType->isEnumeralType())) {
>
> Modified: cfe/trunk/test/CodeGenCXX/stmtexpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGenCXX/stmtexpr.cpp?rev=310427&r1=310426&r2=310427&view=diff
> ============================================================
> ==================
> --- cfe/trunk/test/CodeGenCXX/stmtexpr.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/stmtexpr.cpp Tue Aug  8 16:18:05 2017
> @@ -173,7 +173,7 @@ extern "C" int cleanup_exit_lvalue_local
>  _Complex float bar_complex(A, int);
>  extern "C" int cleanup_exit_complex(bool b) {
>    _Complex float v = bar_complex(A(1), ({ if (b) return 42; 13; }));
> -  return v;
> +  return (float)v;
>  }
>
>  // CHECK-LABEL: define{{.*}} i32 @cleanup_exit_complex({{.*}})
>
> Modified: cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> atomic_capture_codegen.cpp?rev=310427&r1=310426&r2=310427&view=diff
> ============================================================
> ==================
> --- cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp Tue Aug  8 16:18:05
> 2017
> @@ -611,50 +611,6 @@ int main() {
>  // CHECK: store i8 [[DESIRED_I8]], i8* @{{.+}},
>  #pragma omp atomic capture
>    {bx = civ - bx; bv = bx;}
> -// CHECK: [[EXPR_RE:%.+]] = load float, float* getelementptr inbounds ({
> float, float }, { float, float }* @{{.+}}, i32 0, i32 0)
> -// CHECK: [[EXPR_IM:%.+]] = load float, float* getelementptr inbounds ({
> float, float }, { float, float }* @{{.+}}, i32 0, i32 1)
> -// CHECK: [[X:%.+]] = load atomic i16, i16* [[X_ADDR:@.+]] monotonic
> -// CHECK: br label %[[CONT:.+]]
> -// CHECK: [[CONT]]
> -// CHECK: [[EXPECTED:%.+]] = phi i16 [ [[X]], %{{.+}} ], [ [[OLD_X:%.+]],
> %[[CONT]] ]
> -// CHECK: [[CONV:%.+]] = zext i16 [[EXPECTED]] to i32
> -// CHECK: [[X_RVAL:%.+]] = sitofp i32 [[CONV]] to float
> -// <Skip checks for complex calculations>
> -// CHECK: [[X_RE_ADDR:%.+]] = getelementptr inbounds { float, float }, {
> float, float }* [[TEMP:%.+]], i32 0, i32 0
> -// CHECK: [[X_RE:%.+]] = load float, float* [[X_RE_ADDR]]
> -// CHECK: [[X_IM_ADDR:%.+]] = getelementptr inbounds { float, float }, {
> float, float }* [[TEMP]], i32 0, i32 1
> -// CHECK: [[X_IM:%.+]] = load float, float* [[X_IM_ADDR]]
> -// CHECK: [[NEW:%.+]] = fptoui float [[X_RE]] to i16
> -// CHECK: store i16 [[NEW]], i16* [[TEMP:%.+]],
> -// CHECK: [[DESIRED:%.+]] = load i16, i16* [[TEMP]],
> -// CHECK: [[RES:%.+]] = cmpxchg i16* [[X_ADDR]], i16 [[EXPECTED]], i16
> [[DESIRED]] monotonic monotonic
> -// CHECK: [[OLD_X]] = extractvalue { i16, i1 } [[RES]], 0
> -// CHECK: [[SUCCESS_FAIL:%.+]] = extractvalue { i16, i1 } [[RES]], 1
> -// CHECK: br i1 [[SUCCESS_FAIL]], label %[[EXIT:.+]], label %[[CONT]]
> -// CHECK: [[EXIT]]
> -// CHECK: store i16 [[NEW]], i16* @{{.+}},
> -#pragma omp atomic capture
> -  usv = usx /= cfv;
> -// CHECK: [[EXPR_RE:%.+]] = load double, double* getelementptr inbounds
> ({ double, double }, { double, double }* @{{.+}}, i32 0, i32 0)
> -// CHECK: [[EXPR_IM:%.+]] = load double, double* getelementptr inbounds
> ({ double, double }, { double, double }* @{{.+}}, i32 0, i32 1)
> -// CHECK: [[X:%.+]] = load atomic i64, i64* [[X_ADDR:@.+]] monotonic
> -// CHECK: br label %[[CONT:.+]]
> -// CHECK: [[CONT]]
> -// CHECK: [[EXPECTED:%.+]] = phi i64 [ [[X]], %{{.+}} ], [ [[OLD_X:%.+]],
> %[[CONT]] ]
> -// CHECK: [[X_RVAL:%.+]] = sitofp i64 [[EXPECTED]] to double
> -// CHECK: [[ADD_RE:%.+]] = fadd double [[X_RVAL]], [[EXPR_RE]]
> -// CHECK: [[ADD_IM:%.+]] = fadd double 0.000000e+00, [[EXPR_IM]]
> -// CHECK: [[DESIRED:%.+]] = fptosi double [[ADD_RE]] to i64
> -// CHECK: store i64 [[DESIRED]], i64* [[TEMP:%.+]],
> -// CHECK: [[DESIRED:%.+]] = load i64, i64* [[TEMP]],
> -// CHECK: [[RES:%.+]] = cmpxchg i64* [[X_ADDR]], i64 [[EXPECTED]], i64
> [[DESIRED]] monotonic monotonic
> -// CHECK: [[OLD_X]] = extractvalue { i64, i1 } [[RES]], 0
> -// CHECK: [[SUCCESS_FAIL:%.+]] = extractvalue { i64, i1 } [[RES]], 1
> -// CHECK: br i1 [[SUCCESS_FAIL]], label %[[EXIT:.+]], label %[[CONT]]
> -// CHECK: [[EXIT]]
> -// CHECK: store i64 [[EXPECTED]], i64* @{{.+}},
> -#pragma omp atomic capture
> -  {llv = llx; llx += cdv;}
>  // CHECK: [[IDX:%.+]] = load i16, i16* @{{.+}}
>  // CHECK: load i8, i8*
>  // CHECK: [[VEC_ITEM_VAL:%.+]] = zext i1 %{{.+}} to i32
>
> Modified: cfe/trunk/test/OpenMP/atomic_update_codegen.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> atomic_update_codegen.cpp?rev=310427&r1=310426&r2=310427&view=diff
> ============================================================
> ==================
> --- cfe/trunk/test/OpenMP/atomic_update_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/atomic_update_codegen.cpp Tue Aug  8 16:18:05
> 2017
> @@ -554,48 +554,6 @@ int main() {
>  // CHECK: [[EXIT]]
>  #pragma omp atomic
>    bx = civ - bx;
> -// CHECK: [[EXPR_RE:%.+]] = load float, float* getelementptr inbounds ({
> float, float }, { float, float }* @{{.+}}, i32 0, i32 0)
> -// CHECK: [[EXPR_IM:%.+]] = load float, float* getelementptr inbounds ({
> float, float }, { float, float }* @{{.+}}, i32 0, i32 1)
> -// CHECK: [[X:%.+]] = load atomic i16, i16* [[X_ADDR:@.+]] monotonic
> -// CHECK: br label %[[CONT:.+]]
> -// CHECK: [[CONT]]
> -// CHECK: [[EXPECTED:%.+]] = phi i16 [ [[X]], %{{.+}} ], [ [[OLD_X:%.+]],
> %[[CONT]] ]
> -// CHECK: [[CONV:%.+]] = zext i16 [[EXPECTED]] to i32
> -// CHECK: [[X_RVAL:%.+]] = sitofp i32 [[CONV]] to float
> -// <Skip checks for complex calculations>
> -// CHECK: [[X_RE_ADDR:%.+]] = getelementptr inbounds { float, float }, {
> float, float }* [[TEMP:%.+]], i32 0, i32 0
> -// CHECK: [[X_RE:%.+]] = load float, float* [[X_RE_ADDR]]
> -// CHECK: [[X_IM_ADDR:%.+]] = getelementptr inbounds { float, float }, {
> float, float }* [[TEMP]], i32 0, i32 1
> -// CHECK: [[X_IM:%.+]] = load float, float* [[X_IM_ADDR]]
> -// CHECK: [[DESIRED:%.+]] = fptoui float [[X_RE]] to i16
> -// CHECK: store i16 [[DESIRED]], i16* [[TEMP:%.+]]
> -// CHECK: [[DESIRED:%.+]] = load i16, i16* [[TEMP]]
> -// CHECK: [[RES:%.+]] = cmpxchg i16* [[X_ADDR]], i16 [[EXPECTED]], i16
> [[DESIRED]] monotonic monotonic
> -// CHECK: [[OLD_X]] = extractvalue { i16, i1 } [[RES]], 0
> -// CHECK: [[SUCCESS_FAIL:%.+]] = extractvalue { i16, i1 } [[RES]], 1
> -// CHECK: br i1 [[SUCCESS_FAIL]], label %[[EXIT:.+]], label %[[CONT]]
> -// CHECK: [[EXIT]]
> -#pragma omp atomic update
> -  usx /= cfv;
> -// CHECK: [[EXPR_RE:%.+]] = load double, double* getelementptr inbounds
> ({ double, double }, { double, double }* @{{.+}}, i32 0, i32 0)
> -// CHECK: [[EXPR_IM:%.+]] = load double, double* getelementptr inbounds
> ({ double, double }, { double, double }* @{{.+}}, i32 0, i32 1)
> -// CHECK: [[X:%.+]] = load atomic i64, i64* [[X_ADDR:@.+]] monotonic
> -// CHECK: br label %[[CONT:.+]]
> -// CHECK: [[CONT]]
> -// CHECK: [[EXPECTED:%.+]] = phi i64 [ [[X]], %{{.+}} ], [ [[OLD_X:%.+]],
> %[[CONT]] ]
> -// CHECK: [[X_RVAL:%.+]] = sitofp i64 [[EXPECTED]] to double
> -// CHECK: [[ADD_RE:%.+]] = fadd double [[X_RVAL]], [[EXPR_RE]]
> -// CHECK: [[ADD_IM:%.+]] = fadd double 0.000000e+00, [[EXPR_IM]]
> -// CHECK: [[DESIRED:%.+]] = fptosi double [[ADD_RE]] to i64
> -// CHECK: store i64 [[DESIRED]], i64* [[TEMP:%.+]]
> -// CHECK: [[DESIRED:%.+]] = load i64, i64* [[TEMP]]
> -// CHECK: [[RES:%.+]] = cmpxchg i64* [[X_ADDR]], i64 [[EXPECTED]], i64
> [[DESIRED]] monotonic monotonic
> -// CHECK: [[OLD_X]] = extractvalue { i64, i1 } [[RES]], 0
> -// CHECK: [[SUCCESS_FAIL:%.+]] = extractvalue { i64, i1 } [[RES]], 1
> -// CHECK: br i1 [[SUCCESS_FAIL]], label %[[EXIT:.+]], label %[[CONT]]
> -// CHECK: [[EXIT]]
> -#pragma omp atomic
> -  llx += cdv;
>  // CHECK: [[IDX:%.+]] = load i16, i16* @{{.+}}
>  // CHECK: load i8, i8*
>  // CHECK: [[VEC_ITEM_VAL:%.+]] = zext i1 %{{.+}} to i32
>
> Added: cfe/trunk/test/SemaCXX/complex-conversion.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/complex-conversion.cpp?rev=310427&view=auto
> ============================================================
> ==================
> --- cfe/trunk/test/SemaCXX/complex-conversion.cpp (added)
> +++ cfe/trunk/test/SemaCXX/complex-conversion.cpp Tue Aug  8 16:18:05 2017
> @@ -0,0 +1,18 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify %s
> +
> +template<typename T> void take(T);
> +
> +void func(float Real, _Complex float Complex) {
> +  Real += Complex; // expected-error {{assigning to 'float' from
> incompatible type '_Complex float'}}
> +  Real += (float)Complex;
> +
> +  Real = Complex; // expected-error {{implicit conversion from '_Complex
> float' to 'float' is not permitted in C++}}
> +  Real = (float)Complex;
> +
> +  take<float>(Complex); // expected-error {{implicit conversion from
> '_Complex float' to 'float' is not permitted in C++}}
> +  take<double>(1.0i); // expected-error {{implicit conversion from
> '_Complex double' to 'double' is not permitted in C++}}
> +  take<_Complex float>(Complex);
> +
> +  // Conversion to bool doesn't actually discard the imaginary part.
> +  take<bool>(Complex);
> +}
>
> Modified: cfe/trunk/test/SemaCXX/complex-overload.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/complex-overload.cpp?rev=310427&r1=310426&r2=310427&view=diff
> ============================================================
> ==================
> --- cfe/trunk/test/SemaCXX/complex-overload.cpp (original)
> +++ cfe/trunk/test/SemaCXX/complex-overload.cpp Tue Aug  8 16:18:05 2017
> @@ -4,9 +4,10 @@ char *foo(float);
>  void test_foo_1(float fv, double dv, float _Complex fc, double _Complex
> dc) {
>    char *cp1 = foo(fv);
>    char *cp2 = foo(dv);
> -  // Note: GCC and EDG reject these two, but they are valid C99
> conversions
> -  char *cp3 = foo(fc);
> -  char *cp4 = foo(dc);
> +  // Note: GCC and EDG reject these two, they are valid C99 conversions
> but
> +  // shouldn't be accepted in C++ because the result is surprising.
> +  char *cp3 = foo(fc); // expected-error {{implicit conversion from
> '_Complex float' to 'float' is not permitted in C++}}
> +  char *cp4 = foo(dc); // expected-error {{implicit conversion from
> '_Complex double' to 'float' is not permitted in C++}}
>  }
>
>  int *foo(float _Complex);
>
> Modified: cfe/trunk/test/SemaCXX/integer-overflow.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/integer-overflow.cpp?rev=310427&r1=310426&r2=310427&view=diff
> ============================================================
> ==================
> --- cfe/trunk/test/SemaCXX/integer-overflow.cpp (original)
> +++ cfe/trunk/test/SemaCXX/integer-overflow.cpp Tue Aug  8 16:18:05 2017
> @@ -164,7 +164,7 @@ uint64_t check_integer_overflows(int i)
>  // expected-warning at +3 {{array index 536870912 is past the end of the
> array (which contains 10 elements)}}
>  // expected-note at +1 {{array 'a' declared here}}
>    uint64_t a[10];
> -  a[4608 * 1024 * 1024] = 1i;
> +  a[4608 * 1024 * 1024] = 1;
>
>  // expected-warning at +1 2{{overflow in expression; result is 536870912
> with type 'int'}}
>    return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
>
> Modified: cfe/trunk/test/SemaCXX/warn-absolute-value.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/warn-absolute-value.cpp?rev=310427&r1=310426&r2=310427&view=diff
> ============================================================
> ==================
> --- cfe/trunk/test/SemaCXX/warn-absolute-value.cpp (original)
> +++ cfe/trunk/test/SemaCXX/warn-absolute-value.cpp Tue Aug  8 16:18:05
> 2017
> @@ -448,94 +448,16 @@ void test_long_double(long double x) {
>  }
>
>  void test_complex_float(_Complex float x) {
> -  (void)abs(x);
> -  // expected-warning at -1 {{using integer absolute value function 'abs'
> when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsf"
> -  (void)labs(x);
> -  // expected-warning at -1 {{using integer absolute value function 'labs'
> when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"
> -  (void)llabs(x);
> -  // expected-warning at -1 {{using integer absolute value function 'llabs'
> when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
> -
> -  (void)fabsf(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> 'fabsf' when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
> -  (void)fabs(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> 'fabs' when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"
> -  (void)fabsl(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> 'fabsl' when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
> -
>    (void)cabsf(x);
>    (void)cabs(x);
>    (void)cabsl(x);
>
> -  (void)__builtin_abs(x);
> -  // expected-warning at -1 {{using integer absolute value function
> '__builtin_abs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_
> cabsf"
> -  (void)__builtin_labs(x);
> -  // expected-warning at -1 {{using integer absolute value function
> '__builtin_labs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_
> cabsf"
> -  (void)__builtin_llabs(x);
> -  // expected-warning at -1 {{using integer absolute value function
> '__builtin_llabs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_
> cabsf"
> -
> -  (void)__builtin_fabsf(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> '__builtin_fabsf' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_
> cabsf"
> -  (void)__builtin_fabs(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> '__builtin_fabs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_
> cabsf"
> -  (void)__builtin_fabsl(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> '__builtin_fabsl' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsf' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_
> cabsf"
> -
>    (void)__builtin_cabsf(x);
>    (void)__builtin_cabs(x);
>    (void)__builtin_cabsl(x);
>  }
>
>  void test_complex_double(_Complex double x) {
> -  (void)abs(x);
> -  // expected-warning at -1 {{using integer absolute value function 'abs'
> when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabs"
> -  (void)labs(x);
> -  // expected-warning at -1 {{using integer absolute value function 'labs'
> when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs"
> -  (void)llabs(x);
> -  // expected-warning at -1 {{using integer absolute value function 'llabs'
> when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
> -
> -  (void)fabsf(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> 'fabsf' when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
> -  (void)fabs(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> 'fabs' when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs"
> -  (void)fabsl(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> 'fabsl' when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
> -
>    (void)cabsf(x);
>    // expected-warning at -1 {{absolute value function 'cabsf' given an
> argument of type '_Complex double' but has parameter of type '_Complex
> float' which may cause truncation of value}}
>    // expected-note at -2 {{use function 'cabs' instead}}
> @@ -543,31 +465,6 @@ void test_complex_double(_Complex double
>    (void)cabs(x);
>    (void)cabsl(x);
>
> -  (void)__builtin_abs(x);
> -  // expected-warning at -1 {{using integer absolute value function
> '__builtin_abs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_
> cabs"
> -  (void)__builtin_labs(x);
> -  // expected-warning at -1 {{using integer absolute value function
> '__builtin_labs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_
> cabs"
> -  (void)__builtin_llabs(x);
> -  // expected-warning at -1 {{using integer absolute value function
> '__builtin_llabs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_
> cabs"
> -
> -  (void)__builtin_fabsf(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> '__builtin_fabsf' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_
> cabs"
> -  (void)__builtin_fabs(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> '__builtin_fabs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_
> cabs"
> -  (void)__builtin_fabsl(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> '__builtin_fabsl' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabs' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_
> cabs"
>
>    (void)__builtin_cabsf(x);
>    // expected-warning at -1 {{absolute value function '__builtin_cabsf'
> given an argument of type '_Complex double' but has parameter of type
> '_Complex float' which may cause truncation of value}}
> @@ -578,32 +475,6 @@ void test_complex_double(_Complex double
>  }
>
>  void test_complex_long_double(_Complex long double x) {
> -  (void)abs(x);
> -  // expected-warning at -1 {{using integer absolute value function 'abs'
> when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsl"
> -  (void)labs(x);
> -  // expected-warning at -1 {{using integer absolute value function 'labs'
> when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
> -  (void)llabs(x);
> -  // expected-warning at -1 {{using integer absolute value function 'llabs'
> when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
> -
> -  (void)fabsf(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> 'fabsf' when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
> -  (void)fabs(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> 'fabs' when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
> -  (void)fabsl(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> 'fabsl' when argument is of complex type}}
> -  // expected-note at -2 {{use function 'cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
> -
>    (void)cabsf(x);
>    // expected-warning at -1 {{absolute value function 'cabsf' given an
> argument of type '_Complex long double' but has parameter of type '_Complex
> float' which may cause truncation of value}}
>    // expected-note at -2 {{use function 'cabsl' instead}}
> @@ -614,32 +485,6 @@ void test_complex_long_double(_Complex l
>    // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
>    (void)cabsl(x);
>
> -  (void)__builtin_abs(x);
> -  // expected-warning at -1 {{using integer absolute value function
> '__builtin_abs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_
> cabsl"
> -  (void)__builtin_labs(x);
> -  // expected-warning at -1 {{using integer absolute value function
> '__builtin_labs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_
> cabsl"
> -  (void)__builtin_llabs(x);
> -  // expected-warning at -1 {{using integer absolute value function
> '__builtin_llabs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_
> cabsl"
> -
> -  (void)__builtin_fabsf(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> '__builtin_fabsf' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_
> cabsl"
> -  (void)__builtin_fabs(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> '__builtin_fabs' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_
> cabsl"
> -  (void)__builtin_fabsl(x);
> -  // expected-warning at -1 {{using floating point absolute value function
> '__builtin_fabsl' when argument is of complex type}}
> -  // expected-note at -2 {{use function '__builtin_cabsl' instead}}
> -  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_
> cabsl"
> -
>    (void)__builtin_cabsf(x);
>    // expected-warning at -1 {{absolute value function '__builtin_cabsf'
> given an argument of type '_Complex long double' but has parameter of type
> '_Complex float' which may cause truncation of value}}
>    // expected-note at -2 {{use function '__builtin_cabsl' instead}}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180109/7acca576/attachment-0001.html>


More information about the cfe-commits mailing list