[cfe-commits] r113708 - in /cfe/trunk: include/clang/AST/EvaluatedExprVisitor.h lib/Sema/SemaExpr.cpp test/SemaTemplate/default-expr-arguments.cpp
Douglas Gregor
dgregor at apple.com
Sat Sep 11 16:32:50 PDT 2010
Author: dgregor
Date: Sat Sep 11 18:32:50 2010
New Revision: 113708
URL: http://llvm.org/viewvc/llvm-project?rev=113708&view=rev
Log:
Teach the EvaluatedExprVisitor and its client, which marks
declarations in potentially-evaluated subexpressions, about
recursion. Fixes the release-mode self-host failure I introduced in
r113700.
Modified:
cfe/trunk/include/clang/AST/EvaluatedExprVisitor.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp
Modified: cfe/trunk/include/clang/AST/EvaluatedExprVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/EvaluatedExprVisitor.h?rev=113708&r1=113707&r2=113708&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/EvaluatedExprVisitor.h (original)
+++ cfe/trunk/include/clang/AST/EvaluatedExprVisitor.h Sat Sep 11 18:32:50 2010
@@ -67,6 +67,14 @@
if (cast<CXXRecordDecl>(Record->getDecl())->isPolymorphic())
return this->Visit(E->getExprOperand());
}
+
+ /// \brief The basis case walks all of the children of the statement or
+ /// expression, assuming they are all potentially evaluated.
+ void VisitStmt(Stmt *S) {
+ for(Stmt::child_iterator C = S->child_begin(), CEnd = S->child_end();
+ C != CEnd; ++C)
+ this->Visit(*C);
+ }
};
}
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=113708&r1=113707&r2=113708&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Sep 11 18:32:50 2010
@@ -3454,6 +3454,8 @@
ExprTemporaries.push_back(Param->getDefaultArgTemporary(i));
// We already type-checked the argument, so we know it works.
+ // Just mark all of the declarations in this potentially-evaluated expression
+ // as being "referenced".
MarkDeclarationsReferencedInExpr(Param->getDefaultArg());
return Owned(CXXDefaultArgExpr::Create(Context, CallLoc, Param));
}
@@ -7816,6 +7818,7 @@
void VisitMemberExpr(MemberExpr *E) {
S.MarkDeclarationReferenced(E->getMemberLoc(), E->getMemberDecl());
+ Inherited::VisitMemberExpr(E);
}
void VisitCXXNewExpr(CXXNewExpr *E) {
@@ -7825,15 +7828,18 @@
S.MarkDeclarationReferenced(E->getLocStart(), E->getOperatorNew());
if (E->getOperatorDelete())
S.MarkDeclarationReferenced(E->getLocStart(), E->getOperatorDelete());
+ Inherited::VisitCXXNewExpr(E);
}
void VisitCXXDeleteExpr(CXXDeleteExpr *E) {
if (E->getOperatorDelete())
S.MarkDeclarationReferenced(E->getLocStart(), E->getOperatorDelete());
+ Inherited::VisitCXXDeleteExpr(E);
}
void VisitCXXConstructExpr(CXXConstructExpr *E) {
S.MarkDeclarationReferenced(E->getLocStart(), E->getConstructor());
+ Inherited::VisitCXXConstructExpr(E);
}
void VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp?rev=113708&r1=113707&r2=113708&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp Sat Sep 11 18:32:50 2010
@@ -218,6 +218,24 @@
void g() { f(17); }
}
+namespace PR5810c {
+ template<typename T>
+ struct X {
+ X() {
+ T t;
+ double *****p = t; // expected-error{{cannot initialize a variable of type 'double *****' with an lvalue of type 'int'}}
+ }
+ X(const X&) { }
+ };
+
+ struct Y : X<int> { // expected-note{{instantiation of}}
+ };
+
+ void f(Y y = Y());
+
+ void g() { f(); }
+}
+
namespace PR8127 {
template< typename T > class PointerClass {
public:
More information about the cfe-commits
mailing list