brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 1c54714 Raw
81 lines · plain
1// RUN: %clang_cc1 -std=c++14 %s -triple nvptx64-nvidia-cuda \2// RUN:   -fcuda-is-device -verify -fsyntax-only3// RUN: %clang_cc1 -std=c++17 %s -triple nvptx64-nvidia-cuda \4// RUN:   -fcuda-is-device -verify -fsyntax-only5// RUN: %clang_cc1 -std=c++14 %s \6// RUN:   -triple x86_64-unknown-linux-gnu -verify -fsyntax-only7// RUN: %clang_cc1 -std=c++17 %s \8// RUN:   -triple x86_64-unknown-linux-gnu -verify -fsyntax-only9#include "Inputs/cuda.h"10 11template<typename T>12__host__ __device__ void foo(const T **a) {13  // expected-note@-1 {{declared here}}14  static const T b = sizeof(a);15  static constexpr T c = sizeof(a);16  const T d = sizeof(a);17  constexpr T e = sizeof(a);18  constexpr T f = **a;19  // expected-error@-1 {{constexpr variable 'f' must be initialized by a constant expression}}20  // expected-note@-2 {{}}21  a[0] = &b;22  a[1] = &c;23  a[2] = &d;24  a[3] = &e;25}26 27__device__ void device_fun(const int **a) {28  // expected-note@-1 {{declared here}}29  constexpr int b = sizeof(a);30  static constexpr int c = sizeof(a);31  constexpr int d = **a;32  // expected-error@-1 {{constexpr variable 'd' must be initialized by a constant expression}}33  // expected-note@-2 {{}}34  a[0] = &b;35  a[1] = &c;36  foo(a);37  // expected-note@-1 {{in instantiation of function template specialization 'foo<int>' requested here}}38}39 40void host_fun(const int **a) {41  // expected-note@-1 {{declared here}}42  constexpr int b = sizeof(a);43  static constexpr int c = sizeof(a);44  constexpr int d = **a;45  // expected-error@-1 {{constexpr variable 'd' must be initialized by a constant expression}}46  // expected-note@-2 {{}}47  a[0] = &b;48  a[1] = &c;49  foo(a);50}51 52__host__ __device__ void host_device_fun(const int **a) {53  // expected-note@-1 {{declared here}}54  constexpr int b = sizeof(a);55  static constexpr int c = sizeof(a);56  constexpr int d = **a;57  // expected-error@-1 {{constexpr variable 'd' must be initialized by a constant expression}}58  // expected-note@-2 {{}}59  a[0] = &b;60  a[1] = &c;61  foo(a);62}63 64template <class T>65struct A {66  explicit A() = default;67};68template <class T>69constexpr A<T> a{};70 71struct B {72  static constexpr bool value = true;73};74 75template<typename T>76struct C {77  static constexpr bool value = T::value;78};79 80__constant__ const bool &x = C<B>::value;81