[cfe-dev] extending C with Clang

John McCall rjmccall at apple.com
Thu Sep 2 15:12:21 PDT 2010


On Sep 2, 2010, at 3:01 PM, Wei Li wrote:

> Dear All:
> 
> I am  extending C language for my research work and using Clang for
> this. I am adding some annotations which are not part of C language
> but will be helpful for my specific work.
> 
> Now consider the following:
> 
> int  foo() { return 1; }
> 
> is a legal  expression in C and is acceptable by the Clang. Now if I
> introduce a new annotation say "Wei"  and write the above expression
> as
> 
> int foo() Wei { return 1;}
> 
> I have to make changes in Clang at the front end to make it work. I
> see my extension as super set of C. That is my work should accept the
> legal C program as well.
> 
> Now here is the problem. When I make changes in the Clang . It accepts
> the new annotation but breaks the C programs. My understanding is that
> as I am adding to C so if my stuff works, any legal C  program should
> also work. But its not happening. I am not a compiler person. I am an
> engineer. Any suggestions? why clang is doing this or am I doing
> something    which is not compatible with the C grammar.?

Your parser modifications are probably broken.  I would strongly
suggest implementing Wei as a macro for __attribute__((Wei)) and then
just adding support for your new attribute.

John.



More information about the cfe-dev mailing list