Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -1467,6 +1467,12 @@ if (getLangOpts().CPlusPlus || getLangOpts().ConstStrings) StrTy.addConst(); + // OpenCL v1.1 s6.5.3: a string literal is in the constant address space. + if (getLangOpts().OpenCL) { + StrTy.addConst(); + StrTy = Context.getAddrSpaceQualType(StrTy, LangAS::opencl_constant); + } + // Get an array type for the string, according to C99 6.4.5. This includes // the nul terminator character as well as the string length for pascal // strings. Index: lib/Sema/SemaType.cpp =================================================================== --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -3829,6 +3829,10 @@ unsigned ASIdx = static_cast(addrSpace.getZExtValue()); Type = S.Context.getAddrSpaceQualType(Type, ASIdx); + + // Constant address space implies const qualifier + if(S.getLangOpts().OpenCL && ASIdx == LangAS::opencl_constant) + Type = S.Context.getConstType(Type); } /// Does this type have a "direct" ownership qualifier? That is, Index: test/SemaOpenCL/str_literals.cl =================================================================== --- /dev/null +++ test/SemaOpenCL/str_literals.cl @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -verify +// expected-no-diagnostics + +__constant char * __constant x = "hello world"; + +void foo(__constant char * a) { + +} + +void bar() { + foo("hello world"); +}