Give L__FUNCTION__ the right type in templates. PR13206.

llvm-svn: 159171
This commit is contained in:
Nico Weber 2012-06-25 22:34:48 +00:00
parent 1598289c72
commit 606cef46e3
2 changed files with 21 additions and 1 deletions

View File

@ -1093,7 +1093,11 @@ TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) {
unsigned Length = PredefinedExpr::ComputeName(IT, currentDecl).length();
llvm::APInt LengthI(32, Length + 1);
QualType ResTy = getSema().Context.CharTy.withConst();
QualType ResTy;
if (IT == PredefinedExpr::LFunction)
ResTy = getSema().Context.WCharTy.withConst();
else
ResTy = getSema().Context.CharTy.withConst();
ResTy = getSema().Context.getConstantArrayType(ResTy, LengthI,
ArrayType::Normal, 0);
PredefinedExpr *PE =

View File

@ -7,3 +7,19 @@ void abcdefghi12(void) {
const wchar_t (*ss)[12] = &STR2WSTR(__FUNCTION__);
static int arr[sizeof(STR2WSTR(__FUNCTION__))==12*sizeof(wchar_t) ? 1 : -1];
}
namespace PR13206 {
void foo(const wchar_t *);
template<class T> class A {
public:
void method() {
foo(L__FUNCTION__);
}
};
void bar() {
A<int> x;
x.method();
}
}