[clang] [clang] Add support for -fcx-limited-range and #pragma CX_LIMITED_RANGE. (PR #68820)

Joshua Cranmer via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 25 12:55:09 PDT 2023


================
@@ -846,6 +859,31 @@ void Parser::HandlePragmaFEnvRound() {
   Actions.ActOnPragmaFEnvRound(PragmaLoc, RM);
 }
 
+void Parser::HandlePragmaCXLimitedRange() {
+  assert(Tok.is(tok::annot_pragma_cx_limited_range));
+  tok::OnOffSwitch OOS = static_cast<tok::OnOffSwitch>(
+      reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
+
+  bool IsEnabled;
+  switch (OOS) {
+  case tok::OOS_ON:
+    IsEnabled = true;
+    break;
+  case tok::OOS_OFF:
+    IsEnabled = false;
+    break;
+  case tok::OOS_DEFAULT:
+    // According to ISO C99 standard chapter 7.3.4, the default value
+    // for the pragma is ``off'. In GCC, the option -fcx-limited-range
+    // controls the default setting of the pragma.
----------------
jcranmer-intel wrote:

GCC doesn't support these pragmas at all, but I believe it's reasonable to say that `-fcx-limited-range` and `-fcx-fortran-rules` controls the default value of these pragmas.

https://github.com/llvm/llvm-project/pull/68820


More information about the cfe-commits mailing list