Clang crash with attribute-types that have extra parens:

Hi all, I'm stuck on the following defect and was hoping someone could give a bit of advice to get me unstuck-
I found that doing the following causes an assertion failure:
int (__attribute__((vector_size(16))) vs_test);
The following does not for comparison sake:
int (__attribute__((aligned(16))) align_test);

The initial problem seems to be that SemaType.cpp's Sema::GetTypeSourceInfoForDeclarator receives a VectorType, which is not terribly implemented. The first assertion failure is caused by DeclaratorLocFiller::Visit on this value. I fixed this by adding a DeclaratorLocFiller::VisitVectorTypeLoc.

The next issue is an actual crash (not an assertion) due to dereferencing a null in the call to TypeLocVisitor::Visit in the 'else' clause of the ReturnTypeInfo test. Due to the CurrTL.getNextTypeLoc returning an empty type, this is a null dereference. It seemed to me that once again, VectorType hadn't been properly implemented. Digging down, it would seem that the stock ConcreteTypeLoc implementation would work by implementing getInnerType, but the TypeSpecTypeLoc implementation gets called, which is what results in a 'null'. Thus, the crash in the output below:

I've attempted to actually just implement VectorTypeLoc::getNextTypeLoc as : return TypeLoc(getTypePtr()->getElementType(), getNonLocalData());, however this causes a different test to fail, SemaTemplate/ext-vector-type.cpp.

In that case, it seems that TypeLocBuilder::pushImpl attempts to confirm that the 'getNextTypeLoc' was the previously built thing (essentially an empty TypeLoc in the 1st call case).

The following code repros that issue (see 2nd crash log below):
1 template <typename T, unsigned Len>
  1 struct make1 {
  2 typedef T __attribute((ext_vector_type(Len))) type;
  3 };
  5 void test() {
  6 make1<int, 5>::type x;
  7 }

So, after that LONG introduction, my question is: Am I way off the rails in my attempt here? Am I missing the idea behind getNextTypeLoc? Should VectorType even be possible to get to GetTypeSourceInfoForDeclarator, and I should be running up the stack from there? Is the issue with something in the TypeLocBuilder stuff?


Command Output (stderr):

+cfe-dev, I must have dropped it

Thank you very much, I’ll use this for guidance when I start working again after the new year.