rjmccall added a comment.

In D146148#4217382 <https://reviews.llvm.org/D146148#4217382>, @zahiraam wrote:

> In D146148#4213475 <https://reviews.llvm.org/D146148#4213475>, @rjmccall 
> wrote:
>
>> The user isn't modifying the `float_t` type definition, they're using it.  I 
>> think the diagnostic should say something like `cannot use type 'float_t' 
>> within '#pragma clang fp eval_method'; type is set according to the default 
>> eval method for the translation unit`.
>>
>> Is there any way we can infer an attribute for these typedefs when they're 
>> declared, then diagnose it in `DiagnoseUseOfDecl`?  Some sort of 
>> "available_only_in_default_eval_method" attribute?
>
> @rjmccall Thanks for the review.
> I might be able to call the DiagnoseUseOfDecl here 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaType.cpp#L1609
>  but I don't seem to have access to the NameDecl (first argument of the 
> function).

We already call DiagnoseUseOfDecl whenever you use a declaration.  You wouldn't 
need to inject any extra code into the core type-lookup operation.

> Would the attribute be on the Decl?

I'm suggesting that you could add a check in DiagnoseUseOfDecl for some new 
attribute that you would synthesize when we build a typedef with this name.  
(We do something similar with library declarations of builtins.)  Or, better 
yet, we could just modify the header to explicitly use the attribute, or maybe 
add the attribute in a redeclaration in our own math.h; I don't know if those 
are feasible options.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146148/new/

https://reviews.llvm.org/D146148

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to