forked from OSchip/llvm-project
parent
99469702a3
commit
314825bc8a
|
@ -2458,8 +2458,6 @@ def warn_stringcompare : Warning<
|
||||||
def err_blocks_disable : Error<"blocks support disabled - compile with -fblocks"
|
def err_blocks_disable : Error<"blocks support disabled - compile with -fblocks"
|
||||||
" or pick a deployment target that supports them">;
|
" or pick a deployment target that supports them">;
|
||||||
def err_expected_block_lbrace : Error<"expected '{' in block literal">;
|
def err_expected_block_lbrace : Error<"expected '{' in block literal">;
|
||||||
def err_goto_in_block : Error<
|
|
||||||
"goto not allowed in block literal">;
|
|
||||||
def err_return_in_block_expression : Error<
|
def err_return_in_block_expression : Error<
|
||||||
"return not allowed in block expression literal">;
|
"return not allowed in block expression literal">;
|
||||||
def err_block_returns_array : Error<
|
def err_block_returns_array : Error<
|
||||||
|
|
|
@ -6884,6 +6884,26 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
|
||||||
CurFunctionNeedsScopeChecking = BSI->SavedFunctionNeedsScopeChecking;
|
CurFunctionNeedsScopeChecking = BSI->SavedFunctionNeedsScopeChecking;
|
||||||
|
|
||||||
BSI->TheDecl->setBody(body.takeAs<CompoundStmt>());
|
BSI->TheDecl->setBody(body.takeAs<CompoundStmt>());
|
||||||
|
|
||||||
|
bool Good = true;
|
||||||
|
// Check goto/label use.
|
||||||
|
for (llvm::DenseMap<IdentifierInfo*, LabelStmt*>::iterator
|
||||||
|
I = BSI->LabelMap.begin(), E = BSI->LabelMap.end(); I != E; ++I) {
|
||||||
|
LabelStmt *L = I->second;
|
||||||
|
|
||||||
|
// Verify that we have no forward references left. If so, there was a goto
|
||||||
|
// or address of a label taken, but no definition of it.
|
||||||
|
if (L->getSubStmt() != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Emit error.
|
||||||
|
Diag(L->getIdentLoc(), diag::err_undeclared_label_use) << L->getName();
|
||||||
|
Good = false;
|
||||||
|
}
|
||||||
|
BSI->LabelMap.clear();
|
||||||
|
if (!Good)
|
||||||
|
return ExprError();
|
||||||
|
|
||||||
AnalysisContext AC(BSI->TheDecl);
|
AnalysisContext AC(BSI->TheDecl);
|
||||||
CheckFallThroughForBlock(BlockTy, BSI->TheDecl->getBody(), AC);
|
CheckFallThroughForBlock(BlockTy, BSI->TheDecl->getBody(), AC);
|
||||||
CheckUnreachable(AC);
|
CheckUnreachable(AC);
|
||||||
|
|
|
@ -879,10 +879,6 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
|
||||||
Action::OwningStmtResult
|
Action::OwningStmtResult
|
||||||
Sema::ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
|
Sema::ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
|
||||||
IdentifierInfo *LabelII) {
|
IdentifierInfo *LabelII) {
|
||||||
// If we are in a block, reject all gotos for now.
|
|
||||||
if (CurBlock)
|
|
||||||
return StmtError(Diag(GotoLoc, diag::err_goto_in_block));
|
|
||||||
|
|
||||||
// Look up the record for this label identifier.
|
// Look up the record for this label identifier.
|
||||||
LabelStmt *&LabelDecl = getLabelMap()[LabelII];
|
LabelStmt *&LabelDecl = getLabelMap()[LabelII];
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ void test2() {
|
||||||
break; // expected-error {{'break' statement not in loop or switch statement}}
|
break; // expected-error {{'break' statement not in loop or switch statement}}
|
||||||
continue; // expected-error {{'continue' statement not in loop statement}}
|
continue; // expected-error {{'continue' statement not in loop statement}}
|
||||||
while(1) break; // ok
|
while(1) break; // ok
|
||||||
goto foo; // expected-error {{goto not allowed}}
|
goto foo; // expected-error {{use of undeclared label 'foo'}}
|
||||||
|
a: goto a; // ok
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,7 @@ int test7(void (^p)()) {
|
||||||
|
|
||||||
void test8() {
|
void test8() {
|
||||||
somelabel:
|
somelabel:
|
||||||
// FIXME: This should say "jump out of block not legal" when gotos are allowed.
|
^{ goto somelabel; }(); // expected-error {{use of undeclared label 'somelabel'}}
|
||||||
^{ goto somelabel; }(); // expected-error {{goto not allowed in block literal}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test9() {
|
void test9() {
|
||||||
|
|
|
@ -181,15 +181,14 @@ void test11(int n) {
|
||||||
// TODO: When and if gotos are allowed in blocks, this should work.
|
// TODO: When and if gotos are allowed in blocks, this should work.
|
||||||
void test12(int n) {
|
void test12(int n) {
|
||||||
void *P = ^{
|
void *P = ^{
|
||||||
goto L1; // expected-error {{goto not allowed in block literal}}
|
goto L1;
|
||||||
L1:
|
L1:
|
||||||
goto L2; // expected-error {{goto not allowed in block literal}}
|
goto L2;
|
||||||
L2:
|
L2:
|
||||||
goto L3; // expected-error {{goto not allowed in block literal}}
|
goto L3; // expected-error {{illegal goto into protected scope}}
|
||||||
// todo-error {{illegal goto into protected scope}}
|
int Arr[n]; // expected-note {{jump bypasses initialization of variable length array}}
|
||||||
int Arr[n]; // todo-note {{jump bypasses initialization of variable length array}}
|
|
||||||
L3:
|
L3:
|
||||||
goto L4; // expected-error {{goto not allowed in block literal}}
|
goto L4;
|
||||||
L4: return;
|
L4: return;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue