def warn_pragma_pop_failed : Warning<"#pragma %0(pop, ...) failed: %1">,
InGroup<IgnoredPragmas>;
def err_pragma_fc_pp_scope : Error<
- "'#pragma float_control push/pop' can only appear at file scope">;
+ "'#pragma float_control push/pop' can only appear at file scope or namespace scope">;
def err_pragma_fc_noprecise_requires_nofenv : Error<
"'#pragma float_control(precise, off)' is illegal when fenv_access is enabled">;
def err_pragma_fc_except_requires_precise : Error<
auto NewValue = FpPragmaStack.CurrentValue;
FPOptions NewFPFeatures(NewValue);
if ((Action == PSK_Push_Set || Action == PSK_Push || Action == PSK_Pop) &&
- !CurContext->isTranslationUnit()) {
- // Push and pop can only occur at file scope.
+ !(CurContext->isTranslationUnit()) && !CurContext->isNamespace()) {
+ // Push and pop can only occur at file or namespace scope.
Diag(Loc, diag::err_pragma_fc_pp_scope);
return;
}
D->hasWrittenPrototype(), D->getConstexprKind(),
TrailingRequiresClause);
Function->setRangeEnd(D->getSourceRange().getEnd());
+ Function->setUsesFPIntrin(D->usesFPIntrin());
}
if (D->isInlined())
+// RUN: %clang_cc1 -DEXCEPT=1 -fcxx-exceptions -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NS %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -verify -DFENV_ON=1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
z = z * z;
//CHECK: = fmul float
}
+
+#if EXCEPT
+namespace ns {
+// Check that pragma float_control can appear in namespace.
+#pragma float_control(except, on, push)
+float exc_on(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_on{{.*}}
+ {} try {
+ x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
+ } catch (...) {}
+ return zero;
+}
+}
+
+// Check pragma is still effective after namespace closes
+float exc_still_on(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_still_on{{.*}}
+ {} try {
+ x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
+ } catch (...) {}
+ return zero;
+}
+
+#pragma float_control(pop)
+float exc_off(double x, float zero) {
+// CHECK-NS: define {{.*}}exc_off{{.*}}
+ {} try {
+ x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: fdiv contract double
+ } catch (...) {}
+ return zero;
+}
+
+namespace fc_template_namespace {
+#pragma float_control(except, on, push)
+template <class T>
+T exc_on(double x, T zero) {
+// CHECK-NS: define {{.*}}fc_template_namespace{{.*}}
+ {} try {
+ x = 1.0 / zero; /* division by zero, the result unused */
+//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
+ } catch (...) {}
+ return zero;
+}
+}
+
+#pragma float_control(pop)
+float xx(double x, float z) {
+ return fc_template_namespace::exc_on<float>(x, z);
+}
+#endif // EXCEPT
#pragma float_control(pop)
#pragma float_control(precise, on, push)
void check_stack() {
-#pragma float_control(push) // expected-error {{can only appear at file scope}}
-#pragma float_control(pop) // expected-error {{can only appear at file scope}}
-#pragma float_control(precise, on, push) // expected-error {{can only appear at file scope}}
-#pragma float_control(except, on, push) // expected-error {{can only appear at file scope}}
+#pragma float_control(push) // expected-error {{can only appear at file scope or namespace scope}}
+#pragma float_control(pop) // expected-error {{can only appear at file scope or namespace scope}}
+#pragma float_control(precise, on, push) // expected-error {{can only appear at file scope or namespace scope}}
+#pragma float_control(except, on, push) // expected-error {{can only appear at file scope or namespace scope}}
#pragma float_control(except, on, push, junk) // expected-error {{float_control is malformed}}
return;
}