]> granicus.if.org Git - clang/commitdiff
Enable overloading of OpenCL events - this is needed for the overloaded OpenCL builti...
authorGuy Benyei <guy.benyei@intel.com>
Thu, 7 Feb 2013 16:05:33 +0000 (16:05 +0000)
committerGuy Benyei <guy.benyei@intel.com>
Thu, 7 Feb 2013 16:05:33 +0000 (16:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174630 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Overload.h
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaOverload.cpp
test/SemaOpenCL/event_t_overload.cl [new file with mode: 0644]

index 8a2cef73360c1082e13fac76935a35c02249d44b..c052495f807ebf7f0b5f09df9ef36f4dd7c7c2c2 100644 (file)
@@ -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
   };
 
index c70041ba511ef2c0f2697991fd26f4eba42354b4..7f24af8be19e870e8e7e82e22dcf601ae9aca184 100644 (file)
@@ -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:
index ac9dec4e6c92a89bc17d9b7b78af69c243834e4d..6fa41379703a5342bea7aa3aea683e9a56823de0 100644 (file)
@@ -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:
diff --git a/test/SemaOpenCL/event_t_overload.cl b/test/SemaOpenCL/event_t_overload.cl
new file mode 100644 (file)
index 0000000..bc3ec44
--- /dev/null
@@ -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'}}
+}