Parenthesis are now added to casts of type array.
authorNick Hildenbrandt <hldnbrnd@uiuc.edu>
Mon, 23 Sep 2002 21:02:50 +0000 (21:02 +0000)
committerNick Hildenbrandt <hldnbrnd@uiuc.edu>
Mon, 23 Sep 2002 21:02:50 +0000 (21:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3892 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index f0f5507897c1ce45451e99805da812e7680c77ac..3b8c67d45b1a0d3733a0e302579282e6caedad30 100644 (file)
@@ -244,7 +244,8 @@ ostream &CWriter::printType(const Type *Ty, const string &NameSoFar,
     // Do not need parens around "* NameSoFar" if NameSoFar consists only
     // of zero or more '*' chars *and* this is not an unnamed pointer type
     // such as the result type in a cast statement.  Otherwise, enclose in ( ).
-    if (ptrTypeNameNeedsParens(NameSoFar) || !namedContext)
+    if (ptrTypeNameNeedsParens(NameSoFar) || !namedContext || 
+        PTy->getElementType()->getPrimitiveID() == Type::ArrayTyID)
       ptrName = "(" + ptrName + ")";    // 
 
     return printType(PTy->getElementType(), ptrName);
index f0f5507897c1ce45451e99805da812e7680c77ac..3b8c67d45b1a0d3733a0e302579282e6caedad30 100644 (file)
@@ -244,7 +244,8 @@ ostream &CWriter::printType(const Type *Ty, const string &NameSoFar,
     // Do not need parens around "* NameSoFar" if NameSoFar consists only
     // of zero or more '*' chars *and* this is not an unnamed pointer type
     // such as the result type in a cast statement.  Otherwise, enclose in ( ).
-    if (ptrTypeNameNeedsParens(NameSoFar) || !namedContext)
+    if (ptrTypeNameNeedsParens(NameSoFar) || !namedContext || 
+        PTy->getElementType()->getPrimitiveID() == Type::ArrayTyID)
       ptrName = "(" + ptrName + ")";    // 
 
     return printType(PTy->getElementType(), ptrName);