[cfe-dev] pragma float_control(push) or (pop)

James Y Knight via cfe-dev cfe-dev at lists.llvm.org
Wed Jul 28 09:46:21 PDT 2021


I suspect this is just a bug and the code meant to say (untested):

*diff --git clang/lib/Sema/SemaAttr.cpp clang/lib/Sema/SemaAttr.cpp*

*index fe8f02f02368..2277e08d9b05 100644*

*--- clang/lib/Sema/SemaAttr.cpp*

*+++ clang/lib/Sema/SemaAttr.cpp*

@@ -475,7 +475,7 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,

                                    PragmaFloatControlKind Value) {

   FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();

   if ((Action == PSK_Push_Set || Action == PSK_Push || Action == PSK_Pop)
&&

-      !(CurContext->isTranslationUnit()) && !CurContext->isNamespace()) {

+      !CurContext->getRedeclContext()->isFileContext()) {

     // Push and pop can only occur at file or namespace scope.

     Diag(Loc, diag::err_pragma_fc_pp_scope);

     return;

On Wed, Jul 28, 2021 at 12:47 AM Smith, Kevin B via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> I was a little surprised by this behavior.  I was trying to write a header
> file that would use file scope pragma float_control(push) and pragma
> float_control(pop) and ran into this error.  It seems like this makes these
> pragmas pretty difficult to be effectively used.
>
>
>
> Thank you,
>
> Kevin Smith
>
>
>
> $ clang bad.cpp
>
> bad.cpp:2:9: error: '#pragma float_control push/pop' can only appear at
> file scope or namespace scope
>
> #pragma float_control(push)
>
>         ^
>
> bad.cpp:9:9: error: '#pragma float_control push/pop' can only appear at
> file scope or namespace scope
>
> #pragma float_control(pop)
>
>         ^
>
> 2 errors generated.
>
>
>
> $ cat bad.cpp
>
> extern "C++" {
>
> #pragma float_control(push)
>
> #pragma clang fp reassociate(off)
>
>
>
>   float my_silly_func(float a, float b) {
>
>     return (a + b) - b;
>
>   }
>
>
>
> #pragma float_control(pop)
>
> }
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210728/7c6b4e80/attachment.html>


More information about the cfe-dev mailing list