[cfe-dev] pragma float_control(push) or (pop)
Aaron Ballman via cfe-dev
cfe-dev at lists.llvm.org
Wed Jul 28 10:02:27 PDT 2021
On Wed, Jul 28, 2021 at 12:46 PM James Y Knight via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> 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;
Oh, good suggestion James! I'll change what I did in
https://reviews.llvm.org/rGb0ef3d8f666fa6008abb09340b73d9340d442569 to
use this approach instead.
~Aaron
>
>
> 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list