<div dir="ltr">I suspect this is just a bug and the code meant to say (untested):<div>





<p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b>diff --git clang/lib/Sema/SemaAttr.cpp clang/lib/Sema/SemaAttr.cpp</b></span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b>index fe8f02f02368..2277e08d9b05 100644</b></span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b>--- clang/lib/Sema/SemaAttr.cpp</b></span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b>+++ clang/lib/Sema/SemaAttr.cpp</b></span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(46,174,187)">@@ -475,7 +475,7 @@</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"> void Sema::ActOnPragmaFloatControl(SourceLocation Loc,</span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">                                    </span>PragmaFloatControlKind Value) {</span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">   </span>FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();</span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">   </span>if ((Action == PSK_Push_Set || Action == PSK_Push || Action == PSK_Pop) &&</span></p><p class="gmail-p2" style="margin:0px;font:11px Menlo;color:rgb(180,36,25)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-<span class="gmail-Apple-converted-space">      </span>!(CurContext->isTranslationUnit()) && !CurContext->isNamespace()) {</span></p><p class="gmail-p3" style="margin:0px;font:11px Menlo;color:rgb(47,180,29)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">+<span class="gmail-Apple-converted-space">      </span>!CurContext->getRedeclContext()->isFileContext()) {</span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">     </span>// Push and pop can only occur at file or namespace scope.</span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">     </span>Diag(Loc, diag::err_pragma_fc_pp_scope);</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">

















</p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">     </span>return;</span></p></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 28, 2021 at 12:47 AM Smith, Kevin B via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="gmail-m_6753880315069242905WordSection1">
<p class="MsoNormal">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. <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thank you,<u></u><u></u></p>
<p class="MsoNormal">Kevin Smith<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ clang bad.cpp<u></u><u></u></p>
<p class="MsoNormal">bad.cpp:2:9: error: '#pragma float_control push/pop' can only appear at file scope or namespace scope<u></u><u></u></p>
<p class="MsoNormal">#pragma float_control(push)<u></u><u></u></p>
<p class="MsoNormal">        ^<u></u><u></u></p>
<p class="MsoNormal">bad.cpp:9:9: error: '#pragma float_control push/pop' can only appear at file scope or namespace scope<u></u><u></u></p>
<p class="MsoNormal">#pragma float_control(pop)<u></u><u></u></p>
<p class="MsoNormal">        ^<u></u><u></u></p>
<p class="MsoNormal">2 errors generated.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ cat bad.cpp<u></u><u></u></p>
<p class="MsoNormal">extern "C++" {<u></u><u></u></p>
<p class="MsoNormal">#pragma float_control(push)<u></u><u></u></p>
<p class="MsoNormal">#pragma clang fp reassociate(off)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">  float my_silly_func(float a, float b) {<u></u><u></u></p>
<p class="MsoNormal">    return (a + b) - b;<u></u><u></u></p>
<p class="MsoNormal">  }<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">#pragma float_control(pop)<u></u><u></u></p>
<p class="MsoNormal">}<u></u><u></u></p>
</div>
</div>

_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>