]> granicus.if.org Git - clang/commitdiff
Fix for PR3869: actually enforce that the argument of an indirect goto
authorEli Friedman <eli.friedman@gmail.com>
Thu, 26 Mar 2009 00:18:06 +0000 (00:18 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 26 Mar 2009 00:18:06 +0000 (00:18 +0000)
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

lib/Sema/SemaStmt.cpp
test/CodeGen/PR3869-indirect-goto-long.c [new file with mode: 0644]

index 39f21f853a3d423a2dca0cc03a91549c5cddacbf..4ef0fda36123be9dc784d9a28c86d71db2e48b54 100644 (file)
@@ -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 (file)
index 0000000..140e4ec
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: clang-cc -emit-llvm-bc -o - %s
+// PR3869
+int a(long long b) { goto *b; }
+