<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Oct 2, 2017 at 3:33 PM Andrew Gozillon via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: agozillon<br>
Date: Sun Oct  1 23:31:25 2017<br>
New Revision: 314650<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=314650&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=314650&view=rev</a><br>
Log:<br>
Dependent Address Space Support Test File<br>
<br>
Adding regression test for Dependent Address Spaces in relation to<br>
<a href="https://reviews.llvm.org/D33666" rel="noreferrer" target="_blank">https://reviews.llvm.org/D33666</a> I forgot to svn add the test file<br>
before commiting the prior changes. I appologies.<br>
<br>
<br>
Added:<br>
    cfe/trunk/test/SemaTemplate/address_space-dependent.cpp<br>
<br>
Added: cfe/trunk/test/SemaTemplate/address_space-dependent.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/address_space-dependent.cpp?rev=314650&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/address_space-dependent.cpp?rev=314650&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaTemplate/address_space-dependent.cpp (added)<br>
+++ cfe/trunk/test/SemaTemplate/address_space-dependent.cpp Sun Oct  1 23:31:25 2017<br>
@@ -0,0 +1,119 @@<br>
+// RUN: %clang_cc1 -x c++ -std=c++14 -fsyntax-only -verify %s<br>
+<br>
+template <int I, int J, int K><br>
+void car() {<br>
+  int __attribute__((address_space(I))) __attribute__((address_space(J))) * Y;  // expected-error {{multiple address spaces specified for type}}<br>
+  int *__attribute__((address_space(I))) __attribute__((address_space(J))) * Z; // expected-error {{multiple address spaces specified for type}}<br>
+<br>
+  __attribute__((address_space(I))) int local;        // expected-error {{automatic variable qualified with an address space}}<br>
+  __attribute__((address_space(J))) int array[5];     // expected-error {{automatic variable qualified with an address space}}<br>
+  __attribute__((address_space(I))) int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}}<br>
+<br>
+  __attribute__((address_space(J))) * x; // expected-error {{C++ requires a type specifier for all declarations}}<br>
+<br>
+  __attribute__((address_space(I))) float *B;<br>
+<br>
+  typedef __attribute__((address_space(J))) int AS2Int;<br>
+  struct HasASFields {<br>
+    AS2Int typedef_as_field; // expected-error {{field may not be qualified with an address space}}<br>
+  };<br>
+<br>
+  struct _st {<br>
+    int x, y;<br>
+  } s __attribute((address_space(I))) = {1, 1};<br>
+}<br>
+<br>
+template <int I><br>
+struct HasASTemplateFields {<br>
+  __attribute__((address_space(I))) int as_field; // expected-error {{field may not be qualified with an address space}}<br>
+};<br>
+<br>
+template <int I, int J><br>
+void foo(__attribute__((address_space(I))) float *a, // expected-note {{candidate template ignored: substitution failure [with I = 1, J = 2]: parameter may not be qualified with an address space}}<br>
+         __attribute__((address_space(J))) float b) {<br>
+  *a = 5.0f + b;<br>
+}<br>
+<br>
+template void foo<1, 2>(float *, float); // expected-error {{explicit instantiation of 'foo' does not refer to a function template, variable template, member function, member class, or static data member}}<br>
+<br>
+template <int I><br>
+void neg() {<br>
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is negative}}<br>
+}<br>
+<br>
+template <long int I><br>
+void toBig() {<br>
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388599)}}<br>
+}<br>
+<br>
+template <long int I><br>
+void correct() {<br>
+  __attribute__((address_space(I))) int *bounds;<br>
+}<br>
+<br>
+template <int I, int J><br>
+char *cmp(__attribute__((address_space(I))) char *x, __attribute__((address_space(J))) char *y) {<br>
+  return x < y ? x : y; // expected-error {{comparison of distinct pointer types ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *')}}<br>
+}<br>
+<br>
+typedef void ft(void);<br>
+<br>
+template <int I><br>
+struct fooFunction {<br>
+  __attribute__((address_space(I))) void **const base = 0;<br>
+<br>
+  void *get_0(void) {<br>
+    return base[0]; // expected-error {{cannot initialize return object of type 'void *' with an lvalue of type '__attribute__((address_space(1))) void *}}<br>
+  }<br>
+<br>
+  __attribute__((address_space(I))) ft qf; // expected-error {{function type may not be qualified with an address space}}<br>
+  __attribute__((address_space(I))) char *test3_val;<br>
+<br>
+  void test3(void) {<br>
+    extern void test3_helper(char *p); // expected-note {{passing argument to parameter 'p' here}}<br>
+    test3_helper(test3_val);           // expected-error {{cannot initialize a parameter of type 'char *' with an lvalue of type '__attribute__((address_space(1))) char *'}}<br>
+  }<br>
+};<br>
+<br>
+template <typename T, int N><br>
+int GetAddressSpaceValue(T __attribute__((address_space(N))) * p) {<br>
+  return N;<br>
+}<br>
+<br>
+template <unsigned A> int __attribute__((address_space(A))) *same_template();<br>
+template <unsigned B> int __attribute__((address_space(B))) *same_template();<br>
+void test_same_template() { (void) same_template<0>(); }<br>
+<br>
+template <unsigned A> int __attribute__((address_space(A))) *different_template(); // expected-note {{candidate function [with A = 0]}}<br>
+template <unsigned B> int __attribute__((address_space(B+1))) *different_template(); // expected-note {{candidate function [with B = 0]}}<br>
+void test_different_template() { (void) different_template<0>(); } // expected-error {{call to 'different_template' is ambiguous}}<br>
+<br>
+template <typename T> struct partial_spec_deduce_as;<br>
+template <typename T, unsigned AS><br>
+struct partial_spec_deduce_as <__attribute__((address_space(AS))) T *> {<br>
+   static const unsigned value = AS;<br>
+};<br>
+<br>
+int main() {<br>
+  int __attribute__((address_space(1))) * p1;<br>
+  int p = GetAddressSpaceValue(p1);<br>
+<br>
+  car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}<br>
+  HasASTemplateFields<1> HASTF;<br>
+  neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}<br>
+  correct<0x7FFFF7>();<br>
+  toBig<4294967500>(); // expected-note {{in instantiation of function template specialization 'toBig<4294967500>' requested here}}<br></blockquote><div><br></div><div>It exceeds if long is 32-bit.</div><div>Reproducible with %clang_cc1 -triple i686-unknown-unknown</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+  __attribute__((address_space(1))) char *x;<br>
+  __attribute__((address_space(2))) char *y;<br>
+  cmp<1, 2>(x, y); // expected-note {{in instantiation of function template specialization 'cmp<1, 2>' requested here}}<br>
+<br>
+  fooFunction<1> ff;<br>
+  ff.get_0(); // expected-note {{in instantiation of member function 'fooFunction<1>::get_0' requested here}}<br>
+  ff.qf();<br>
+  ff.test3(); // expected-note {{in instantiation of member function 'fooFunction<1>::test3' requested here}}<br>
+<br>
+  static_assert(partial_spec_deduce_as<int __attribute__((address_space(3))) *>::value == 3, "address space value has been incorrectly deduced");<br>
+<br>
+  return 0;<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>