diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 688150a..b2efbdb 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -2581,6 +2581,27 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
           T = S.BuildQualifiedType(T, DeclType.Loc, DeclType.Ptr.TypeQuals);
         break;
       }
+      // OpenCLC v2.0, s6.5: by default pointers point to the __generic address
+      // space.
+      if (LangOpts.OpenCL && LangOpts.OpenCLVersion >= 200) {
+        bool IsASQualified = false;
+        // Iterate through attribute list looking for any address space
+        // qualifier.
+        for (auto attr_it = D.getDeclSpec().getAttributes().getList(); attr_it;
+             attr_it->getNext()) {
+          AttributeList::Kind attr_kd = attr_it->getKind();
+          if (attr_kd == AttributeList::AT_OpenCLPrivateAddressSpace ||
+              attr_kd == AttributeList::AT_OpenCLGlobalAddressSpace ||
+              attr_kd == AttributeList::AT_OpenCLLocalAddressSpace ||
+              attr_kd == AttributeList::AT_OpenCLConstantAddressSpace ||
+              attr_kd == AttributeList::AT_OpenCLGenericAddressSpace) {
+            IsASQualified = true;
+            break;
+          }
+        }
+        if (!IsASQualified) {
+          T = S.Context.getAddrSpaceQualType(T, LangAS::opencl_generic);
+        }
+      }
       T = S.BuildPointerType(T, DeclType.Loc, Name);
       if (DeclType.Ptr.TypeQuals)
         T = S.BuildQualifiedType(T, DeclType.Loc, DeclType.Ptr.TypeQuals);
diff --git a/test/CodeGenOpenCL/address-spaces.cl b/test/CodeGenOpenCL/address-spaces.cl
index e030c77..257ceac 100644
--- a/test/CodeGenOpenCL/address-spaces.cl
+++ b/test/CodeGenOpenCL/address-spaces.cl
@@ -1,27 +1,43 @@
-// RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s -check-prefix=CL10
+// RUN: %clang_cc1 %s -ffake-address-space-map -cl-std=CL2.0 -DCL20 -emit-llvm -o - | FileCheck %s -check-prefix=CL20
 
 void f__p(__private int *arg) { }
-// CHECK: i32* nocapture %arg
+// CL10: i32* nocapture %arg
 
 void f__g(__global int *arg) { }
-// CHECK: i32 addrspace(1)* nocapture %arg
+// CL10: i32 addrspace(1)* nocapture %arg
 
 void f__l(__local int *arg) { }
-// CHECK: i32 addrspace(2)* nocapture %arg
+// CL10: i32 addrspace(2)* nocapture %arg
 
 void f__c(__constant int *arg) { }
-// CHECK: i32 addrspace(3)* nocapture %arg
+// CL10: i32 addrspace(3)* nocapture %arg
 
+#ifdef CL20
+void f__gen(__generic int *arg) { }
+// CL20: i32 addrspace(4)* nocapture %arg
+#endif
 
 void fp(private int *arg) { }
-// CHECK: i32* nocapture %arg
+// CL10: i32* nocapture %arg
 
 void fg(global int *arg) { }
-// CHECK: i32 addrspace(1)* nocapture %arg
+// CL10: i32 addrspace(1)* nocapture %arg
 
 void fl(local int *arg) { }
-// CHECK: i32 addrspace(2)* nocapture %arg
+// CL10: i32 addrspace(2)* nocapture %arg
 
 void fc(constant int *arg) { }
-// CHECK: i32 addrspace(3)* nocapture %arg
-
+// CL10: i32 addrspace(3)* nocapture %arg
+
+#ifdef CL20
+void fgen(generic int *arg) { }
+// CL20: i32 addrspace(4)* nocapture %arg
+#endif
+
+void f_default(int *arg) { }
+#ifdef CL20
+// CL20: i32 addrspace(4)* nocapture %arg
+#else
+// CL10: i32* nocapture %arg
+#endif
