[cfe-dev] [cfe-commits] [PATCH] PR13788 - sema crash on add initializer

Richard Smith richard at metafoo.co.uk
Thu Nov 1 15:52:56 PDT 2012


On Thu, Nov 1, 2012 at 5:36 AM, Brian Brooks <brooks.brian at gmail.com> wrote:
> Adding cfe-dev...

Dropping cfe-dev via bcc, you were right first time.

> On Wed, Oct 31, 2012 at 5:26 PM, Brian Brooks <brooks.brian at gmail.com>
> wrote:
>> The attached patch needs review please!
>>
>> I suspect that we may need to call RequireCompleteType() to do
>> instantiation *even if* the VDecl is a dependent type.  I am not yet able to
>> reason about this though.

I'm not sure I follow how this comment relates to the patch.

>> The patch prevents the abort, and the test case (extended with code to
>> print initialized data) output looks the same in clang and gcc.

-  QualType baseType = Context.getBaseElementType(var->getType());
-  if (baseType->isDependentType()) return;
+  QualType type = var->getType();
+  QualType baseType = Context.getBaseElementType(type);
+  if (type->isDependentType() || baseType->isDependentType())
+    return;

You only need to check 'type' here. It will be dependent whenever 'baseType' is.

--- test/SemaCXX/PR13788.cpp	(revision 0)
+++ test/SemaCXX/PR13788.cpp	(revision 0)

We prefer to add tests to existing test files when that is reasonable.
test/SemaTemplate/dependent-sized_array.cpp seems like a good place
for this test (please add a comment pointing at PR13788 to the test
case, or put it in namespace PR13788, or similar).

Thanks!



More information about the cfe-dev mailing list