In C99, an array parameter declarator might have the form: direct-declarator
'[' 'static' type-qual-list[opt] assign-expr ']'
and when the size of the array is a constant, don't omit the static keyword
when printing the type. Also, in the VLA case, put a space after the static
keyword (some assignment expression must follow it).
llvm-svn: 213424
}
void TypePrinter::printConstantArrayAfter(const ConstantArrayType *T,
raw_ostream &OS) {
- OS << '[' << T->getSize().getZExtValue() << ']';
+ OS << '[';
+
+ if (T->getSizeModifier() == VariableArrayType::Static)
+ OS << "static ";
+
+ OS << T->getSize().getZExtValue() << ']';
printAfter(T->getElementType(), OS);
}
}
if (T->getSizeModifier() == VariableArrayType::Static)
- OS << "static";
+ OS << "static ";
else if (T->getSizeModifier() == VariableArrayType::Star)
OS << '*';
// CHECK: return b->b;
return b->b;
}
+
+int arr(int a[static 3]) {
+ // CHECK: int a[static 3]
+ return a[2];
+}
+
+int varr(int n, int a[static n]) {
+ // CHECK: int a[static n]
+ return a[2];
+}
+