brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 55867ff Raw
55 lines · c
1// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s2// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s -fexperimental-new-constant-interpreter3// RUN: %clang_cc1 -triple ppc64le -DPPC     -emit-llvm -o - -verify -x c++ %s4// RUN: %clang_cc1 -triple ppc64le -DPPC     -emit-llvm -o - -verify -x c++ %s -fexperimental-new-constant-interpreter5// RUN: not %clang_cc1 -triple ppc64le -DPPC     -emit-llvm -o - -x c++ %s \6// RUN:            -fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s7// RUN: not %clang_cc1 -triple ppc64le -DPPC     -emit-llvm -o - -x c++ %s -fexperimental-new-constant-interpreter \8// RUN:            -fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s9// RUN: %clang_cc1 -triple spir64 -emit-llvm -o - -verify -x c++ %s10// RUN: %clang_cc1 -triple spir64 -emit-llvm -o - -verify -x c++ %s -fexperimental-new-constant-interpreter11#ifndef PPC12int v;13template <typename T> T addT(T a, T b) {14  T *q = __arithmetic_fence(&a);15  // expected-error@-1 {{invalid operand of type 'float *' where floating, complex or a vector of such types is required}}16  // expected-error@-2 {{invalid operand of type 'int *' where floating, complex or a vector of such types is required}}17  return __arithmetic_fence(a + b);18  // expected-error@-1 {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}19}20int addit(int a, int b) {21  float x, y;22  typedef struct {23    int a, b;24  } stype;25  stype s;26  s = __arithmetic_fence(s);    // expected-error {{invalid operand of type 'stype' where floating, complex or a vector of such types is required}}27  x = __arithmetic_fence();     // expected-error {{too few arguments to function call, expected 1, have 0}}28  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}29  // Complex is supported.30  _Complex double cd, cd1;31  cd = __arithmetic_fence(cd1);32  // Vector is supported.33  typedef float __v4hi __attribute__((__vector_size__(8)));34  __v4hi vec1, vec2;35  vec1 = __arithmetic_fence(vec2);36 37  v = __arithmetic_fence(a + b); // expected-error {{invalid operand of type 'int' where floating, complex or a vector of such types is required}}38  float f = addT<float>(a, b);   // expected-note {{in instantiation of function template specialization 'addT<float>' requested here}}39  int i = addT<int>(1, 2);       // expected-note {{in instantiation of function template specialization 'addT<int>' requested here}}40  constexpr float d = 1.0 + 2.0;41  constexpr float c = __arithmetic_fence(1.0 + 2.0);42  constexpr float e = __arithmetic_fence(d);43  return 0;44}45bool func(float f1, float f2, float f3) {46  return (f1 == f2 && f1 == f3) || f2 == f3; // Should not warn here47}48static_assert( __arithmetic_fence(1.0 + 2.0), "message" );49#else50float addit(float a, float b) {51  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}52}53#endif54//PPC: error: option '-fprotect-parens' cannot be specified on this target55