<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Need __has_pragma"
   href="https://bugs.llvm.org/show_bug.cgi?id=52545">52545</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Need __has_pragma
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>scanon@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We have __has_feature and __has_attribute and a number of other variants so
that code can take advantage of new features while still functioning with older
clang versions. We should also have __has_pragma for the same reason.

In particular, I was recently bitten by trying to use the clang fp
reassociate(on) pragma, which is available in clang-11+; rather than producing
an "unknown pragma" warning, older clangs produce the error "invalid option
'reassociate'; expected contract".

An alternative solution (which would have worked in my case) would be to have
unknown pragma options always be a warning instead of an error, but in general
it's a better option to have __has_pragma, because it gives the user the
building block to fallback on a different solution or to produce an error in
cases where that's more appropriate.

I think a minimum-viable __has_pragma would take a string argument that's the
entire pragma body and produce a result of 1 if the string is an accepted
pragma for the current target.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>