[cfe-commits] r61289 - /cfe/trunk/lib/CodeGen/CGStmt.cpp

Anders Carlsson andersca at mac.com
Sat Dec 20 13:33:39 PST 2008


Author: andersca
Date: Sat Dec 20 15:33:38 2008
New Revision: 61289

URL: http://llvm.org/viewvc/llvm-project?rev=61289&view=rev
Log:
Check the entire StackSaveValues stack for VLAs when dealing with goto and return statements. Noticed by Eli Friedman.

Modified:
    cfe/trunk/lib/CodeGen/CGStmt.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=61289&r1=61288&r2=61289&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Sat Dec 20 15:33:38 2008
@@ -220,9 +220,11 @@
     return;
   }
 
-  if (StackSaveValues.back()) {
-    CGM.ErrorUnsupported(&S, "goto inside scope with VLA");
-    return;
+  for (int i = 0; i < StackSaveValues.size(); i++) {
+    if (StackSaveValues[i]) {
+      CGM.ErrorUnsupported(&S, "goto inside scope with VLA");
+      return;
+    }
   }
   
   // If this code is reachable then emit a stop point (if generating
@@ -476,9 +478,11 @@
 /// if the function returns void, or may be missing one if the function returns
 /// non-void.  Fun stuff :).
 void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
-  if (StackSaveValues.back()) {
-    CGM.ErrorUnsupported(&S, "return inside scope with VLA");
-    return;
+  for (int i = 0; i < StackSaveValues.size(); i++) {
+    if (StackSaveValues[i]) {
+      CGM.ErrorUnsupported(&S, "return inside scope with VLA");
+      return;
+    }
   }
   
   // Emit the result value, even if unused, to evalute the side effects.





More information about the cfe-commits mailing list