]> granicus.if.org Git - clang/commitdiff
Don't look through casts when looking for the underlying decl for a function
authorEli Friedman <eli.friedman@gmail.com>
Sat, 26 Dec 2009 03:35:45 +0000 (03:35 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 26 Dec 2009 03:35:45 +0000 (03:35 +0000)
call; the standard doesn't expect us to, and the program could be doing
something crazy.  Fixes PR5882.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92166 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/CodeGen/func-ptr-cast-decl.c [new file with mode: 0644]

index 3df5b00cda9a9853e8f48e05f2a5bb922ed5cb75..6438faea0a01a50b0a7e6fa5c62d2e3943dda3b9 100644 (file)
@@ -3373,7 +3373,7 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
   // Also, in C++, keep track of whether we should perform argument-dependent
   // lookup and whether there were any explicitly-specified template arguments.
 
-  Expr *NakedFn = Fn->IgnoreParenCasts();
+  Expr *NakedFn = Fn->IgnoreParens();
   if (isa<UnresolvedLookupExpr>(NakedFn)) {
     UnresolvedLookupExpr *ULE = cast<UnresolvedLookupExpr>(NakedFn);
     return BuildOverloadedCallExpr(Fn, ULE, LParenLoc, Args, NumArgs,
diff --git a/test/CodeGen/func-ptr-cast-decl.c b/test/CodeGen/func-ptr-cast-decl.c
new file mode 100644 (file)
index 0000000..e630796
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm-only %s -verify
+// PR5882
+
+int q_sk_num(void *a);
+typedef int (*fptr)(double);
+void a() { ((fptr)q_sk_num)(0); }