From: Hal Finkel Date: Sat, 19 Jul 2014 02:01:03 +0000 (+0000) Subject: TypePrinter should not ignore IndexTypeCVRQualifiers on constant-sized arrays X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bfe2d3c0f966e8d6ab873b54deacee9048780d19;p=platform%2Fupstream%2Fllvm.git TypePrinter should not ignore IndexTypeCVRQualifiers on constant-sized arrays C99 array parameters can have index-type CVR qualifiers, and the TypePrinter should print them when present (and we were not for constant-sized arrays). Otherwise, we'd drop the restrict in: int foo(int a[restrict static 3]) { ... } llvm-svn: 213445 --- diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index d357b32..d06bfbd 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -431,6 +431,10 @@ void TypePrinter::printConstantArrayBefore(const ConstantArrayType *T, void TypePrinter::printConstantArrayAfter(const ConstantArrayType *T, raw_ostream &OS) { OS << '['; + if (T->getIndexTypeQualifiers().hasQualifiers()) { + AppendTypeQualList(OS, T->getIndexTypeCVRQualifiers()); + OS << ' '; + } if (T->getSizeModifier() == VariableArrayType::Static) OS << "static "; diff --git a/clang/test/Sema/ast-print.c b/clang/test/Sema/ast-print.c index e40c4dd2..382f0d3 100644 --- a/clang/test/Sema/ast-print.c +++ b/clang/test/Sema/ast-print.c @@ -24,8 +24,18 @@ int arr(int a[static 3]) { return a[2]; } +int rarr(int a[restrict static 3]) { + // CHECK: int a[restrict static 3] + return a[2]; +} + int varr(int n, int a[static n]) { // CHECK: int a[static n] return a[2]; } +int rvarr(int n, int a[restrict static n]) { + // CHECK: int a[restrict static n] + return a[2]; +} +