Extend QualType::getAddressSpace to do the right thing for array types, and in
the future, RecordTypes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48784 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 02b5f31..eea285c 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -808,14 +808,9 @@
     // This includes arrays of objects with address space qualifiers, but not
     // automatic variables that point to other address spaces.
     // ISO/IEC TR 18037 S5.1.2
-    if (NewVD->hasLocalStorage()) {
-      QualType AutoTy = NewVD->getCanonicalType();
-      if (const ArrayType *AT = AutoTy->getAsArrayType())
-        AutoTy = AT->getElementType().getCanonicalType();
-      if (AutoTy.getAddressSpace() != 0) {
-        Diag(D.getIdentifierLoc(), diag::err_as_qualified_auto_decl);
-        InvalidDecl = true;
-      }
+    if (NewVD->hasLocalStorage() && (NewVD->getType().getAddressSpace() != 0)) {
+      Diag(D.getIdentifierLoc(), diag::err_as_qualified_auto_decl);
+      InvalidDecl = true;
     }
     // Merge the decl with the existing one if appropriate. If the decl is
     // in an outer scope, it isn't the same thing.