55 lines · c
1// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s2// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffp-exception-behavior=strict -DSTRICT -fsyntax-only -verify %s3// RUN: %clang_cc1 -triple x86_64-linux-gnu -x c++ -DCPP -DSTRICT -ffp-exception-behavior=strict -fsyntax-only -verify %s4#ifdef CPP5#define CONST constexpr6#else7#define CONST const8#endif9 10#pragma STDC FENV_ACCESS IN_BETWEEN // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}11 12#pragma STDC FENV_ACCESS OFF13 14float func_04(int x, float y) {15 if (x)16 return y + 2;17 #pragma STDC FENV_ACCESS ON // expected-error{{'#pragma STDC FENV_ACCESS' can only appear at file scope or at the start of a compound statement}}18 return x + y;19}20 21#pragma STDC FENV_ACCESS ON22int main(void) {23 CONST float one = 1.0F ;24 CONST float three = 3.0F ;25 CONST float four = 4.0F ;26 CONST float frac_ok = one/four;27#if !defined(CPP)28//expected-note@+2 {{declared here}}29#endif30 CONST float frac = one/three;31 CONST double d = one;32 CONST int not_too_big = 255;33 CONST float fnot_too_big = not_too_big;34 CONST int too_big = 0x7ffffff0;35#if defined(CPP)36//expected-warning@+2{{implicit conversion}}37#endif38 CONST float fbig = too_big; // inexact39#if !defined(CPP)40#define static_assert _Static_assert41#endif42enum {43 e1 = (int)one, e3 = (int)three, e4 = (int)four, e_four_quarters = (int)(frac_ok * 4)44};45static_assert(e1 == 1 && e3 == 3 && e4 == 4 && e_four_quarters == 1, "");46enum {47#if !defined(CPP)48// expected-error@+2 {{not an integer constant expression}} expected-note@+2 {{is not a constant expression}}49#endif50 e_three_thirds = (int)(frac * 3)51};52 if (one <= four) return 0;53 return -1;54}55