diff options
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 3466da6e5a7..ba4b67a23d4 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -3900,6 +3900,31 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc, S.Context.getTypeSize(SCS1.getToType(2))) return ImplicitConversionSequence::Better; + // Prefer a compatible vector conversion over a lax vector conversion + // For example: + // + // typedef float __v4sf __attribute__((__vector_size__(16))); + // void f(vector float); + // void f(vector signed int); + // int main() { + // __v4sf a; + // f(a); + // } + // Here, we'd like to choose f(vector float) and not + // report an ambiguous call error + if (SCS1.Second == ICK_Vector_Conversion && + SCS2.Second == ICK_Vector_Conversion) { + bool SCS1IsCompatibleVectorConversion = S.Context.areCompatibleVectorTypes( + SCS1.getFromType(), SCS1.getToType(2)); + bool SCS2IsCompatibleVectorConversion = S.Context.areCompatibleVectorTypes( + SCS2.getFromType(), SCS2.getToType(2)); + + if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion) + return SCS1IsCompatibleVectorConversion + ? ImplicitConversionSequence::Better + : ImplicitConversionSequence::Worse; + } + return ImplicitConversionSequence::Indistinguishable; } |