Skip to content

Commit 15ef06f

Browse files
committed
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
1 parent 035441f commit 15ef06f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,8 @@ def err_pragma_fp_invalid_argument : Error<
14891489
"%select{"
14901490
"'fast' or 'on' or 'off'|"
14911491
"'on' or 'off'|"
1492-
"'ignore', 'maytrap' or 'strict'}2">;
1492+
"'ignore', 'maytrap' or 'strict'|"
1493+
"'source', 'double' or 'extended'}2">;
14931494

14941495
def err_pragma_invalid_keyword : Error<
14951496
"invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 'assume_safety'}1 or 'disable'">;

clang/test/Sema/fp-eval-pragma.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ int foo2() {
2727
return 0;
2828
}
2929

30+
void apply_pragma_with_wrong_value() {
31+
// expected-error@+1{{unexpected argument 'value' to '#pragma clang fp eval_method'; expected 'source', 'double' or 'extended'}}
32+
#pragma clang fp eval_method(value)
33+
}
34+
35+
int foo3() {
36+
apply_pragma_with_wrong_value();
37+
return 0;
38+
}
39+
3040
void foo() {
3141
auto a = __FLT_EVAL_METHOD__;
3242
{

0 commit comments

Comments
 (0)