Check the entire StackSaveValues stack for VLAs when dealing with goto and return statements. Noticed by Eli Friedman.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61289 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anders Carlsson 2008-12-20 21:33:38 +00:00
Родитель 751358ff73
Коммит 7e63b8527f
1 изменённых файлов: 10 добавлений и 6 удалений

Просмотреть файл

@ -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.