[cfe-dev] clang comparison webpage

Chris Lattner clattner at apple.com
Mon Dec 9 08:24:02 PST 2013

On Dec 9, 2013, at 7:50 AM, Alp Toker <alp at nuanti.com> wrote:
On 08/12/2013 23:20, Mouse wrote:
>> http://clang.llvm.org/comparison.html compares clang versus three other
>> compilers, one of them gcc, and invites mail to cfe-dev "if you think
>> some characterization is unfair here".
>> But the comparison to gcc leaves off the major reason clang is a
>> complete nonstarter for me: lack of support for gcc extensions.  (In my
>> case nested function support is the biggest one; clang appears to be
>> under the impression that they are "infrequently used"
> On this matter specifically, clang is a lot better set up nowadays to parse the old GNU nested functions thanks to work that was done do support closures like blocks and other function declarators that appear in funny places.
> I just tried and you can get them to parse with a one-line change in clang/lib/Parse/ParseDecl.cpp, and you can get some degree of semantic support for nested variable scope with another small change to ScopeInfo.h and SemaDecl.cpp. Probably with one more tweak to lib/CodeGen you could get this up and running.
> I think the policy not to support this extension made sense in the early days, but since then we've added support for all kinds of good (and dubious) extensions from GCC, MSVC and others so this is small fry.
> So if there is a good case for it and someone volunteers their weekend to implement it complete with tests, I can't imagine there would be vociferous objection from current maintainers of the code to be honest.

Right.  Early on, it just wasn’t important.  Beyond that, I still think that gnu nested functions are bad because 1) the cases that require trampolines on the stack are back for security (needing an executable stack) and 2) because error recovery/QoI is worse with them (in principle) when a } is forgotten.

That said, if someone were motivated to implement this extension (or a subset of it) then that would be really great.  IMO, I just think that -fnested-functions should be off by default.


More information about the cfe-dev mailing list