diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/docs/ReleaseNotes.rst | 1 | ||||
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 2 | ||||
-rw-r--r-- | clang/test/Sema/builtins-elementwise-math.c | 11 |
3 files changed, 13 insertions, 1 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 32266fc..dc97883 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -669,6 +669,7 @@ Bug Fixes in This Version base classes. (GH139452) - Fixed an assertion failure in serialization of constexpr structs containing unions. (#GH140130) - Fixed duplicate entries in TableGen that caused the wrong attribute to be selected. (GH#140701) +- Fixed type mismatch error when 'builtin-elementwise-math' arguments have different qualifiers, this should be well-formed. (#GH141397) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index ba2630e..373ca54 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -15572,7 +15572,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; } diff --git a/clang/test/Sema/builtins-elementwise-math.c b/clang/test/Sema/builtins-elementwise-math.c index b5648a5..01057b3 100644 --- a/clang/test/Sema/builtins-elementwise-math.c +++ b/clang/test/Sema/builtins-elementwise-math.c @@ -3,6 +3,7 @@ typedef double double2 __attribute__((ext_vector_type(2))); typedef double double4 __attribute__((ext_vector_type(4))); typedef float float2 __attribute__((ext_vector_type(2))); +typedef float float3 __attribute__((ext_vector_type(3))); typedef float float4 __attribute__((ext_vector_type(4))); typedef int int2 __attribute__((ext_vector_type(2))); @@ -1202,3 +1203,13 @@ void test_builtin_elementwise_fma(int i32, int2 v2i32, short i16, c3 = __builtin_elementwise_fma(f32, f32, c3); // expected-error@-1 {{3rd argument must be a scalar or vector of floating-point types (was '_Complex float')}} } + +typedef struct { + float3 b; +} struct_float3; +// This example uncovered a bug #141397 : +// Type mismatch error when 'builtin-elementwise-math' arguments have different qualifiers, this should be well-formed +float3 foo(float3 a,const struct_float3* hi) { + float3 b = __builtin_elementwise_max((float3)(0.0f), a); + return __builtin_elementwise_pow(b, hi->b.yyy); +} |