[dragonegg] r178447 - For gcc 4.7, use gimple_call_fntype to extract a GIMPLE_CALL function type.
Peter Collingbourne
peter at pcc.me.uk
Sun Mar 31 03:30:47 PDT 2013
Author: pcc
Date: Sun Mar 31 05:30:47 2013
New Revision: 178447
URL: http://llvm.org/viewvc/llvm-project?rev=178447&view=rev
Log:
For gcc 4.7, use gimple_call_fntype to extract a GIMPLE_CALL function type.
This fixes cases where function pointers are cast in the call expression.
Added:
dragonegg/trunk/test/validator/c/FunctionCastCall.c
Modified:
dragonegg/trunk/src/Convert.cpp
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=178447&r1=178446&r2=178447&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Sun Mar 31 05:30:47 2013
@@ -3260,8 +3260,12 @@ Value *TreeToLLVM::EmitCallOf(Value *Cal
}
tree fndecl = gimple_call_fndecl(stmt);
+#if (GCC_MINOR < 7)
tree fntype =
fndecl ? TREE_TYPE(fndecl) : TREE_TYPE(TREE_TYPE(gimple_call_fn(stmt)));
+#else
+ tree fntype = gimple_call_fntype(stmt);
+#endif
// Determine the calling convention.
CallingConv::ID CallingConvention = CallingConv::C;
@@ -9125,7 +9129,11 @@ bool TreeToLLVM::EmitBuiltinCall(gimple
isa<REFERENCE_TYPE>(TREE_TYPE(call_expr))) &&
"Not calling a function pointer?");
+#if (GCC_MINOR < 7)
tree function_type = TREE_TYPE(TREE_TYPE(call_expr));
+#else
+ tree function_type = gimple_call_fntype(stmt);
+#endif
Value *Callee = EmitRegister(call_expr);
CallingConv::ID CallingConv;
AttributeSet PAL;
Added: dragonegg/trunk/test/validator/c/FunctionCastCall.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c/FunctionCastCall.c?rev=178447&view=auto
==============================================================================
--- dragonegg/trunk/test/validator/c/FunctionCastCall.c (added)
+++ dragonegg/trunk/test/validator/c/FunctionCastCall.c Sun Mar 31 05:30:47 2013
@@ -0,0 +1,7 @@
+// RUN: %dragonegg -S %s
+
+typedef void (*ft)(void);
+
+void foo(ft f) {
+ ((void(*)(int))f)(0);
+}
More information about the llvm-commits
mailing list