[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / Sema / fp-eval-pragma-with-float-double_t-1.c
blobed47101d6443096146f145f9f63057c25d37b4eb
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 \
3 // RUN: -x c++ -DCPP -DNOERROR %s
5 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
6 // RUN: -ffp-eval-method=source -DNOERROR %s
7 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
8 // RUN: -ffp-eval-method=source \
9 // RUN: -DNOERROR %s
11 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
12 // RUN: -ffp-eval-method=double %s
13 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
14 // RUN: -ffp-eval-method=double %s
16 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only \
17 // RUN: -ffp-eval-method=extended %s
18 // RUN: %clang_cc1 -verify -triple x86_64-linux-gnu -fsyntax-only -x c++ -DCPP \
19 // RUN: -ffp-eval-method=extended %s
22 #ifdef NOERROR
23 // expected-no-diagnostics
24 typedef float float_t;
25 typedef double double_t;
26 #else
27 #ifdef CPP
28 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}}
30 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}}
31 #else
32 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}}
34 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}}
35 #endif
36 #endif
38 float foo1() {
39 #pragma clang fp eval_method(source)
40 float a;
41 double b;
42 return a - b;
45 float foo2() {
46 #pragma clang fp eval_method(source)
47 float_t a;
48 double_t b;
49 return a - b;
52 void foo3() {
53 #pragma clang fp eval_method(source)
54 char buff[sizeof(float_t)];
55 char bufd[sizeof(double_t)];
56 buff[1] = bufd[2];
59 float foo4() {
60 #pragma clang fp eval_method(source)
61 typedef float_t FT;
62 typedef double_t DT;
63 FT a;
64 DT b;
65 return a - b;
68 int foo5() {
69 #pragma clang fp eval_method(source)
70 int t = _Generic( 1.0L, float_t:1, default:0);
71 int v = _Generic( 1.0L, double_t:1, default:0);
72 return t;
75 void foo6() {
76 #pragma clang fp eval_method(source)
77 float f = (float_t)1;
78 double d = (double_t)2;
81 void foo7() {
82 #pragma clang fp eval_method(source)
83 float c1 = (float_t)12;
84 double c2 = (double_t)13;
87 float foo8() {
88 #pragma clang fp eval_method(source)
89 extern float_t f;
90 extern double_t g;
91 return f-g;
94 #ifdef CPP
95 void foo9() {
96 #pragma clang fp eval_method(source)
97 auto resf = [](float_t f) { return f; };
98 auto resd = [](double_t g) { return g; };
101 void foo10() {
102 #pragma clang fp eval_method(source)
103 using Ft = float_t;
104 using Dt = double_t;
105 Ft a;
106 Dt b;
108 #endif