[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Sema / arithmetic-fence-builtin.c
blob4f4f0a02cde9ec0b610f6a7a8784d6c8fb98c16d
1 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
2 // RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
3 // RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
4 // RUN: -fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
5 #ifndef PPC
6 int v;
7 template <typename T> T addT(T a, T b) {
8 T *q = __arithmetic_fence(&a);
9 // expected-error@-1 {{invalid operand of type 'float *' where floating, complex or a vector of such types is required}}
10 // expected-error@-2 {{invalid operand of type 'int *' where floating, complex or a vector of such types is required}}
11 return __arithmetic_fence(a + b);
12 // expected-error@-1 {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
14 int addit(int a, int b) {
15 float x, y;
16 typedef struct {
17 int a, b;
18 } stype;
19 stype s;
20 s = __arithmetic_fence(s); // expected-error {{invalid operand of type 'stype' where floating, complex or a vector of such types is required}}
21 x = __arithmetic_fence(); // expected-error {{too few arguments to function call, expected 1, have 0}}
22 x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
23 // Complex is supported.
24 _Complex double cd, cd1;
25 cd = __arithmetic_fence(cd1);
26 // Vector is supported.
27 typedef float __v4hi __attribute__((__vector_size__(8)));
28 __v4hi vec1, vec2;
29 vec1 = __arithmetic_fence(vec2);
31 v = __arithmetic_fence(a + b); // expected-error {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}
32 float f = addT<float>(a, b); // expected-note {{in instantiation of function template specialization 'addT<float>' requested here}}
33 int i = addT<int>(1, 2); // expected-note {{in instantiation of function template specialization 'addT<int>' requested here}}
34 constexpr float d = 1.0 + 2.0;
35 constexpr float c = __arithmetic_fence(1.0 + 2.0);
36 constexpr float e = __arithmetic_fence(d);
37 return 0;
39 bool func(float f1, float f2, float f3) {
40 return (f1 == f2 && f1 == f3) || f2 == f3; // Should not warn here
42 static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
43 #else
44 float addit(float a, float b) {
45 return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
47 #endif
48 //PPC: error: option '-fprotect-parens' cannot be specified on this target