127 lines · c
1// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s2// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s -fexperimental-new-constant-interpreter3 4// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \5// RUN: -x c++ -DCPP -DNOERROR %s6// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \7// RUN: -x c++ -DCPP -DNOERROR %s -fexperimental-new-constant-interpreter8 9// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \10// RUN: -ffp-eval-method=extended -DNOERROR %s11// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \12// RUN: -ffp-eval-method=extended -DNOERROR %s -fexperimental-new-constant-interpreter13 14// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \15// RUN: -ffp-eval-method=extended -DNOERROR %s16// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \17// RUN: -ffp-eval-method=extended -DNOERROR %s -fexperimental-new-constant-interpreter18 19// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \20// RUN: -ffp-eval-method=source %s21// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \22// RUN: -ffp-eval-method=source %s -fexperimental-new-constant-interpreter23 24// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \25// RUN: -ffp-eval-method=source %s26// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \27// RUN: -ffp-eval-method=source %s -fexperimental-new-constant-interpreter28 29// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \30// RUN: -ffp-eval-method=double %s31// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \32// RUN: -ffp-eval-method=double %s -fexperimental-new-constant-interpreter33 34// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \35// RUN: -ffp-eval-method=double %s36// RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \37// RUN: -ffp-eval-method=double %s -fexperimental-new-constant-interpreter38 39#ifdef NOERROR40// expected-no-diagnostics41typedef float float_t;42typedef double double_t;43#else44#ifdef CPP45typedef float float_t; //expected-error 9 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}46 47typedef double double_t; //expected-error 9 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}48#else49typedef float float_t; //expected-error 7 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}50 51typedef double double_t; //expected-error 7 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}52#endif53#endif54 55float foo1() {56#pragma clang fp eval_method(extended)57 float a;58 double b;59 return a - b;60}61 62float foo2() {63#pragma clang fp eval_method(extended)64 float_t a; 65 double_t b; 66 return a - b;67}68 69void foo3() {70#pragma clang fp eval_method(extended)71 char buff[sizeof(float_t)];72 char bufd[sizeof(double_t)];73 buff[1] = bufd[2];74}75 76float foo4() {77#pragma clang fp eval_method(extended)78 typedef float_t FT;79 typedef double_t DT;80 FT a;81 DT b;82 return a - b;83}84 85int foo5() {86#pragma clang fp eval_method(extended)87 int t = _Generic( 1.0L, float_t:1, default:0);88 int v = _Generic( 1.0L, double_t:1, default:0);89 return t;90}91 92void foo6() {93#pragma clang fp eval_method(extended)94 float f = (float_t)1; 95 double d = (double_t)2; 96}97 98void foo7() {99#pragma clang fp eval_method(extended)100 float c1 = (float_t)12;101 double c2 = (double_t)13;102}103 104float foo8() {105#pragma clang fp eval_method(extended)106 extern float_t f;107 extern double_t g;108 return f-g;109}110 111#ifdef CPP112void foo9() {113#pragma clang fp eval_method(extended)114 auto resf = [](float_t f) { return f; };115 auto resd = [](double_t g) { return g; };116}117 118void foo10() {119#pragma clang fp eval_method(extended)120 using Ft = float_t;121 using Dt = double_t;122 Ft a;123 Dt b;124}125#endif126 127