diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-06-04 17:58:41 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-06-04 17:58:41 +0000 |
commit | 50c5c7241029651d4ff976f840bbca59fa81445f (patch) | |
tree | 1935934774f35ea7874870aed84d46fe9031ac29 | |
parent | 5aa4fd65efe3bda6080009fffba747450f34536e (diff) |
Don't assume that the type of a FunctionDecl is a FunctionType; that
assumption isn't accurate in the presence of typedefs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51951 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Decl.h | 2 | ||||
-rw-r--r-- | test/CodeGen/typedef-func.c | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index e3d83af420..1bfad2e391 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -492,7 +492,7 @@ public: unsigned getMinRequiredArguments() const; QualType getResultType() const { - return cast<FunctionType>(getType())->getResultType(); + return getType()->getAsFunctionType()->getResultType(); } StorageClass getStorageClass() const { return StorageClass(SClass); } bool isInline() const { return IsInline; } diff --git a/test/CodeGen/typedef-func.c b/test/CodeGen/typedef-func.c new file mode 100644 index 0000000000..08328e6770 --- /dev/null +++ b/test/CodeGen/typedef-func.c @@ -0,0 +1,13 @@ +// RUN: clang -emit-llvm < %s + +// PR2414 +typedef void filter_func_t(); +filter_func_t mono_filter; + +void addfilter2(filter_func_t *func){} + +void setup_filters() +{ + addfilter2( mono_filter); +} + |