r213445 - TypePrinter should not ignore IndexTypeCVRQualifiers on constant-sized arrays

Hal Finkel hfinkel at anl.gov
Fri Jul 18 19:01:03 PDT 2014


Author: hfinkel
Date: Fri Jul 18 21:01:03 2014
New Revision: 213445

URL: http://llvm.org/viewvc/llvm-project?rev=213445&view=rev
Log:
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]) { ... }

Modified:
    cfe/trunk/lib/AST/TypePrinter.cpp
    cfe/trunk/test/Sema/ast-print.c

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=213445&r1=213444&r2=213445&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Fri Jul 18 21:01:03 2014
@@ -431,6 +431,10 @@ void TypePrinter::printConstantArrayBefo
 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 ";

Modified: cfe/trunk/test/Sema/ast-print.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ast-print.c?rev=213445&r1=213444&r2=213445&view=diff
==============================================================================
--- cfe/trunk/test/Sema/ast-print.c (original)
+++ cfe/trunk/test/Sema/ast-print.c Fri Jul 18 21:01:03 2014
@@ -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];
+}
+





More information about the cfe-commits mailing list