This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Identify destructor/constructor


James E Wilson wrote:

Revital Eres wrote:

How can I identify that a function is a destructor/constructor
like __base_dtor or __comp_dtor?


Just grepping in the gcc/cp directory, I find DECL_CONSTRUCTOR_P and DECL_DESTRUCTOR_P defined in cp-tree.h. However, these will only work in the C++ front end.

Checking the constructor/destructor attribute code in c-common.c, I see flags DECL_STATIC_CONSTRUCTOR and DECL_STATIC_DESTRUCTOR. These should be usable in the middle end, though I don't know if C++ code will set them. I didn't check. I suspect not. You might have to fix this if you need this info.

It doesn't set them because they don't mean the same thing. The C++ DECL_CONSTRUCTOR_P is a class consturctor; DECL_STATIC_CONSTRUCTOR is something like C++'s magic file-scope initialization routines or C's "__attribute__((constructor))" functions.


--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]