ISO/IEC TR 18037 
An address space name cannot be used to qualify an object that has automatic
storage duration.  Still not catching ASQual'd allocas of array type, just 
scalars at the moment.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48350 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 7307fc4..28940ac 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -757,7 +757,6 @@
                                            D.getDeclSpec().isInlineSpecified(),
                                            LastDeclarator);
     // Handle attributes.
-
     HandleDeclAttributes(NewFD, D.getDeclSpec().getAttributes(),
                          D.getAttributes());
     
@@ -801,7 +800,13 @@
     // Handle attributes prior to checking for duplicates in MergeVarDecl
     HandleDeclAttributes(NewVD, D.getDeclSpec().getAttributes(),
                          D.getAttributes());
-     
+    // Emit a warning (error?) if an address space was applied to decl with
+    // local storage.
+    if (NewVD->hasLocalStorage() && 
+        (NewVD->getCanonicalType().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.
     if (PrevDecl && S->isDeclScope(PrevDecl)) {