r174630 - Enable overloading of OpenCL events - this is needed for the overloaded OpenCL builtin functions.
Guy Benyei
guy.benyei at intel.com
Thu Feb 7 08:05:33 PST 2013
Author: gbenyei
Date: Thu Feb 7 10:05:33 2013
New Revision: 174630
URL: http://llvm.org/viewvc/llvm-project?rev=174630&view=rev
Log:
Enable overloading of OpenCL events - this is needed for the overloaded OpenCL builtin functions.
Added:
cfe/trunk/test/SemaOpenCL/event_t_overload.cl
Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=174630&r1=174629&r2=174630&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Thu Feb 7 10:05:33 2013
@@ -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
};
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=174630&r1=174629&r2=174630&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Feb 7 10:05:33 2013
@@ -2783,6 +2783,12 @@ Sema::PerformImplicitConversion(Expr *Fr
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:
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=174630&r1=174629&r2=174630&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Feb 7 10:05:33 2013
@@ -1633,6 +1633,11 @@ static bool IsStandardConversion(Sema &S
// 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 CheckConvertedConstantConver
case ICK_Identity:
case ICK_Integral_Promotion:
case ICK_Integral_Conversion:
+ case ICK_Zero_Event_Conversion:
return true;
case ICK_Boolean_Conversion:
Added: cfe/trunk/test/SemaOpenCL/event_t_overload.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/event_t_overload.cl?rev=174630&view=auto
==============================================================================
--- cfe/trunk/test/SemaOpenCL/event_t_overload.cl (added)
+++ cfe/trunk/test/SemaOpenCL/event_t_overload.cl Thu Feb 7 10:05:33 2013
@@ -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'}}
+}
More information about the cfe-commits
mailing list