Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td	(revision 178582)
+++ include/clang/Basic/DiagnosticSemaKinds.td	(working copy)
@@ -6203,7 +6203,9 @@
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
   "sampler type cannot be used with the __local and __global address space qualifiers">;
-
+def err_opencl_global_invalid_addr_space : Error<
+  "global variables must have a constant address space qualifier">;
+  
 // OpenMP support.
 def err_omp_expected_var_arg_suggest : Error<
   "%0 is not a global variable, static local variable or static data member%select{|; did you mean %2?}1">;
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp	(revision 178582)
+++ lib/Sema/SemaDecl.cpp	(working copy)
@@ -5199,6 +5199,16 @@
     return false;
   }
 
+  // OpenCL v1.2 s6.5 - All program scope variables must be declared in the
+  // __constant address space.
+  if (getLangOpts().OpenCL && NewVD->isFileVarDecl()
+      && T.getAddressSpace() != LangAS::opencl_constant
+      && !T->isSamplerT()){
+    Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space);
+    NewVD->setInvalidDecl();
+    return false;
+  }
+  
   // OpenCL v1.2 s6.8 -- The static qualifier is valid only in program
   // scope.
   if ((getLangOpts().OpenCLVersion >= 120)
Index: test/SemaOpenCL/event_t.cl
===================================================================
--- test/SemaOpenCL/event_t.cl	(revision 178582)
+++ test/SemaOpenCL/event_t.cl	(working copy)
@@ -2,7 +2,7 @@
 
 event_t glb_evt; // expected-error {{the event_t type cannot be used to declare a program scope variable}}
 
-struct evt_s {
+constant struct evt_s {
   event_t evt;  // expected-error {{the event_t type cannot be used to declare a structure or union field}}
 } evt_str;
 
Index: test/SemaOpenCL/storageclass.cl
===================================================================
--- test/SemaOpenCL/storageclass.cl	(revision 178582)
+++ test/SemaOpenCL/storageclass.cl	(working copy)
@@ -2,6 +2,8 @@
 
 static constant int A = 0;
 
+int X = 0; // expected-error{{global variables must have a constant address space qualifier}}
+
 // static is not allowed at local scope.
 void kernel foo() {
   static int X = 5; // expected-error{{variables in function scope cannot be declared static}} 
