From: Eli Friedman Date: Thu, 26 Mar 2009 00:18:06 +0000 (+0000) Subject: Fix for PR3869: actually enforce that the argument of an indirect goto X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bbf462314b1dc8e422b7c4dd4cac47e566aedf6d;p=clang Fix for PR3869: actually enforce that the argument of an indirect goto is of type void*. I'll try to add the appropriate checking later. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67721 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 39f21f853a..4ef0fda361 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -688,8 +688,10 @@ Action::OwningStmtResult Sema::ActOnIndirectGotoStmt(SourceLocation GotoLoc,SourceLocation StarLoc, ExprArg DestExp) { // FIXME: Verify that the operand is convertible to void*. - - return Owned(new (Context) IndirectGotoStmt((Expr*)DestExp.release())); + // Convert operand to void* + Expr* E = (Expr*)DestExp.release(); + ImpCastExprToType(E, Context.VoidPtrTy); + return Owned(new (Context) IndirectGotoStmt(E)); } Action::OwningStmtResult diff --git a/test/CodeGen/PR3869-indirect-goto-long.c b/test/CodeGen/PR3869-indirect-goto-long.c new file mode 100644 index 0000000000..140e4ec14a --- /dev/null +++ b/test/CodeGen/PR3869-indirect-goto-long.c @@ -0,0 +1,4 @@ +// RUN: clang-cc -emit-llvm-bc -o - %s +// PR3869 +int a(long long b) { goto *b; } +