[cfe-commits] r58100 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/fntype-decl.cpp

Doug Gregor doug.gregor at gmail.com
Fri Oct 24 17:02:42 PDT 2008


Hi Argiris,

On Fri, Oct 24, 2008 at 2:33 PM, Argiris Kirtzidis <akyrtzi at gmail.com> wrote:
> Two points:
> --Would it be better if the C++ semantic checks were modified to work on the
> param types of the function type ?
> ParmVarDecls are not strictly needed except in the case of default args.

Right. However, if we do the checks on the function type itself then
we don't have good location information for the diagnostics. Still,
there is probably some refactoring we can do, because at this point I
think we're missing some diagnostics when someone declares a typedef
of a function type (or function pointer type) rather than declaring a
function.

> --The test case (along with some others) now crashes on both C++ and C on
> Windows.

Oh, no! Thanks for reporting this!

> This is what happens:
> -ParmVarDecls are added to the FunctionDecl that has typedef as type.
> -When it's time to destroy the FunctionDecl, the destructor enters the
> ParmVarDecl-destroying-loop
> -FunctionDecl::param_end() sees that there are actually ParmVarDecls stored
> so it tries to return the correct iterator (before your commit it would just
> return 0x0 for a typedef'ed FunctionDecl).
> -FunctionDecl::getNumParams() tries to return the number of parameters.
> -Getting the param number involves first getting at the underlying
> FunctionType of the TypedefType.
> -In order to get at its unsugared type, the TypedefType needs to get the
> TypedefDecl::UnderlyingType
> -The TypedefDecl was previously destroyed and... crash!

Thanks for the diagnosis; I'll get this fixed. It sure would have been
nice if it crashed on Mac OS :)

It does seem odd that we're destroying the TypedefDecl before
destroying the FunctionDecl but I'll look into it.

  - Doug



More information about the cfe-commits mailing list