]> granicus.if.org Git - clang/commitdiff
Give L__FUNCTION__ the right type in templates. PR13206.
authorNico Weber <nicolasweber@gmx.de>
Mon, 25 Jun 2012 22:34:48 +0000 (22:34 +0000)
committerNico Weber <nicolasweber@gmx.de>
Mon, 25 Jun 2012 22:34:48 +0000 (22:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159171 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiate.cpp
test/Sema/ms_wide_predefined_expr.cpp

index b26e79b135e64e65c4fa2201738db78b95421a03..b80aaa2bbcafdae2f2e1c3bc425a82d91b4620a2 100644 (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 =
index 4df64dc0219a1a81be7546f583b3655da6ba26ab..8e816e00b37a2291bed40b1f8a1390cd595442b6 100644 (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();
+}
+}