summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-12-20 21:33:38 +0000
committerAnders Carlsson <andersca@mac.com>2008-12-20 21:33:38 +0000
commitfbef9c208f9bd52254db20178fc4555c52a9a583 (patch)
tree0769429db0eac1936f511b6dc664c8cc08b8821c /clang/lib/CodeGen/CGStmt.cpp
parentc20879a6e4ec7540ed6826200dca721748887a36 (diff)
downloadbcm5719-llvm-fbef9c208f9bd52254db20178fc4555c52a9a583.tar.gz
bcm5719-llvm-fbef9c208f9bd52254db20178fc4555c52a9a583.zip
Check the entire StackSaveValues stack for VLAs when dealing with goto and return statements. Noticed by Eli Friedman.
llvm-svn: 61289
Diffstat (limited to 'clang/lib/CodeGen/CGStmt.cpp')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 6d8f5da015c..60e8bd6b7fd 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -220,9 +220,11 @@ void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) {
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 @@ void CodeGenFunction::EmitReturnOfRValue(RValue RV, QualType Ty) {
/// 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.
OpenPOWER on IntegriCloud