[clang] 15ef06f - Diagnose when `#pragma clang fp eval_method` doesn't have a supported value.
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 10 13:20:15 PST 2022
Author: Zahira Ammarguellat
Date: 2022-03-10T13:19:53-08:00
New Revision: 15ef06f453c6f9513b476e80dd9567d01fc662e8
URL: https://github.com/llvm/llvm-project/commit/15ef06f453c6f9513b476e80dd9567d01fc662e8
DIFF: https://github.com/llvm/llvm-project/commit/15ef06f453c6f9513b476e80dd9567d01fc662e8.diff
LOG: Diagnose when `#pragma clang fp eval_method` doesn't have a supported value.
Currently the compiler is crashing.
Differential Revision: https://reviews.llvm.org/D121380
Added:
Modified:
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/test/Sema/fp-eval-pragma.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 92ae27d6212a0..7af15f5504ff9 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -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'">;
diff --git a/clang/test/Sema/fp-eval-pragma.cpp b/clang/test/Sema/fp-eval-pragma.cpp
index 42d88fd438e81..571b8097e9abf 100644
--- a/clang/test/Sema/fp-eval-pragma.cpp
+++ b/clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@ int foo2() {
return 0;
}
+void apply_pragma_with_wrong_value() {
+ // expected-error at +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__;
{
More information about the cfe-commits
mailing list