Skip to content
Snippets Groups Projects
Commit 170c2dde authored by Hal Finkel's avatar Hal Finkel
Browse files

TypePrinter should not omit the static keyword in array parameter declarators

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).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213424 91177308-0d34-0410-b5e6-96231b3b80d8
parent 8fe24af4
No related branches found
No related tags found
No related merge requests found
......@@ -430,7 +430,12 @@ void TypePrinter::printConstantArrayBefore(const ConstantArrayType *T,
}
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);
}
......@@ -461,7 +466,7 @@ void TypePrinter::printVariableArrayAfter(const VariableArrayType *T,
}
if (T->getSizeModifier() == VariableArrayType::Static)
OS << "static";
OS << "static ";
else if (T->getSizeModifier() == VariableArrayType::Star)
OS << '*';
......
......@@ -18,3 +18,14 @@ int foo(const struct blah *b) {
// 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];
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment