[cfe-dev] Verification of the type of language (C or C++) within the body of a function/method
Miguel Aguilar
miguel.aguilar at ice.rwth-aachen.de
Fri Jan 25 08:31:30 PST 2013
Well actually the CXXRecordDecl considers something like this by means
of the "isCLike()", but for the whole class and not for the statements
within a given method. It says about isCLike():
"True if this class is C-like, without C++-specific features, e.g. it
contains only public fields, no bases, tag kind is not 'class', etc."
But in my case I am interested on not having C++ statements in the
methods such as "try-catch", etc. In features like function overloading
is not something I need to verify.
Miguel
On 01/25/2013 05:14 PM, Dmitri Gribenko wrote:
> On Fri, Jan 25, 2013 at 5:13 PM, Miguel Aguilar
> <miguel.aguilar at ice.rwth-aachen.de> wrote:
>> Is there any way to verify that the code within the body or a function or
>> method is pure C or if it has C++ statements?
> I don't think this is a valid question to ask. You can have C-like
> constructs that actually use C++ features that are not visible in
> syntax. For example, function overloading:
>
> void f(void *);
> void f(int);
>
> void g() {
> f(42);
> }
>
> "g" uses only statements that exist in C, but it depends on overload
> resolution and you can not determine that based on syntax only.
>
> Dmitri
>
More information about the cfe-dev
mailing list