llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: QiYue (QiYueFeiXue) <details> <summary>Changes</summary> Fixes #<!-- -->141397 --- Full diff: https://github.com/llvm/llvm-project/pull/141485.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaChecking.cpp (+5-5) - (added) clang/test/SemaCXX/bug141397.cpp (+16) ``````````diff diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 930e9083365a1..61aeffde338d8 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2907,7 +2907,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, return ExprError(); } - if (MagnitudeTy.getCanonicalType() != SignTy.getCanonicalType()) { + if (!Context.hasSameUnqualifiedType(MagnitudeTy, SignTy)) { return Diag(Sign.get()->getBeginLoc(), diag::err_typecheck_call_different_arg_types) << MagnitudeTy << SignTy; @@ -5265,7 +5265,7 @@ bool Sema::BuiltinComplex(CallExpr *TheCall) { Expr *Real = TheCall->getArg(0); Expr *Imag = TheCall->getArg(1); - if (!Context.hasSameType(Real->getType(), Imag->getType())) { + if (!Context.hasSameUnqualifiedType(Real->getType(), Imag->getType())) { return Diag(Real->getBeginLoc(), diag::err_typecheck_call_different_arg_types) << Real->getType() << Imag->getType() @@ -15568,7 +15568,7 @@ Sema::BuiltinVectorMath(CallExpr *TheCall, if (checkMathBuiltinElementType(*this, LocA, TyA, ArgTyRestr, 1)) return std::nullopt; - if (TyA.getCanonicalType() != TyB.getCanonicalType()) { + if (!Context.hasSameUnqualifiedType(TyA, TyB)) { Diag(LocA, diag::err_typecheck_call_different_arg_types) << TyA << TyB; return std::nullopt; } @@ -15607,8 +15607,8 @@ bool Sema::BuiltinElementwiseTernaryMath( } for (int I = 1; I < 3; ++I) { - if (Args[0]->getType().getCanonicalType() != - Args[I]->getType().getCanonicalType()) { + if (!Context.hasSameUnqualifiedType(Args[0]->getType(), + Args[I]->getType())) { return Diag(Args[0]->getBeginLoc(), diag::err_typecheck_call_different_arg_types) << Args[0]->getType() << Args[I]->getType(); diff --git a/clang/test/SemaCXX/bug141397.cpp b/clang/test/SemaCXX/bug141397.cpp new file mode 100644 index 0000000000000..cb9f13a93f955 --- /dev/null +++ b/clang/test/SemaCXX/bug141397.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify +// expected-no-diagnostics + +// This example uncovered a bug in Sema::BuiltinVectorMath, where we should be +// using ASTContext::hasSameUnqualifiedType(). + +typedef float vec3 __attribute__((ext_vector_type(3))); + +typedef struct { + vec3 b; +} struc; + +vec3 foo(vec3 a,const struc* hi) { + vec3 b = __builtin_elementwise_max((vec3)(0.0f), a); + return __builtin_elementwise_pow(b, hi->b.yyy); +} `````````` </details> https://github.com/llvm/llvm-project/pull/141485 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits