[cfe-commits] r143017 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaTemplate/instantiate-expr-4.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Tue Oct 25 23:49:26 PDT 2011
Author: rsmith
Date: Wed Oct 26 01:49:26 2011
New Revision: 143017
URL: http://llvm.org/viewvc/llvm-project?rev=143017&view=rev
Log:
Fix crash due to missing array-to-pointer decay when instantiating an unresolved
member expression. Refactoring to follow.
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=143017&r1=143016&r2=143017&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Oct 26 01:49:26 2011
@@ -2145,11 +2145,17 @@
CXXScopeSpec SS;
SS.Adopt(QualifierLoc);
- if (BaseE && IsArrow) {
- ExprResult BaseResult = getSema().DefaultLvalueConversion(BaseE);
+ if (BaseE) {
+ ExprResult BaseResult = getSema().DefaultFunctionArrayConversion(BaseE);
if (BaseResult.isInvalid())
return ExprError();
+ if (IsArrow) {
+ BaseResult = getSema().DefaultLvalueConversion(BaseResult.take());
+ if (BaseResult.isInvalid())
+ return ExprError();
+ }
BaseE = BaseResult.take();
+ BaseType = BaseE->getType();
}
return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
@@ -7701,7 +7707,6 @@
Base = getDerived().TransformExpr(Old->getBase());
if (Base.isInvalid())
return ExprError();
- BaseType = ((Expr*) Base.get())->getType();
} else {
BaseType = getDerived().TransformType(Old->getBaseType());
}
Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp?rev=143017&r1=143016&r2=143017&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp Wed Oct 26 01:49:26 2011
@@ -282,6 +282,16 @@
template struct ArrowMemRef0<ArrowWrapper<MemInt*>, float&>; // expected-note{{instantiation}}
template struct ArrowMemRef0<ArrowWrapper<ArrowWrapper<MemInt*> >, int&>;
+struct UnresolvedMemRefArray {
+ int f(int);
+ int f(char);
+};
+UnresolvedMemRefArray Arr[10];
+template<typename U> int UnresolvedMemRefArrayT(U u) {
+ return Arr->f(u);
+}
+template int UnresolvedMemRefArrayT<int>(int);
+
// FIXME: we should be able to return a MemInt without the reference!
MemInt &createMemInt(int);
More information about the cfe-commits
mailing list