llvm-project/clang/test/AST/ast-dump-fpfeatures.m
Serge Pavlov 0140ba031c
[clang] Enable FPContract with optnone (#91061)
Previously treatment of the attribute `optnone` was modified in
https://github.com/llvm/llvm-project/pull/85605 ([clang] Set correct
FPOptions if attribute 'optnone' presents). As a side effect FPContract
was disabled for optnone. It created unneeded divergence with the
behavior of -O0, which enables this optimization.

In the discussion
https://github.com/llvm/llvm-project/pull/85605#issuecomment-2089350379
it was pointed out that FP contraction should be enabled even if all
optimizations are turned off, otherwise results of calculations would be
different. This change enables FPContract at optnone.
2024-05-06 14:30:54 +07:00

30 lines
978 B
Objective-C

// Test without serialization:
// RUN: %clang_cc1 -triple x86_64-pc-linux -ast-dump %s \
// RUN: | FileCheck --strict-whitespace %s
// Test with serialization:
// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-pch -o %t %s
// RUN: %clang_cc1 -x objective-c -triple x86_64-pc-linux -include-pch %t -ast-dump-all /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck --strict-whitespace %s
@interface Adder
- (float) sum: (float)x with: (float)y __attribute((optnone));
@end
#pragma float_control(precise, off)
@implementation Adder
- (float) sum: (float)x with: (float)y __attribute((optnone)) {
return x + y;
}
@end
// CHECK-LABEL: ObjCImplementationDecl {{.*}} Adder
// CHECK: ObjCMethodDecl {{.*}} - sum:with: 'float'
// CHECK: CompoundStmt {{.*}} FPContractMode=1 MathErrno=1
// CHECK-NEXT: ReturnStmt
// CHECK-NEXT: BinaryOperator {{.*}} 'float' '+' FPContractMode=1 MathErrno=1