[cfe-commits] r91887 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaTemplate/instantiate-member-expr.cpp

Anders Carlsson andersca at mac.com
Mon Dec 21 21:24:09 PST 2009


Author: andersca
Date: Mon Dec 21 23:24:09 2009
New Revision: 91887

URL: http://llvm.org/viewvc/llvm-project?rev=91887&view=rev
Log:
When we simply return a retained member expression when instantiating, we must also mark the member decl as referenced.

Added:
    cfe/trunk/test/SemaTemplate/instantiate-member-expr.cpp
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=91887&r1=91886&r2=91887&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Dec 21 23:24:09 2009
@@ -3688,8 +3688,13 @@
       Base.get() == E->getBase() &&
       Qualifier == E->getQualifier() &&
       Member == E->getMemberDecl() &&
-      !E->hasExplicitTemplateArgumentList())
+      !E->hasExplicitTemplateArgumentList()) {
+    
+    // Mark it referenced in the new context regardless.
+    // FIXME: this is a bit instantiation-specific.
+    SemaRef.MarkDeclarationReferenced(E->getMemberLoc(), Member);
     return SemaRef.Owned(E->Retain());
+  }
 
   TemplateArgumentListInfo TransArgs;
   if (E->hasExplicitTemplateArgumentList()) {

Added: cfe/trunk/test/SemaTemplate/instantiate-member-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-member-expr.cpp?rev=91887&view=auto

==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-member-expr.cpp (added)
+++ cfe/trunk/test/SemaTemplate/instantiate-member-expr.cpp Mon Dec 21 23:24:09 2009
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+struct S {
+ S() { }
+};
+
+template<typename T>
+struct vector {
+  void push_back(const T&) { int a[sizeof(T) ? -1: -1]; } // expected-error {{array size is negative}}
+};
+
+class GRExprEngine {
+public:
+ typedef vector<S<void *> >CheckersOrdered;
+ CheckersOrdered Checkers;
+
+ template <typename CHECKER>
+ void registerCheck(CHECKER *check) {
+   Checkers.push_back(S<void *>()); // expected-note {{in instantiation of member function 'vector<struct S<void *> >::push_back' requested here}}
+ }
+};
+
+class RetainReleaseChecker { };
+
+void f(GRExprEngine& Eng) {
+   Eng.registerCheck(new RetainReleaseChecker); // expected-note {{in instantiation of function template specialization 'GRExprEngine::registerCheck<class RetainReleaseChecker>' requested here}}
+}





More information about the cfe-commits mailing list