Index: include/clang/Basic/Attr.td =================================================================== --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -564,8 +564,6 @@ let Spellings = [Clang<"address_space">]; let Args = [IntArgument<"AddressSpace">]; let Documentation = [Undocumented]; - // Represented as a qualifier or DependentAddressSpaceType instead. - let ASTNode = 0; } def Alias : Attr { Index: lib/AST/TypePrinter.cpp =================================================================== --- lib/AST/TypePrinter.cpp +++ lib/AST/TypePrinter.cpp @@ -1427,6 +1427,9 @@ return; } + if (T->getAttrKind() == attr::AddressSpace) + return; + OS << " __attribute__(("; switch (T->getAttrKind()) { #define TYPE_ATTR(NAME) @@ -1494,6 +1497,9 @@ case attr::PreserveAll: OS << "preserve_all"; break; + + case attr::AddressSpace: + llvm_unreachable("Printing of address_space is handled by the qualifier"); } OS << "))"; } Index: lib/Sema/SemaType.cpp =================================================================== --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -7281,10 +7281,21 @@ case ParsedAttr::AT_OpenCLLocalAddressSpace: case ParsedAttr::AT_OpenCLConstantAddressSpace: case ParsedAttr::AT_OpenCLGenericAddressSpace: - case ParsedAttr::AT_AddressSpace: + case ParsedAttr::AT_AddressSpace: { HandleAddressSpaceTypeAttribute(type, attr, state.getSema()); + + if (attr.getKind() == ParsedAttr::AT_AddressSpace && + !type->getAs()) { + ASTContext &Ctx = state.getSema().Context; + auto *ASAttr = ::new (Ctx) AddressSpaceAttr( + attr.getRange(), Ctx, attr.getAttributeSpellingListIndex(), + static_cast(type.getQualifiers().getAddressSpace())); + type = state.getAttributedType(ASAttr, type, type); + } + attr.setUsedAsTypeAttr(); break; + } OBJC_POINTER_TYPE_ATTRS_CASELIST: if (!handleObjCPointerTypeAttr(state, attr, type)) distributeObjCPointerTypeAttr(state, attr, type);