brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.0 KiB · 90a81ac Raw
55 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify %s2 3// Check that we emit the correct warnings in various situations where the C++114// spelling of the `address_space` attribute is applied to a declaration instead5// of a type. Also check that the attribute can instead be applied to the type.6 7void f([[clang::address_space(1)]] int* param) { // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}8  [[clang::address_space(1)]] int* local1; // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}9  int* local2 [[clang::address_space(1)]]; // expected-error {{automatic variable qualified with an address space}} expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}10  int [[clang::address_space(1)]] * local3;11  int* [[clang::address_space(1)]] local4; // expected-error {{automatic variable qualified with an address space}}12 13  for ([[clang::address_space(1)]] int* p = nullptr; p; ++p) {} // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}14  for (; [[clang::address_space(1)]] int* p = nullptr; ) {} // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}15  while([[clang::address_space(1)]] int* p = nullptr) {} // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}16  if ([[clang::address_space(1)]] int* p = nullptr) {} // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}17  try {18  } catch([[clang::address_space(1)]] int& i) { // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}19  }20 21  for (int [[clang::address_space(1)]] * p = nullptr; p; ++p) {}22  for (; int [[clang::address_space(1)]] * p = nullptr; ) {}23  while(int [[clang::address_space(1)]] * p = nullptr) {}24  if (int [[clang::address_space(1)]] * p = nullptr) {}25  try {26  } catch(int [[clang::address_space(1)]] & i) {27  }28}29 30[[clang::address_space(1)]] int* return_value(); // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}31int [[clang::address_space(1)]] * return_value();32 33[[clang::address_space(1)]] int global1; // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}34int global2 [[clang::address_space(1)]]; // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}35int [[clang::address_space(1)]] global3;36int [[clang::address_space(1)]] global4;37 38struct [[clang::address_space(1)]] S { // expected-error {{'clang::address_space' attribute cannot be applied to a declaration}}39  [[clang::address_space(1)]] int* member_function_1(); // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}40  int [[clang::address_space(1)]] * member_function_2();41};42 43template <class T>44[[clang::address_space(1)]] T var_template_1; // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}45template <class T>46T [[clang::address_space(1)]] var_template_2;47 48using void_ptr [[clang::address_space(1)]] = void *; // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}49// Intentionally using the same alias name to check that the aliases define the50// same type.51using void_ptr = void [[clang::address_space(1)]] *;52 53namespace N {}54[[clang::address_space(1)]] using namespace N; // expected-error {{'clang::address_space' attribute cannot be applied to a declaration}}55