Index: include/clang/Basic/TargetInfo.h
===================================================================
--- include/clang/Basic/TargetInfo.h	(revision 186944)
+++ include/clang/Basic/TargetInfo.h	(working copy)
@@ -349,7 +349,7 @@
     // Currently we assume the register width on the target matches the pointer
     // width, we can introduce a new variable for this if/when some target wants
     // it.
-    return LongWidth; 
+    return PointerWidth; 
   }
 
   /// \brief Returns the default value of the __USER_LABEL_PREFIX__ macro,
Index: lib/Basic/TargetInfo.cpp
===================================================================
--- lib/Basic/TargetInfo.cpp	(revision 186944)
+++ lib/Basic/TargetInfo.cpp	(working copy)
@@ -188,6 +188,40 @@
     UseBitFieldTypeAlignment = false;
   if (Opts.ShortWChar)
     WCharType = UnsignedShort;
+
+  if (Opts.OpenCL) {
+    // Long is 64-bits by the OpenCL language standard, irrespective
+    // of what it normally is for the target. The other integer types
+    // are set up correctly for OpenCL by all targets currently.
+    HalfWidth = HalfAlign = 16;
+    LongWidth = LongAlign = 64;
+    LongLongWidth = LongLongAlign = 128;
+    LongDoubleWidth = LongDoubleAlign = 128;
+    //??? LargeArrayMinWidth = LargeArrayAlign = 128;
+
+    assert(PointerWidth == 32 || PointerWidth == 64);
+    bool is32BitArch = PointerWidth == 32;
+    SizeType = is32BitArch ? UnsignedInt : UnsignedLong;
+    PtrDiffType = is32BitArch ? SignedInt : SignedLong;
+    IntPtrType = is32BitArch ? SignedInt : SignedLong;
+
+    IntMaxType = SignedLongLong;
+    UIntMaxType = UnsignedLongLong;
+    Int64Type = SignedLong;
+
+    HalfFormat = &llvm::APFloat::IEEEhalf;
+    FloatFormat = &llvm::APFloat::IEEEsingle;
+    DoubleFormat = &llvm::APFloat::IEEEdouble;
+    LongDoubleFormat = &llvm::APFloat::IEEEquad;
+
+    static const LangAS::Map OpenCLAddrSpaceMap = {
+      1, // opencl_global
+      2, // opencl_constant
+      3  // opencl_local
+    };
+
+    AddrSpaceMap = &OpenCLAddrSpaceMap;
+  }
 }
 
 //===----------------------------------------------------------------------===//
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp	(revision 186944)
+++ lib/Frontend/CompilerInvocation.cpp	(working copy)
@@ -1236,7 +1236,7 @@
   Opts.Blocks = Args.hasArg(OPT_fblocks);
   Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
   Opts.Modules = Args.hasArg(OPT_fmodules);
-  Opts.CharIsSigned = !Args.hasArg(OPT_fno_signed_char);
+  Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
   Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);
   Opts.ShortWChar = Args.hasArg(OPT_fshort_wchar);
   Opts.ShortEnums = Args.hasArg(OPT_fshort_enums);
@@ -1246,7 +1246,7 @@
   Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
   Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
   Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
-  Opts.MathErrno = Args.hasArg(OPT_fmath_errno);
+  Opts.MathErrno = !Opts.OpenCL && Args.hasArg(OPT_fmath_errno);
   Opts.InstantiationDepth = Args.getLastArgIntValue(OPT_ftemplate_depth, 256,
                                                     Diags);
   Opts.ConstexprCallDepth = Args.getLastArgIntValue(OPT_fconstexpr_depth, 512,
