<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Calibri Light";
        panose-1:2 15 3 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hello dear community,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’ve been trying to implement a way to set address spaces using a custom C++11-style attribute, but I’ve been running into problems. The syntax I’m trying to use is:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>[[vms::ptr_32]] int* HiIAmA32BitPtr{ (int*)0xFFFF'FFFF };<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>But apparently clang ignores those C++11-style attributes. Looking at the source, it’s because the attribute isn’t attached properly to the DeclSpec since…<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:9.5pt;font-family:Consolas;color:#2B91AF'>DeclaratorChunk</span><span style='font-size:9.5pt;font-family:Consolas;color:black'>& DeclType = D.getTypeObject(chunkIndex);<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.5pt;font-family:Consolas;color:black'><o:p> </o:p></span></p><p class=MsoNormal>…returns NULL. Not sure why, or what it is doing. The alternative way of doing it that I found is doing:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>int* [[vms::ptr_32]] HiIAmA32BitPtr{ (int*)0xFFFF'FFFF };<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>This attribute is detected properly, but the type passed into <span style='font-size:9.5pt;font-family:Consolas;color:black'>processTypeAttrs </span>is int* (apparently if using the __attribute((address_space)) syntax, it passes in regulator int), and attaching the address space to int* doesn’t seem to work as clang creates an llvm::type (lib/CodeGen/CodeGenTypes.cpp) using the address space of the pointee instead of the actual pointer type. That seems weird to me, but I don’t know what exactly address spaces are or how they work.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>So I’m a little confused on how to approach this. I would like the first syntax to work if possible, but I’m not sure how one would go about implementing that without breaking anything. The second syntax seems to behave in a non-ideal way, by passing in int* instead of int. Not sure how one would go about fixing that, or if one should just make a hack to try to get the underlying type. I use address spaces since it seems like a good way to use mixed pointer sizes in the same translation unit.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Any ideas or thoughts?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-top:12.0pt;page-break-after:avoid'><span style='font-family:"Calibri Light",sans-serif;color:#A5A5A5;mso-fareast-language:EN-GB'>Regards,</span><span style='color:black;mso-fareast-language:EN-GB'><o:p></o:p></span></p><p class=MsoNormal style='page-break-after:avoid'><span style='font-family:"Calibri Light",sans-serif;color:#A5A5A5;mso-fareast-language:EN-GB'>Patrik Eklöf</span><span style='color:black;mso-fareast-language:EN-GB'><o:p></o:p></span></p></div></body></html>