]> granicus.if.org Git - clang/commitdiff
[clang] Fix mismatched args constructing AddressSpaceAttr.
authorAnton Bikineev <bikineev@google.com>
Wed, 7 Aug 2019 11:12:43 +0000 (11:12 +0000)
committerAnton Bikineev <bikineev@google.com>
Wed, 7 Aug 2019 11:12:43 +0000 (11:12 +0000)
Differential Revision: https://reviews.llvm.org/D65589

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368152 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
unittests/AST/ASTTraverserTest.cpp

index 00e2a0cdc3a1300856996d321fef9d6378a89fd6..37286158a02d470d8ef2c073fed6ea0d2ef3681a 100644 (file)
@@ -5978,9 +5978,9 @@ static void HandleAddressSpaceTypeAttribute(QualType &Type,
     }
 
     ASTContext &Ctx = S.Context;
-    auto *ASAttr = ::new (Ctx) AddressSpaceAttr(
-        Attr.getRange(), Ctx, Attr.getAttributeSpellingListIndex(),
-        static_cast<unsigned>(ASIdx));
+    auto *ASAttr = ::new (Ctx)
+        AddressSpaceAttr(Attr.getRange(), Ctx, static_cast<unsigned>(ASIdx),
+                         Attr.getAttributeSpellingListIndex());
 
     // If the expression is not value dependent (not templated), then we can
     // apply the address space qualifiers just to the equivalent type.
index cddb219a79fb6e6e066fc640a542d36eaa684a32..69812cb8d21c16f72c8cd6dccff697a75bc0d608 100644 (file)
@@ -139,6 +139,8 @@ struct templ<int>
 { 
 };
 
+void parmvardecl_attr(struct A __attribute__((address_space(19)))*);
+
 )cpp");
 
   const FunctionDecl *Func = getFunctionNode(AST.get(), "func");
@@ -220,5 +222,16 @@ FullComment
                     R"cpp(
 TemplateArgument
 )cpp");
+
+  Func = getFunctionNode(AST.get(), "parmvardecl_attr");
+
+  const auto *Parm = Func->getParamDecl(0);
+  const auto TL = Parm->getTypeSourceInfo()->getTypeLoc();
+  ASSERT_TRUE(TL.getType()->isPointerType());
+
+  const auto ATL = TL.getNextTypeLoc().getAs<AttributedTypeLoc>();
+  const auto *AS = cast<AddressSpaceAttr>(ATL.getAttr());
+  EXPECT_EQ(toTargetAddressSpace(static_cast<LangAS>(AS->getAddressSpace())),
+            19u);
 }
 } // namespace clang