Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -3052,6 +3052,8 @@ /*Pascal*/ false, ResTy, Loc); } else { ResTy = Context.CharTy.withConst(); + if (LangOpts.OpenCL) + ResTy = Context.getAddrSpaceQualType(ResTy, LangAS::opencl_constant); ResTy = Context.getConstantArrayType(ResTy, LengthI, ArrayType::Normal, /*IndexTypeQuals*/ 0); SL = StringLiteral::Create(Context, Str, StringLiteral::Ascii, Index: test/SemaOpenCL/predefind-expr.cl =================================================================== --- /dev/null +++ test/SemaOpenCL/predefind-expr.cl @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 %s -verify + +void f() { +char * f1 = __func__;//expected-error{{initializing 'char *' with an expression of type 'const __constant char *' changes address space of pointer}} +constant char * f2 = __func__;//expected-warning{{initializing '__constant char *' with an expression of type 'const __constant char [2]' discards qualifiers}} +constant const char * f3 = __func__; +}