Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp	(revision 209804)
+++ lib/Frontend/CompilerInvocation.cpp	(working copy)
@@ -1114,18 +1114,13 @@
   Opts.ImplicitInt = Std.hasImplicitInt();
 
   // Set OpenCL Version.
-  if (LangStd == LangStandard::lang_opencl) {
-    Opts.OpenCL = 1;
+  Opts.OpenCL = LangStd == LangStandard::lang_opencl || IK == IK_OpenCL;
+  if (LangStd == LangStandard::lang_opencl)
     Opts.OpenCLVersion = 100;
-  }
-  else if (LangStd == LangStandard::lang_opencl11) {
-      Opts.OpenCL = 1;
+  else if (LangStd == LangStandard::lang_opencl11)
       Opts.OpenCLVersion = 110;
-  }
-  else if (LangStd == LangStandard::lang_opencl12) {
-    Opts.OpenCL = 1;
+  else if (LangStd == LangStandard::lang_opencl12)
     Opts.OpenCLVersion = 120;
-  }
   
   // OpenCL has some additional defaults.
   if (Opts.OpenCL) {
@@ -1136,8 +1131,7 @@
     Opts.NativeHalfType = 1;
   }
 
-  if (LangStd == LangStandard::lang_cuda)
-    Opts.CUDA = 1;
+  Opts.CUDA = LangStd == LangStandard::lang_cuda || IK == IK_CUDA;
 
   // OpenCL and C++ both have bool, true, false keywords.
   Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
Index: test/Frontend/stdlang.c
===================================================================
--- test/Frontend/stdlang.c	(revision 0)
+++ test/Frontend/stdlang.c	(working copy)
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
+// RUN: %clang_cc1 -x cl -std=c99 -DOPENCL %s
+// expected-no-diagnostics
+
+#if defined(CUDA)
+  __attribute__((device)) void f_device();
+#elif defined(OPENCL)
+  kernel void func(void);
+#endif
Index: test/Index/attributes-cuda.cu
===================================================================
--- test/Index/attributes-cuda.cu	(revision 209808)
+++ test/Index/attributes-cuda.cu	(working copy)
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-load-source all -x cuda -std=cuda %s | FileCheck %s
+// RUN: c-index-test -test-load-source all -x cuda %s | FileCheck %s
 
 __attribute__((device)) void f_device();
 __attribute__((global)) void f_global();
@@ -5,7 +5,6 @@
 __attribute__((constant)) int* g_constant;
 __attribute__((host)) void f_host();
 
-
 // CHECK:       attributes-cuda.cu:3:30: FunctionDecl=f_device:3:30
 // CHECK-NEXT:  attributes-cuda.cu:3:16: attribute(device)
 // CHECK:       attributes-cuda.cu:4:30: FunctionDecl=f_global:4:30
