Diagnose when `#pragma clang fp eval_method` doesn't have a supported value.
authorZahira Ammarguellat <zahira.ammarguellat@intel.com>
Thu, 10 Mar 2022 16:08:12 +0000 (08:08 -0800)
committerZahira Ammarguellat <zahira.ammarguellat@intel.com>
Thu, 10 Mar 2022 21:19:53 +0000 (13:19 -0800)
Currently the compiler is crashing.

Differential Revision: https://reviews.llvm.org/D121380

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

index 92ae27d..7af15f5 100644 (file)
@@ -1489,7 +1489,8 @@ def err_pragma_fp_invalid_argument : Error<
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source', 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 'assume_safety'}1 or 'disable'">;
index 42d88fd..571b809 100644 (file)
@@ -27,6 +27,16 @@ int foo2() {
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+  // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp eval_method'; expected 'source', '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__;
   {