summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaStmt.cpp6
-rw-r--r--clang/test/CodeGen/PR3869-indirect-goto-long.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 39f21f853a3..4ef0fda3612 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/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/clang/test/CodeGen/PR3869-indirect-goto-long.c b/clang/test/CodeGen/PR3869-indirect-goto-long.c
new file mode 100644
index 00000000000..140e4ec14a8
--- /dev/null
+++ b/clang/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; }
+
OpenPOWER on IntegriCloud