[PATCH] D121380: Pragma `clang fp eval_method` needs to take as input a supported value.

Zahira Ammarguellat via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 10 08:17:35 PST 2022


zahiraam created this revision.
zahiraam added reviewers: aaron.ballman, andrew.w.kaylor.
Herald added a project: All.
zahiraam requested review of this revision.
Herald added a project: clang.

Diagnose when `#pragma clang fp eval_method` doesn't have a supported value. Currently the compiler is crashing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121380

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/test/Sema/fp-eval-pragma.cpp


Index: clang/test/Sema/fp-eval-pragma.cpp
===================================================================
--- clang/test/Sema/fp-eval-pragma.cpp
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+ // expected-error at +1{{unexpected argument 'value' to '#pragma clang fp eval_method'; expected 'source' or 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source' or 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 'assume_safety'}1 or 'disable'">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121380.414383.patch
Type: text/x-patch
Size: 1148 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220310/f7bf628d/attachment.bin>


More information about the cfe-commits mailing list