mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
Enable overloading of OpenCL events - this is needed for the overloaded OpenCL builtin functions.
llvm-svn: 174630
This commit is contained in:
@@ -80,6 +80,7 @@ namespace clang {
|
||||
ICK_Block_Pointer_Conversion, ///< Block Pointer conversions
|
||||
ICK_TransparentUnionConversion, /// Transparent Union Conversions
|
||||
ICK_Writeback_Conversion, ///< Objective-C ARC writeback conversion
|
||||
ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2 6.12.10)
|
||||
ICK_Num_Conversion_Kinds ///< The number of conversion kinds
|
||||
};
|
||||
|
||||
|
||||
@@ -2783,6 +2783,12 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
|
||||
break;
|
||||
}
|
||||
|
||||
case ICK_Zero_Event_Conversion:
|
||||
From = ImpCastExprToType(From, ToType,
|
||||
CK_ZeroToOCLEvent,
|
||||
From->getValueKind()).take();
|
||||
break;
|
||||
|
||||
case ICK_Lvalue_To_Rvalue:
|
||||
case ICK_Array_To_Pointer:
|
||||
case ICK_Function_To_Pointer:
|
||||
|
||||
@@ -1633,6 +1633,11 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
|
||||
// tryAtomicConversion has updated the standard conversion sequence
|
||||
// appropriately.
|
||||
return true;
|
||||
} else if (ToType->isEventT() &&
|
||||
From->isIntegerConstantExpr(S.getASTContext()) &&
|
||||
(From->EvaluateKnownConstInt(S.getASTContext()) == 0)) {
|
||||
SCS.Second = ICK_Zero_Event_Conversion;
|
||||
FromType = ToType;
|
||||
} else {
|
||||
// No second conversion required.
|
||||
SCS.Second = ICK_Identity;
|
||||
@@ -4871,6 +4876,7 @@ static bool CheckConvertedConstantConversions(Sema &S,
|
||||
case ICK_Identity:
|
||||
case ICK_Integral_Promotion:
|
||||
case ICK_Integral_Conversion:
|
||||
case ICK_Zero_Event_Conversion:
|
||||
return true;
|
||||
|
||||
case ICK_Boolean_Conversion:
|
||||
|
||||
11
clang/test/SemaOpenCL/event_t_overload.cl
Normal file
11
clang/test/SemaOpenCL/event_t_overload.cl
Normal file
@@ -0,0 +1,11 @@
|
||||
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
|
||||
|
||||
void __attribute__((overloadable)) foo(event_t, __local char *); // expected-note {{candidate function not viable: no known conversion from '__global int *' to '__local char *' for 2nd argument}}
|
||||
void __attribute__((overloadable)) foo(event_t, __local float *); // expected-note {{candidate function not viable: no known conversion from '__global int *' to '__local float *' for 2nd argument}}
|
||||
|
||||
void kernel ker(__local char *src1, __local float *src2, __global int *src3) {
|
||||
event_t evt;
|
||||
foo(evt, src1);
|
||||
foo(0, src2);
|
||||
foo(evt, src3); // expected-error {{no matching function for call to 'foo'}}
|
||||
}
|
||||
Reference in New Issue
Block a user