[cfe-commits] r106523 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaTemplate/array-to-pointer-decay.cpp
Douglas Gregor
dgregor at apple.com
Mon Jun 21 19:41:06 PDT 2010
Author: dgregor
Date: Mon Jun 21 21:41:05 2010
New Revision: 106523
URL: http://llvm.org/viewvc/llvm-project?rev=106523&view=rev
Log:
Apply array-to-pointer decay when instantiating a MemberExpr. Fixes
PR7405, patch by Kyle Lippincott!
Added:
cfe/trunk/test/SemaTemplate/array-to-pointer-decay.cpp (with props)
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=106523&r1=106522&r2=106523&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Jun 21 21:41:05 2010
@@ -1174,7 +1174,9 @@
SS.setScopeRep(Qualifier);
}
- QualType BaseType = ((Expr*) Base.get())->getType();
+ Expr *BaseExpr = Base.takeAs<Expr>();
+ getSema().DefaultFunctionArrayConversion(BaseExpr);
+ QualType BaseType = BaseExpr->getType();
// FIXME: this involves duplicating earlier analysis in a lot of
// cases; we should avoid this when possible.
@@ -1183,8 +1185,8 @@
R.addDecl(FoundDecl);
R.resolveKind();
- return getSema().BuildMemberReferenceExpr(move(Base), BaseType,
- OpLoc, isArrow,
+ return getSema().BuildMemberReferenceExpr(getSema().Owned(BaseExpr),
+ BaseType, OpLoc, isArrow,
SS, FirstQualifierInScope,
R, ExplicitTemplateArgs);
}
Added: cfe/trunk/test/SemaTemplate/array-to-pointer-decay.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/array-to-pointer-decay.cpp?rev=106523&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/array-to-pointer-decay.cpp (added)
+++ cfe/trunk/test/SemaTemplate/array-to-pointer-decay.cpp Mon Jun 21 21:41:05 2010
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct mystruct {
+ int member;
+};
+
+template <int i>
+int foo() {
+ mystruct s[1];
+ return s->member;
+}
+
+int main() {
+ foo<1>();
+}
+
+// PR7405
+struct hb_sanitize_context_t {
+ int start;
+};
+template <typename Type> static bool sanitize() {
+ hb_sanitize_context_t c[1];
+ return !c->start;
+}
+bool closure = sanitize<int>();
Propchange: cfe/trunk/test/SemaTemplate/array-to-pointer-decay.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/SemaTemplate/array-to-pointer-decay.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/SemaTemplate/array-to-pointer-decay.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list