mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-01 19:46:05 +00:00
Sanity-check argument to indirect goto.
llvm-svn: 67746
This commit is contained in:
parent
55a2cd736d
commit
6568eef9f9
@ -687,10 +687,14 @@ Sema::ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
|
||||
Action::OwningStmtResult
|
||||
Sema::ActOnIndirectGotoStmt(SourceLocation GotoLoc,SourceLocation StarLoc,
|
||||
ExprArg DestExp) {
|
||||
// FIXME: Verify that the operand is convertible to void*.
|
||||
// Convert operand to void*
|
||||
Expr* E = (Expr*)DestExp.release();
|
||||
ImpCastExprToType(E, Context.VoidPtrTy);
|
||||
Expr* E = DestExp.takeAs<Expr>();
|
||||
QualType ETy = E->getType();
|
||||
AssignConvertType ConvTy =
|
||||
CheckSingleAssignmentConstraints(Context.VoidPtrTy, E);
|
||||
if (DiagnoseAssignmentResult(ConvTy, StarLoc, Context.VoidPtrTy, ETy,
|
||||
E, "passing"))
|
||||
return StmtError();
|
||||
return Owned(new (Context) IndirectGotoStmt(E));
|
||||
}
|
||||
|
||||
|
8
clang/test/Sema/indirect-goto.c
Normal file
8
clang/test/Sema/indirect-goto.c
Normal file
@ -0,0 +1,8 @@
|
||||
// RUN: clang-cc -fsyntax-only -verify %s
|
||||
|
||||
struct c {int x;};
|
||||
int a(struct c x, long long y) {
|
||||
goto *x; // expected-error{{incompatible type}}
|
||||
goto *y; // expected-warning{{incompatible integer to pointer conversion}}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user