[cfe-commits] [PATCH] Fix for VarDecl::getSourceRange() when static array has initializer.

Richard Smith richard at metafoo.co.uk
Wed Jan 9 18:56:11 PST 2013


On Wed, Jan 9, 2013 at 8:36 AM, Will Wilson <will at indefiant.com> wrote:
> Hi All,
>
> Here's a simple patch that fixes a bug in VarDecl::getSourceRange() which
> occurs when a static member array has an element type with an implicit
> initializer expression.
>
> Basically, this detect the edge case where the initializer has no size and
> falls back on the usual DeclaratorDecl::getSourceRange() allowing any
> postfix tokens to be included in the range calculation.
>
> All tests passed locally, but I'm afraid I didn't have a chance to construct
> a suitable test-case. However the following snippet reproduces the issue if
> needed. Either way I hope this should be safe to commit.

All changes should have an associated test case (where possible).
Please also add a comment, this is pretty subtle!

> ----
>
> struct ElemType { char padding[16]; };
>
> class TemplatedClass
> {
> public:
> static ElemType Arr[4];
> };
>
> ElemType TemplatedClass::Arr[4];  // Issue: '[4]' missing from
> VarDecl::getSourceRange()
>
> static TemplatedClass Instance;



More information about the cfe-commits mailing list