[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / clang / test / Sema / fp-eval-pragma-with-float-double_t-3.c
blobd58a36dc108ae49dcef8785736ecb88b98f48807
1 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s
2 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -DNOERROR %s -fexperimental-new-constant-interpreter
4 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
5 // RUN: -x c++ -DCPP -DNOERROR %s
6 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
7 // RUN: -x c++ -DCPP -DNOERROR %s -fexperimental-new-constant-interpreter
9 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
10 // RUN: -ffp-eval-method=extended -DNOERROR %s
11 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
12 // RUN: -ffp-eval-method=extended -DNOERROR %s -fexperimental-new-constant-interpreter
14 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
15 // RUN: -ffp-eval-method=extended -DNOERROR %s
16 // 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-interpreter
19 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
20 // RUN: -ffp-eval-method=source %s
21 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
22 // RUN: -ffp-eval-method=source %s -fexperimental-new-constant-interpreter
24 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
25 // RUN: -ffp-eval-method=source %s
26 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
27 // RUN: -ffp-eval-method=source %s -fexperimental-new-constant-interpreter
29 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
30 // RUN: -ffp-eval-method=double %s
31 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
32 // RUN: -ffp-eval-method=double %s -fexperimental-new-constant-interpreter
34 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
35 // RUN: -ffp-eval-method=double %s
36 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
37 // RUN: -ffp-eval-method=double %s -fexperimental-new-constant-interpreter
39 #ifdef NOERROR
40 // expected-no-diagnostics
41 typedef float float_t;
42 typedef double double_t;
43 #else
44 #ifdef CPP
45 typedef 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}}
47 typedef 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 #else
49 typedef 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}}
51 typedef 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 #endif
53 #endif
55 float foo1() {
56 #pragma clang fp eval_method(extended)
57 float a;
58 double b;
59 return a - b;
62 float foo2() {
63 #pragma clang fp eval_method(extended)
64 float_t a;
65 double_t b;
66 return a - b;
69 void 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];
76 float 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;
85 int 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;
92 void foo6() {
93 #pragma clang fp eval_method(extended)
94 float f = (float_t)1;
95 double d = (double_t)2;
98 void foo7() {
99 #pragma clang fp eval_method(extended)
100 float c1 = (float_t)12;
101 double c2 = (double_t)13;
104 float foo8() {
105 #pragma clang fp eval_method(extended)
106 extern float_t f;
107 extern double_t g;
108 return f-g;
111 #ifdef CPP
112 void foo9() {
113 #pragma clang fp eval_method(extended)
114 auto resf = [](float_t f) { return f; };
115 auto resd = [](double_t g) { return g; };
118 void foo10() {
119 #pragma clang fp eval_method(extended)
120 using Ft = float_t;
121 using Dt = double_t;
122 Ft a;
123 Dt b;
125 #endif