From e14b1997db6e09028b3dfdb982fee7eb3ffe5e9f Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sat, 26 Dec 2009 03:35:45 +0000 Subject: [PATCH] Don't look through casts when looking for the underlying decl for a function call; the standard doesn't expect us to, and the program could be doing something crazy. Fixes PR5882. llvm-svn: 92166 --- clang/lib/Sema/SemaExpr.cpp | 2 +- clang/test/CodeGen/func-ptr-cast-decl.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGen/func-ptr-cast-decl.c diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3df5b00cda9a..6438faea0a01 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -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(NakedFn)) { UnresolvedLookupExpr *ULE = cast(NakedFn); return BuildOverloadedCallExpr(Fn, ULE, LParenLoc, Args, NumArgs, diff --git a/clang/test/CodeGen/func-ptr-cast-decl.c b/clang/test/CodeGen/func-ptr-cast-decl.c new file mode 100644 index 000000000000..e6307964294a --- /dev/null +++ b/clang/test/CodeGen/func-ptr-cast-decl.c @@ -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); }