]> granicus.if.org Git - clang/commitdiff
TypePrinter should not ignore IndexTypeCVRQualifiers on constant-sized arrays
authorHal Finkel <hfinkel@anl.gov>
Sat, 19 Jul 2014 02:01:03 +0000 (02:01 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sat, 19 Jul 2014 02:01:03 +0000 (02:01 +0000)
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]) { ... }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213445 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/TypePrinter.cpp
test/Sema/ast-print.c

index d357b3215abf037df2b801aa18383c1e3e8f3eb1..d06bfbdb7a7912a4a2f0c74a9e608319194c7be5 100644 (file)
@@ -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 ";
index e40c4dd23180810d8685dd01b607d03f7dabd31f..382f0d38962715e83a791060f897663005ed3b46 100644 (file)
@@ -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];
+}
+