[cfe-commits] r159171 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiate.cpp test/Sema/ms_wide_predefined_expr.cpp
Nico Weber
nicolasweber at gmx.de
Mon Jun 25 15:34:48 PDT 2012
Author: nico
Date: Mon Jun 25 17:34:48 2012
New Revision: 159171
URL: http://llvm.org/viewvc/llvm-project?rev=159171&view=rev
Log:
Give L__FUNCTION__ the right type in templates. PR13206.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/Sema/ms_wide_predefined_expr.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=159171&r1=159170&r2=159171&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Mon Jun 25 17:34:48 2012
@@ -1093,7 +1093,11 @@
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 =
Modified: cfe/trunk/test/Sema/ms_wide_predefined_expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ms_wide_predefined_expr.cpp?rev=159171&r1=159170&r2=159171&view=diff
==============================================================================
--- cfe/trunk/test/Sema/ms_wide_predefined_expr.cpp (original)
+++ cfe/trunk/test/Sema/ms_wide_predefined_expr.cpp Mon Jun 25 17:34:48 2012
@@ -7,3 +7,19 @@
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();
+}
+}
More information about the cfe-commits
mailing list