[cfe-commits] r112282 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaCXX/member-pointer.cpp test/SemaTemplate/instantiate-clang.cpp test/SemaTemplate/instantiate-expr-3.cpp test/SemaTemplate/instantiate-expr-4.cpp test/SemaTemplate/instantiate-function-1.cpp

John McCall rjmccall at apple.com
Fri Aug 27 12:56:05 PDT 2010


Author: rjmccall
Date: Fri Aug 27 14:56:05 2010
New Revision: 112282

URL: http://llvm.org/viewvc/llvm-project?rev=112282&view=rev
Log:
Continue to instantiate sub-statements in a CompoundStmt as long as
we don't see a DeclStmt (failure to instantiate which generally causes
panic).


Modified:
    cfe/trunk/lib/Sema/TreeTransform.h
    cfe/trunk/test/SemaCXX/member-pointer.cpp
    cfe/trunk/test/SemaTemplate/instantiate-clang.cpp
    cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp
    cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
    cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=112282&r1=112281&r2=112282&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Fri Aug 27 14:56:05 2010
@@ -3440,18 +3440,30 @@
 StmtResult
 TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S,
                                               bool IsStmtExpr) {
+  bool SubStmtInvalid = false;
   bool SubStmtChanged = false;
   ASTOwningVector<Stmt*> Statements(getSema());
   for (CompoundStmt::body_iterator B = S->body_begin(), BEnd = S->body_end();
        B != BEnd; ++B) {
     StmtResult Result = getDerived().TransformStmt(*B);
-    if (Result.isInvalid())
-      return StmtError();
+    if (Result.isInvalid()) {
+      // Immediately fail if this was a DeclStmt, since it's very
+      // likely that this will cause problems for future statements.
+      if (isa<DeclStmt>(*B))
+        return StmtError();
+
+      // Otherwise, just keep processing substatements and fail later.
+      SubStmtInvalid = true;
+      continue;
+    }
 
     SubStmtChanged = SubStmtChanged || Result.get() != *B;
     Statements.push_back(Result.takeAs<Stmt>());
   }
 
+  if (SubStmtInvalid)
+    return StmtError();
+
   if (!getDerived().AlwaysRebuild() &&
       !SubStmtChanged)
     return SemaRef.Owned(S->Retain());

Modified: cfe/trunk/test/SemaCXX/member-pointer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-pointer.cpp?rev=112282&r1=112281&r2=112282&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-pointer.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-pointer.cpp Fri Aug 27 14:56:05 2010
@@ -179,13 +179,11 @@
   // We can't call this with an overload set because we're not allowed
   // to look into overload sets unless the parameter has some kind of
   // function type.
-  template <class F> void bind(F f); // expected-note 6 {{candidate template ignored}}
+  template <class F> void bind(F f); // expected-note 12 {{candidate template ignored}}
   template <class F, class T> void bindmem(F (T::*f)()); // expected-note 4 {{candidate template ignored}}
   template <class F> void bindfn(F (*f)()); // expected-note 4 {{candidate template ignored}}
 
   struct A {
-    void member();
-
     void nonstat();
     void nonstat(int);
 
@@ -234,4 +232,41 @@
       }
     };
   };
+
+  template <class T> class B {
+    void nonstat();
+    void nonstat(int);
+
+    void mixed();
+    static void mixed(int);
+
+    static void stat();
+    static void stat(int);
+
+    // None of these can be diagnosed yet, because the arguments are
+    // still dependent.
+    void test0a() {
+      bind(&nonstat);
+      bind(&B::nonstat);
+
+      bind(&mixed);
+      bind(&B::mixed);
+
+      bind(&stat);
+      bind(&B::stat);
+    }
+
+    void test0b() {
+      bind(&nonstat); // expected-error {{no matching function for call}}
+      bind(&B::nonstat); // expected-error {{no matching function for call}}
+
+      bind(&mixed); // expected-error {{no matching function for call}}
+      bind(&B::mixed); // expected-error {{no matching function for call}}
+
+      bind(&stat); // expected-error {{no matching function for call}}
+      bind(&B::stat); // expected-error {{no matching function for call}}
+    }
+  };
+
+  template void B<int>::test0b(); // expected-note {{in instantiation}}
 }

Modified: cfe/trunk/test/SemaTemplate/instantiate-clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-clang.cpp?rev=112282&r1=112281&r2=112282&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-clang.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-clang.cpp Fri Aug 27 14:56:05 2010
@@ -24,7 +24,7 @@
 struct ShuffleVector0 {
   void f(T t, U u, double2 a, double2 b) {
     (void)__builtin_shufflevector(t, u, N, M); // expected-error{{index}}
-    (void)__builtin_shufflevector(a, b, N, M);
+    (void)__builtin_shufflevector(a, b, N, M); // expected-error{{index}}
     (void)__builtin_shufflevector(a, b, 2, 1);
   }
 };

Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp?rev=112282&r1=112281&r2=112282&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp Fri Aug 27 14:56:05 2010
@@ -63,7 +63,11 @@
 template<typename T>
 struct StatementExpr0 {
   void f(T t) {
-    (void)({ if (t) t = t + 17; t + 12;}); // expected-error{{contextually convertible}}
+    (void)({
+        if (t) // expected-error{{contextually convertible}}
+          t = t + 17;
+        t + 12; // expected-error{{invalid operands}}
+      });
   }
 };
 
@@ -106,8 +110,8 @@
     VaList va;
     __builtin_va_start(va, n); // expected-error{{int}}
     for (int i = 0; i != n; ++i)
-      (void)__builtin_va_arg(va, ArgType);
-    __builtin_va_end(va);
+      (void)__builtin_va_arg(va, ArgType); // expected-error{{int}}
+    __builtin_va_end(va); // expected-error{{int}}
   }
 };
 

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=112282&r1=112281&r2=112282&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp Fri Aug 27 14:56:05 2010
@@ -115,7 +115,7 @@
 struct Delete0 {
   void f(T t) {
     delete t; // expected-error{{cannot delete}}
-    ::delete [] t;
+    ::delete [] t; // expected-error{{cannot delete}}
   }
 };
 

Modified: cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp?rev=112282&r1=112281&r2=112282&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp Fri Aug 27 14:56:05 2010
@@ -72,7 +72,7 @@
     if (T x = t) {
       t = x;
     }
-    return v;
+    return v; // expected-error{{cannot initialize return object of type}}
   }
 };
 
@@ -178,10 +178,10 @@
 
   prior:
     T prior_label;
-    prior_label = &&prior;
+    prior_label = &&prior; // expected-error{{assigning to 'int'}}
 
     T later_label;
-    later_label = &&later;
+    later_label = &&later; // expected-error{{assigning to 'int'}}
 
   later:
     (void)(1+1);





More information about the cfe-commits mailing list