brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 571b809 Raw
98 lines · cpp
1// RUN: %clang_cc1 -fexperimental-strict-floating-point \2// RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s3//4// RUN: %clang_cc1 -fexperimental-strict-floating-point \5// RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s \6// RUN: -ffp-eval-method=source7//8// RUN: %clang_cc1 -fexperimental-strict-floating-point \9// RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s \10// RUN: -ffp-eval-method=double11 12extern "C" int printf(const char *, ...);13 14void foo1() {15  printf("FP: %d\n", __FLT_EVAL_METHOD__);16}17 18void apply_pragma() {19  // expected-note@+1{{#pragma entered here}}20#pragma clang fp eval_method(double)21  // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}22  printf("FP: %d\n", __FLT_EVAL_METHOD__);23}24 25int foo2() {26  apply_pragma();27  return 0;28}29 30void 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 35int foo3() {36  apply_pragma_with_wrong_value();37  return 0;38}39 40void foo() {41  auto a = __FLT_EVAL_METHOD__;42  {43    // expected-note@+1{{#pragma entered here}}44#pragma clang fp eval_method(double)45    // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}46    auto b = __FLT_EVAL_METHOD__;47  }48  auto c = __FLT_EVAL_METHOD__;49}50 51void func() {52  {53    {54#pragma clang fp eval_method(source)55    }56    int i = __FLT_EVAL_METHOD__; // ok, not in a scope changed by the pragma57  }58  {59    // expected-note@+1{{#pragma entered here}}60#pragma clang fp eval_method(source)61    // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}62    int i = __FLT_EVAL_METHOD__;63  }64}65 66float G;67 68int f(float x, float y, float z) {69  G = x * y + z;70  return __FLT_EVAL_METHOD__;71}72 73int foo(int flag, float x, float y, float z) {74  if (flag) {75    // expected-note@+1{{#pragma entered here}}76#pragma clang fp eval_method(double)77    G = x + y + z;78    // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}79    return __FLT_EVAL_METHOD__;80  } else {81    // expected-note@+1{{#pragma entered here}}82#pragma clang fp eval_method(extended)83    G = x + y + z;84    // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}85    return __FLT_EVAL_METHOD__;86  }87}88 89#if __FLT_EVAL_METHOD__ == 190#endif91#pragma clang fp eval_method(source)92 93// expected-note@+1{{#pragma entered here}}94#pragma clang fp eval_method(double)95// expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}96#if __FLT_EVAL_METHOD__ == 197#endif98