On Sat, Jul 6, 2013 at 11:36 PM, Stephen Lin <[email protected]> wrote:
> Which stack overflow question? :)

http://stackoverflow.com/questions/12040891/auto-and-decltype-in-for-loop-initialization

> On Sat, Jul 6, 2013 at 11:15 PM, Richard Smith
> <[email protected]> wrote:
>> Author: rsmith
>> Date: Sun Jul  7 01:15:42 2013
>> New Revision: 185772
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=185772&view=rev
>> Log:
>> Rename test to match C++1y paragraph number per N3690, and add additional 
>> test
>> case inspired by a stackoverflow question.
>>
>> Added:
>>     cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp
>>       - copied, changed from r185271, 
>> cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp
>> Removed:
>>     cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp
>> Modified:
>>     cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp
>>
>> Removed: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp?rev=185771&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp 
>> (original)
>> +++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp 
>> (removed)
>> @@ -1,97 +0,0 @@
>> -// RUN: %clang_cc1 -verify -std=c++1y %s
>> -
>> -namespace std {
>> -  template<typename T> struct initializer_list {
>> -    const T *p;
>> -    unsigned long n;
>> -    initializer_list(const T *p, unsigned long n);
>> -  };
>> -}
>> -
>> -// FIXME: This may not be p6 in C++1y; N3638 isn't very clear whether 
>> paragraphs
>> -// were added. It might be p8?
>> -
>> -int i;
>> -int &&f();
>> -
>> -using Int = int;
>> -using IntLRef = int&;
>> -using IntRRef = int&&;
>> -using InitListInt = std::initializer_list<int>;
>> -using IntPtr = int*;
>> -
>> -auto x3a = i;
>> -decltype(auto) x3d = i;
>> -using Int = decltype(x3a);
>> -using Int = decltype(x3d);
>> -
>> -auto x4a = (i);
>> -decltype(auto) x4d = (i);
>> -using Int = decltype(x4a);
>> -using IntLRef = decltype(x4d);
>> -
>> -auto x5a = f();
>> -decltype(auto) x5d = f();
>> -using Int = decltype(x5a);
>> -using IntRRef = decltype(x5d);
>> -
>> -auto x6a = { 1, 2 };
>> -decltype(auto) x6d = { 1, 2 }; // expected-error {{cannot deduce 
>> 'decltype(auto)' from initializer list}}
>> -using InitListInt = decltype(x6a);
>> -
>> -auto *x7a = &i;
>> -decltype(auto) *x7d = &i; // expected-error {{cannot form pointer to 
>> 'decltype(auto)'}}
>> -using IntPtr = decltype(x7a);
>> -
>> -struct S {};
>> -
>> -decltype(auto) f1();
>> -decltype(auto) (*f2)(); // expected-error {{'decltype(auto)' can only be 
>> used as a return type in a function declaration}} expected-error {{requires 
>> an initializer}}
>> -decltype(auto) *f3(); // expected-error {{cannot form pointer to 
>> 'decltype(auto)'}}
>> -const decltype(auto) f4(); // expected-error {{'decltype(auto)' cannot be 
>> combined with other type specifiers}}
>> -typedef decltype(auto) f5(); // expected-error {{'decltype(auto)' can only 
>> be used as a return type in a function declaration}}
>> -decltype(auto) ((((((f6))))())); // ok
>> -decltype(auto) f7()(); // expected-error {{'decltype(auto)' can only be 
>> used as a return type in a function declaration}} expected-error {{function 
>> cannot return function type}}
>> -decltype(auto) (S::*f8)(); // expected-error {{'decltype(auto)' can only be 
>> used as a return type in a function declaration}} expected-error {{requires 
>> an initializer}}
>> -decltype(auto) &f9(); // expected-error {{cannot form reference to 
>> 'decltype(auto)'}}
>> -decltype(auto) (&f10())[10]; // expected-error {{cannot form array of 
>> 'decltype(auto)'}}
>> -
>> -decltype(auto) ((((((v1)))))) = 0; // ok
>> -decltype(auto) v2[1] = { 0 }; // expected-error {{cannot form array of 
>> 'decltype(auto)'}}
>> -decltype(auto) &v3 = { 0 }; // expected-error {{cannot form reference to 
>> 'decltype(auto)'}}
>> -decltype(auto) *v4 = { 0 }; // expected-error {{cannot form pointer to 
>> 'decltype(auto)'}}
>> -
>> -auto multi1a = 0, &multi1b = multi1a;
>> -auto multi1c = multi1a, multi1d = multi1b;
>> -decltype(auto) multi1e = multi1a, multi1f = multi1b; // expected-error 
>> {{'decltype(auto)' deduced as 'int' in declaration of 'multi1e' and deduced 
>> as 'int &' in declaration of 'multi1f'}}
>> -
>> -auto f1a() { return 0; }
>> -decltype(auto) f1d() { return 0; }
>> -using Int = decltype(f1a());
>> -using Int = decltype(f1d());
>> -
>> -auto f2a(int n) { return n; }
>> -decltype(auto) f2d(int n) { return n; }
>> -using Int = decltype(f2a(0));
>> -using Int = decltype(f2d(0));
>> -
>> -auto f3a(int n) { return (n); }
>> -decltype(auto) f3d(int n) { return (n); } // expected-warning {{reference 
>> to stack memory}}
>> -using Int = decltype(f3a(0));
>> -using IntLRef = decltype(f3d(0));
>> -
>> -auto f4a(int n) { return f(); }
>> -decltype(auto) f4d(int n) { return f(); }
>> -using Int = decltype(f4a(0));
>> -using IntRRef = decltype(f4d(0));
>> -
>> -auto f5aa(int n) { auto x = f(); return x; }
>> -auto f5ad(int n) { decltype(auto) x = f(); return x; }
>> -decltype(auto) f5da(int n) { auto x = f(); return x; }
>> -decltype(auto) f5dd(int n) { decltype(auto) x = f(); return x; } // 
>> expected-error {{rvalue reference to type 'int' cannot bind to lvalue}}
>> -using Int = decltype(f5aa(0));
>> -using Int = decltype(f5ad(0));
>> -using Int = decltype(f5da(0));
>> -
>> -auto init_list_1() { return { 1, 2, 3 }; } // expected-error {{cannot 
>> deduce return type from initializer list}}
>> -decltype(auto) init_list_2() { return { 1, 2, 3 }; } // expected-error 
>> {{cannot deduce return type from initializer list}}
>>
>> Copied: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp 
>> (from r185271, 
>> cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp)
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp?p2=cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp&p1=cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp&r1=185271&r2=185772&rev=185772&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6-1y.cpp 
>> (original)
>> +++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp Sun 
>> Jul  7 01:15:42 2013
>> @@ -8,9 +8,6 @@ namespace std {
>>    };
>>  }
>>
>> -// FIXME: This may not be p6 in C++1y; N3638 isn't very clear whether 
>> paragraphs
>> -// were added. It might be p8?
>> -
>>  int i;
>>  int &&f();
>>
>>
>> Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp?rev=185772&r1=185771&r2=185772&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp 
>> (original)
>> +++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp Sun 
>> Jul  7 01:15:42 2013
>> @@ -29,4 +29,17 @@ void g() {
>>         (*e)() -> void,
>>  #endif
>>         f = 0.0;
>> +
>> +#if __has_feature(cxx_decltype)
>> +  auto g = 0ull, h = decltype(g)(0);
>> +#endif
>> +}
>> +
>> +template<typename T> void h() {
>> +  auto a = T(), *b = &a;
>> +#if __has_feature(cxx_decltype)
>> +  auto c = T(), d = decltype(c)(0);
>> +#endif
>>  }
>> +template void h<int>();
>> +template void h<unsigned long>();
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> [email protected]
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to