<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 31, 2015 at 1:51 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><span style="color:rgb(34,34,34)">>> > Index: test/Index/</span><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__attributes-2Dcuda.cu&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=_9IoPHrAFyG-iDJu2XgNRe9LckXjE4GBp1JxFqv7JGk&s=YkEeg9yKYI9D48bQi64DsWAv9C1O0LRlK6GJEPFIE0U&e=" rel="noreferrer" target="_blank">attributes-cuda.cu</a><br></div></div><span class="">
>> > ===================================================================<br>
>> > --- test/Index/<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__attributes-2Dcuda.cu&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=_9IoPHrAFyG-iDJu2XgNRe9LckXjE4GBp1JxFqv7JGk&s=YkEeg9yKYI9D48bQi64DsWAv9C1O0LRlK6GJEPFIE0U&e=" rel="noreferrer" target="_blank">attributes-cuda.cu</a><br>
>> > +++ test/Index/<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__attributes-2Dcuda.cu&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=_9IoPHrAFyG-iDJu2XgNRe9LckXjE4GBp1JxFqv7JGk&s=YkEeg9yKYI9D48bQi64DsWAv9C1O0LRlK6GJEPFIE0U&e=" rel="noreferrer" target="_blank">attributes-cuda.cu</a><br>
>> > @@ -7,6 +7,14 @@<br>
>> >  __attribute__((constant)) int* g_constant;<br>
>> >  __attribute__((shared)) float *g_shared;<br>
>> >  __attribute__((host)) void f_host();<br>
>> > +__attribute__((device_builtin)) void f_device_builtin();<br>
>> > +typedef __attribute__((device_builtin)) const void *t_device_builtin;<br>
>> > +enum __attribute__((device_builtin)) e_device_builtin {};<br>
>> > +__attribute__((device_builtin)) int v_device_builtin;<br>
>> > +__attribute__((cudart_builtin)) void f_cudart_builtin();<br>
>> > +__attribute__((nv_weak)) void f_nv_weak();<br>
>> > +__attribute__((device_builtin_surface_type)) unsigned long long<br>
>> > surface_var;<br>
>> > +__attribute__((device_builtin_texture_type)) unsigned long long<br>
<br>
</span>I think a better place for this test is SemaCUDA since the point to<br>
the patch is to ensure we can parse and properly ignore the attribute.<br></blockquote><div> </div><div>OK. I'll add a no-warnings test there.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
We don't have any attr-specific tests in there, but I don't see a<br>
reason why we shouldn't add one now. </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When we stop ignoring some of<br>
these attributes in the future, we can add further tests to ensure<br>
they attach to the appropriate decls and are exposed to the C<br>
interface.<br></blockquote><div><br></div><div>How do you test for something like that in general? It appears that most of the tests in Sema* rely on -verify and as such rely only on errors/warnings/notes which would not be sufficient to ascertain correct construction of AST which appears to be what we'd really need for a test like this. Index tests appear to be a somewhat round-about way of achieving that. </div><div><br></div><div>--Artem</div><div><br></div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
~Aaron<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
>> > texture_var;<br>
>> ><br>
>> >  // CHECK:       attributes-cuda.cu:5:30: FunctionDecl=f_device:5:30<br>
>> >  // CHECK-NEXT:  attributes-cuda.cu:5:16: attribute(device)<br>
>> > @@ -18,3 +26,11 @@<br>
>> >  // CHECK-NEXT:  attributes-cuda.cu:8:16: attribute(shared)<br>
>> >  // CHECK:       attributes-cuda.cu:9:28: FunctionDecl=f_host:9:28<br>
>> >  // CHECK-NEXT:  attributes-cuda.cu:9:16: attribute(host)<br>
>> > +// CHECK:      attributes-cuda.cu:10:38:<br>
>> > FunctionDecl=f_device_builtin:10:38<br>
>> > +// CHECK:      attributes-cuda.cu:11:53:<br>
>> > TypedefDecl=t_device_builtin:11:53<br>
>> > +// CHECK:      attributes-cuda.cu:12:38:<br>
>> > EnumDecl=e_device_builtin:12:38<br>
>> > +// CHECK:      attributes-cuda.cu:13:37: VarDecl=v_device_builtin:13:37<br>
>> > +// CHECK:      attributes-cuda.cu:14:38:<br>
>> > FunctionDecl=f_cudart_builtin:14:38<br>
>> > +// CHECK:      attributes-cuda.cu:15:31: FunctionDecl=f_nv_weak:15:31<br>
>> > +// CHECK:      attributes-cuda.cu:16:65: VarDecl=surface_var:16:65<br>
>> > +// CHECK:      attributes-cuda.cu:17:65: VarDecl=texture_var:17:65<br>
>> > Index: include/clang/Basic/Attr.td<br>
>> > ===================================================================<br>
>> > --- include/clang/Basic/Attr.td<br>
>> > +++ include/clang/Basic/Attr.td<br>
>> > @@ -557,13 +557,37 @@<br>
>> >    let Documentation = [Undocumented];<br>
>> >  }<br>
>> ><br>
>> > +def CUDACudartBuiltin : IgnoredAttr {<br>
>> > +  let Spellings = [GNU<"cudart_builtin">];<br>
>> > +  let LangOpts = [CUDA];<br>
>> > +  let Documentation = [Undocumented];<br>
>> > +}<br>
>> > +<br>
>> >  def CUDADevice : InheritableAttr {<br>
>> >    let Spellings = [GNU<"device">];<br>
>> >    let Subjects = SubjectList<[Function, Var]>;<br>
>> >    let LangOpts = [CUDA];<br>
>> >    let Documentation = [Undocumented];<br>
>> >  }<br>
>> ><br>
>> > +def CUDADeviceBuiltin : IgnoredAttr {<br>
>> > +  let Spellings = [GNU<"device_builtin">];<br>
>> > +  let LangOpts = [CUDA];<br>
>> > +  let Documentation = [Undocumented];<br>
>> > +}<br>
>> > +<br>
>> > +def CUDADeviceBuiltinSurfaceType : IgnoredAttr {<br>
>> > +  let Spellings = [GNU<"device_builtin_surface_type">];<br>
>> > +  let LangOpts = [CUDA];<br>
>> > +  let Documentation = [Undocumented];<br>
>> > +}<br>
>> > +<br>
>> > +def CUDADeviceBuiltinTextureType : IgnoredAttr {<br>
>> > +  let Spellings = [GNU<"device_builtin_texture_type">];<br>
>> > +  let LangOpts = [CUDA];<br>
>> > +  let Documentation = [Undocumented];<br>
>> > +}<br>
>> > +<br>
>> >  def CUDAGlobal : InheritableAttr {<br>
>> >    let Spellings = [GNU<"global">];<br>
>> >    let Subjects = SubjectList<[Function]>;<br>
>> > @@ -1015,6 +1039,11 @@<br>
>> >    let Documentation = [Undocumented];<br>
>> >  }<br>
>> ><br>
>> > +def NvWeak : IgnoredAttr {<br>
>> > +  let Spellings = [GCC<"nv_weak">];<br>
>> > +  let Documentation = [Undocumented];<br>
>> > +}<br>
>><br>
>> Is this attribute supported by gcc? I did a quick test of<br>
>> [[gnu::nv_weak]] and it seemed to be an unknown attribute.<br>
>><br>
> That's a typo. Should've been GNU.<br>
><br>
> --Artem<br>
><br>
>><br>
>> ~Aaron<br>
>><br>
>> > +<br>
>> >  def ObjCBridge : InheritableAttr {<br>
>> >    let Spellings = [GNU<"objc_bridge">];<br>
>> >    let Subjects = SubjectList<[Record, TypedefName], ErrorDiag,<br>
>> ><br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > cfe-commits mailing list<br>
>> > <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
>> ><br>
><br>
><br>
><br>
><br>
> --<br>
> --Artem Belevich<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">--Artem Belevich</div></div>
</div></div>