There was some kind of regression in function pointers handling.
Attached is a file that triggers an assert failure (when run with
e.g. -ast-dump):
Sorry for the big file, but I didn't have the time to strip it.
Here is a two line test case that exposes the bug (which appears
specific to -ast-print/-ast-dump)...
snaroff% cat nuno.c
typedef void func_typedef();
func_typedef xxx;
I'll investigate later. Thanks for the bug,
Fixed,
-Chris
Thank you Chris! However it seems my example file now triggers another
assert().
I'm putting it on-line, as it seems to be a good case-study:
http://web.ist.utl.pt/nuno.lopes/php_example.c :P
It fails with 'assert(isa<X>(Val) && "cast<Ty>() argument of
incompatible type!"', triggered by FunctionDecl::getNumParams().
OK, so today I had a few minutes to track down the bug. The problem is
triggered with the following:
typedef void func_t(int x);
func_t a;
The patch to fix it is attached.
Nuno
Index: AST/Decl.cpp
===================================================================
--- AST/Decl.cpp (revision 44636)
+++ AST/Decl.cpp (working copy)
@@ -242,8 +242,8 @@
}
unsigned FunctionDecl::getNumParams() const {
- if (isa<FunctionTypeNoProto>(getType())) return 0;
- return cast<FunctionTypeProto>(getType())->getNumArgs();
+ if (isa<FunctionTypeNoProto>(getCanonicalType())) return 0;
+ return cast<FunctionTypeProto>(getCanonicalType())->getNumArgs();
}
void FunctionDecl::setParams(ParmVarDecl **NewParamInfo, unsigned NumParams) {
_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev