[cfe-dev] Verification of the type of language (C or C++) within the body of a function/method

Dmitri Gribenko gribozavr at gmail.com
Fri Jan 25 08:14:06 PST 2013


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

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-dev mailing list