From: Richard Smith Date: Fri, 8 Nov 2013 02:05:54 +0000 (+0000) Subject: Tests for core issue 170-200. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9a5b3871f3d58fa226910fd8123c98fc8bc6c67;p=clang Tests for core issue 170-200. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194240 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CXX/drs/dr1xx.cpp b/test/CXX/drs/dr1xx.cpp index e06034b8d9..7ad39084a7 100644 --- a/test/CXX/drs/dr1xx.cpp +++ b/test/CXX/drs/dr1xx.cpp @@ -724,3 +724,288 @@ namespace dr169 { // dr169: yes using B::n; // expected-error {{using declaration can not refer to a template specialization}} }; } + +namespace { // dr171: yes + int dr171a; +} +int dr171b; // expected-note {{here}} +namespace dr171 { + extern "C" void dr171a(); + extern "C" void dr171b(); // expected-error {{conflicts}} +} + +namespace dr172 { // dr172: yes + enum { zero }; + int check1[-1 < zero ? 1 : -1]; + + enum { x = -1, y = (unsigned int)-1 }; + int check2[sizeof(x) > sizeof(int) ? 1 : -1]; + + enum { a = (unsigned int)-1 / 2 }; + int check3a[sizeof(a) == sizeof(int) ? 1 : -1]; + int check3b[-a < 0 ? 1 : -1]; + + enum { b = (unsigned int)-1 / 2 + 1 }; + int check4a[sizeof(b) == sizeof(unsigned int) ? 1 : -1]; + int check4b[-b > 0 ? 1 : -1]; + + enum { c = (unsigned long)-1 / 2 }; + int check5a[sizeof(c) == sizeof(long) ? 1 : -1]; + int check5b[-c < 0 ? 1 : -1]; + + enum { d = (unsigned long)-1 / 2 + 1 }; + int check6a[sizeof(d) == sizeof(unsigned long) ? 1 : -1]; + int check6b[-d > 0 ? 1 : -1]; + + enum { e = (unsigned long long)-1 / 2 }; // expected-error 0-1{{extension}} + int check7a[sizeof(e) == sizeof(long) ? 1 : -1]; // expected-error 0-1{{extension}} + int check7b[-e < 0 ? 1 : -1]; + + enum { f = (unsigned long long)-1 / 2 + 1 }; // expected-error 0-1{{extension}} + int check8a[sizeof(f) == sizeof(unsigned long) ? 1 : -1]; // expected-error 0-1{{extension}} + int check8b[-f > 0 ? 1 : -1]; +} + +namespace dr173 { // dr173: yes + int check[('0' + 1 == '1' && '0' + 2 == '2' && '0' + 3 == '3' && + '0' + 4 == '4' && '0' + 5 == '5' && '0' + 6 == '6' && + '0' + 7 == '7' && '0' + 8 == '8' && '0' + 9 == '9') ? 1 : -1]; +} + +// dr174: sup 1012 + +namespace dr175 { // dr175: yes + struct A {}; // expected-note {{here}} + struct B : private A {}; // expected-note {{constrained by private inheritance}} + struct C : B { + A a; // expected-error {{private}} + dr175::A b; + }; +} + +namespace dr176 { // dr176: yes + template class Y; + template<> class Y { + void f() { + typedef Y A; // expected-note {{here}} + typedef Y A; // expected-error {{different types ('Y' vs 'Y')}} + } + }; + + template struct Base {}; // expected-note 2{{found}} + template struct Derived : public Base { + void f() { + typedef typename Derived::template Base A; + typedef typename Derived::Base A; + } + }; + template struct Derived; + + template struct Derived2 : Base, Base { + typename Derived2::Base b; // expected-error {{found in multiple base classes}} + typename Derived2::Base d; + }; + + template class X { // expected-note {{here}} + X *p1; + X *p2; + X *p3; + dr176::X *p4; // expected-error {{requires template arguments}} + }; +} + +namespace dr177 { // dr177: yes + struct B {}; + struct A { + A(A &); // expected-note {{not viable: expects an l-value}} + A(const B &); + }; + B b; + A a = b; // expected-error {{no viable constructor copying variable}} +} + +namespace dr178 { // dr178: yes + int check[int() == 0 ? 1 : -1]; +#if __cplusplus >= 201103L + static_assert(int{} == 0, ""); + struct S { int a, b; }; + static_assert(S{1}.b == 0, ""); + struct T { constexpr T() : n() {} int n; }; + static_assert(T().n == 0, ""); + struct U : S { constexpr U() : S() {} }; + static_assert(U().b == 0, ""); +#endif +} + +namespace dr179 { // dr179: yes + void f(); + int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} +} + +namespace dr180 { // dr180: yes + template struct X : T, T::some_base { + X() : T::some_type_that_might_be_T(), T::some_base() {} + friend class T::some_class; + void f() { + enum T::some_enum e; + } + }; +} + +namespace dr181 { // dr181: yes + namespace X { + template