[cfe-commits] [PATCH] --std=gnu++0xc9x : Allowing C++0x, C99 and GNU extensions

Benoit Belley Benoit.Belley at autodesk.com
Fri Sep 3 07:50:31 PDT 2010


Hi Doug,

Thanks for the explanation.

I am mostly interested about running the Clang static analyzer on our code base at this point in time. So, not having proper IR generation is not an issue for me (along as I can get a proper AST). Unfortunately, I don’t have time to work on C++ VLA in the short term. I’ll just keep the flag in our internal version for now then.

Benoit


Le 2010-09-03 à 10:24, Douglas Gregor a écrit :


On Sep 3, 2010, at 5:13 AM, Benoit Belley wrote:

Without the C99 language features, I trigger the following error message:

// C99 variable-length arrays
def err_vla_non_pod : Error<"variable length array of non-POD element type %0 »>;

Note that both g++ and the Intel compiler accept C99 VLA by default.  Here’s an example demonstrating this:

$ car foo.cpp
class A
{
public:
  A();
  ~A();
};

void foo(int i)
{
  A vla[i];
}

Sure, but that's not a C99 VLA: that's a VLA using a type that can only be expressed in C++ and requires a non-trivial amount of extra work in IR generation to get right. In particular, we need to generate IR to call the destructors for elements in the VLA, along the normal path, exception path, and exception-thrown-during-initialization path.

If someone contributes proper IR generation support for non-POD VLAs, including solid testing to ensure that we're dealing with all of the hard cases, too, to make this a real feature, then I'd be happy to reduce that error to an extwarn/extension in GNU mode. However, without proper IR generation support, the error needs to stay in place.

As an aside: -std=gnu++0x and -std=gnu++98 will end up with most/all of the C99 features that GNU supports anyway, so there should never be a need for, e.g., -std=gnucxx0xc9x. If we get to that point, we should be talking about multiple, semi-independent flags. I'd rather not have to go there.

- Doug




Benoit Belley
Sr Principal Developer
M&E-Product Development Group

Autodesk Canada Inc.
10 Rue Duke
Montreal, Quebec  H3C 2L7
Canada

Direct 514 954-7154



[cid:image002.gif at 01CAF376.C0A99470]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.gif
Type: image/gif
Size: 651 bytes
Desc: image002.gif
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100903/7baf387b/attachment.gif>


More information about the cfe-commits mailing list