[cfe-commits] r48350 - in /cfe/trunk: Sema/SemaDecl.cpp include/clang/Basic/DiagnosticKinds.def test/Sema/address_spaces.c

Nate Begeman natebegeman at mac.com
Thu Mar 13 17:22:18 PDT 2008


Author: sampo
Date: Thu Mar 13 19:22:18 2008
New Revision: 48350

URL: http://llvm.org/viewvc/llvm-project?rev=48350&view=rev
Log:
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.

Modified:
    cfe/trunk/Sema/SemaDecl.cpp
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/test/Sema/address_spaces.c

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=48350&r1=48349&r2=48350&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Thu Mar 13 19:22:18 2008
@@ -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)) {

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=48350&r1=48349&r2=48350&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Thu Mar 13 19:22:18 2008
@@ -584,6 +584,8 @@
      "address space attribute requires an integer constant")
 DIAG(err_attribute_address_multiple_qualifiers, ERROR,
      "multiple address spaces specified for type")
+DIAG(err_as_qualified_auto_decl, ERROR,
+     "automatic variable qualified with an address space")
 DIAG(err_attribute_annotate_no_string, ERROR,
      "argument to annotate attribute was not a string literal")
 DIAG(warn_attribute_ignored, WARNING,

Modified: cfe/trunk/test/Sema/address_spaces.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address_spaces.c?rev=48350&r1=48349&r2=48350&view=diff

==============================================================================
--- cfe/trunk/test/Sema/address_spaces.c (original)
+++ cfe/trunk/test/Sema/address_spaces.c Thu Mar 13 19:22:18 2008
@@ -11,5 +11,7 @@
   int _AS1 _AS2 *Y;  // expected-error {{multiple address spaces specified for type}}
   int *_AS1 _AS2 *Z;  // expected-error {{multiple address spaces specified for type}}
 
+  _AS1 int local; // expected-error {{automatic variable qualified with an address space}}
+
   *a = 5.0f;
 }





More information about the cfe-commits mailing list