expression-traits.cpp revision 651f13cea278ec967336033dd032faef0e9fc2ec
1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions %s 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// Tests for "expression traits" intrinsics such as __is_lvalue_expr. 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// For the time being, these tests are written against the 2003 C++ 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// standard (ISO/IEC 14882:2003 -- see draft at 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2001/n1316/). 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// C++0x has its own, more-refined, idea of lvalues and rvalues. 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// If/when we need to support those, we'll need to track both 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// standard documents. 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#if !__has_feature(cxx_static_assert) 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org# define CONCAT_(X_, Y_) CONCAT1_(X_, Y_) 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org# define CONCAT1_(X_, Y_) X_ ## Y_ 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// This emulation can be used multiple times on one line (and thus in 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// a macro), except at class scope 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org# define static_assert(b_, m_) \ 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org typedef int CONCAT_(sa_, __LINE__)[b_ ? 1 : -1] 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// Tests are broken down according to section of the C++03 standard 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// (ISO/IEC 14882:2003(E)) 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// Assertion macros encoding the following two paragraphs 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// basic.lval/1 Every expression is either an lvalue or an rvalue. 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// expr.prim/5 A parenthesized expression is a primary expression whose type 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// and value are identical to those of the enclosed expression. The 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// presence of parentheses does not affect whether the expression is 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// an lvalue. 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// Note: these asserts cannot be made at class scope in C++03. Put 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// them in a member function instead. 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define ASSERT_LVALUE(expr) \ 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(__is_lvalue_expr(expr), "should be an lvalue"); \ 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(__is_lvalue_expr((expr)), \ 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "the presence of parentheses should have" \ 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org " no effect on lvalueness (expr.prim/5)"); \ 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(!__is_rvalue_expr(expr), "should be an lvalue"); \ 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(!__is_rvalue_expr((expr)), \ 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "the presence of parentheses should have" \ 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org " no effect on lvalueness (expr.prim/5)") 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define ASSERT_RVALUE(expr); \ 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(__is_rvalue_expr(expr), "should be an rvalue"); \ 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(__is_rvalue_expr((expr)), \ 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "the presence of parentheses should have" \ 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org " no effect on lvalueness (expr.prim/5)"); \ 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(!__is_lvalue_expr(expr), "should be an rvalue"); \ 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(!__is_lvalue_expr((expr)), \ 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "the presence of parentheses should have" \ 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org " no effect on lvalueness (expr.prim/5)") 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgenum Enum { Enumerator }; 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgint ReturnInt(); 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid ReturnVoid(); 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgEnum ReturnEnum(); 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid basic_lval_5() 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // basic.lval/5: The result of calling a function that does not return 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // a reference is an rvalue. 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(ReturnInt()); 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(ReturnVoid()); 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(ReturnEnum()); 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgint& ReturnIntReference(); 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern Enum& ReturnEnumReference(); 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid basic_lval_6() 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // basic.lval/6: An expression which holds a temporary object resulting 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // from a cast to a nonreference type is an rvalue (this includes 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // the explicit creation of an object using functional notation 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct IntClass 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org { 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org explicit IntClass(int = 0); 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org IntClass(char const*); 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org operator int() const; 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org }; 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct ConvertibleToIntClass 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org { 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org operator IntClass() const; 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org }; 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ConvertibleToIntClass b; 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // Make sure even trivial conversions are not detected as lvalues 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int intLvalue = 0; 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE((int)intLvalue); 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE((short)intLvalue); 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE((long)intLvalue); 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // Same tests with function-call notation 102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(int(intLvalue)); 103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(short(intLvalue)); 104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(long(intLvalue)); 105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org char charLValue = 'x'; 107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE((signed char)charLValue); 108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE((unsigned char)charLValue); 109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(static_cast<int>(IntClass())); 111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org IntClass intClassLValue; 112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(static_cast<int>(intClassLValue)); 113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(static_cast<IntClass>(ConvertibleToIntClass())); 114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ConvertibleToIntClass convertibleToIntClassLValue; 115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(static_cast<IntClass>(convertibleToIntClassLValue)); 116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org typedef signed char signed_char; 119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org typedef unsigned char unsigned_char; 120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(signed_char(charLValue)); 121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(unsigned_char(charLValue)); 122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(int(IntClass())); 124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(int(intClassLValue)); 125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(IntClass(ConvertibleToIntClass())); 126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(IntClass(convertibleToIntClassLValue)); 127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid conv_ptr_1() 130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // conv.ptr/1: A null pointer constant is an integral constant 132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expression (5.19) rvalue of integer type that evaluates to 133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // zero. 134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(0); 135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_6() 138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr/6: If an expression initially has the type "reference to T" 140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // (8.3.2, 8.5.3), ... the expression is an lvalue. 141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int x = 0; 142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int& referenceToInt = x; 143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(referenceToInt); 144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(ReturnIntReference()); 145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_prim_2() 148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // 5.1/2 A string literal is an lvalue; all other 150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // literals are rvalues. 151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE("foo"); 152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(1); 153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(1.2); 154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(10UL); 155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_prim_3() 158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // 5.1/3: The keyword "this" names a pointer to the object for 160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // which a nonstatic member function (9.3.2) is invoked. ...The 161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expression is an rvalue. 162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct ThisTest 163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org { 164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void f() { ASSERT_RVALUE(this); } 165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org }; 166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern int variable; 169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid Function(); 170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct BaseClass 172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual ~BaseClass(); 174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int BaseNonstaticMemberFunction(); 176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static int BaseStaticMemberFunction(); 177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int baseDataMember; 178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct Class : BaseClass 181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static void function(); 183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static int variable; 184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org template <class T> 186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct NestedClassTemplate {}; 187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org template <class T> 189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static int& NestedFuncTemplate() { return variable; } // expected-note{{possible target for call}} 190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org template <class T> 192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int& NestedMemfunTemplate() { return variable; } // expected-note{{possible target for call}} 193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int operator*() const; 195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org template <class T> 197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int operator+(T) const; // expected-note{{possible target for call}} 198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int NonstaticMemberFunction(); 200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static int StaticMemberFunction(); 201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int dataMember; 202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int& referenceDataMember; 204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static int& staticReferenceDataMember; 205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static int staticNonreferenceDataMember; 206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org enum Enum { Enumerator }; 208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org operator long() const; 210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Class(); 212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Class(int,int); 213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void expr_prim_4() 215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org { 216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // 5.1/4: The operator :: followed by an identifier, a 217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // qualified-id, or an operator-function-id is a primary- 218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expression. ...The result is an lvalue if the entity is 219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // a function or variable. 220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(::Function); // identifier: function 221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(::variable); // identifier: variable 222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // the only qualified-id form that can start without "::" (and thus 224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // be legal after "::" ) is 225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // 226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // ::<sub>opt</sub> nested-name-specifier template<sub>opt</sub> unqualified-id 227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(::Class::function); // qualified-id: function 228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(::Class::variable); // qualified-id: variable 229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The standard doesn't give a clear answer about whether these 231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // should really be lvalues or rvalues without some surrounding 232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // context that forces them to be interpreted as naming a 233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // particular function template specialization (that situation 234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // doesn't come up in legal pure C++ programs). This language 235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // extension simply rejects them as requiring additional context 236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org __is_lvalue_expr(::Class::NestedFuncTemplate); // qualified-id: template \ 237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}} 238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org __is_lvalue_expr(::Class::NestedMemfunTemplate); // qualified-id: template \ 240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expected-error{{reference to non-static member function must be called}} 241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org __is_lvalue_expr(::Class::operator+); // operator-function-id: template \ 243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expected-error{{reference to non-static member function must be called}} 244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org //ASSERT_RVALUE(::Class::operator*); // operator-function-id: member function 246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void expr_prim_7() 249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org { 250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.prim/7 An identifier is an id-expression provided it has been 251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // suitably declared (clause 7). [Note: ... ] The type of the 252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expression is the type of the identifier. The result is the 253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // entity denoted by the identifier. The result is an lvalue if 254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // the entity is a function, variable, or data member... (cont'd) 255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Function); // identifier: function 256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(StaticMemberFunction); // identifier: function 257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(variable); // identifier: variable 258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(dataMember); // identifier: data member 259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org //ASSERT_RVALUE(NonstaticMemberFunction); // identifier: member function 260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // (cont'd)...A nested-name-specifier that names a class, 262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // optionally followed by the keyword template (14.2), and then 263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // followed by the name of a member of either that class (9.2) or 264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // one of its base classes... is a qualified-id... The result is 265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // the member. The type of the result is the type of the 266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // member. The result is an lvalue if the member is a static 267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // member function or a data member. 268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Class::dataMember); 269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Class::StaticMemberFunction); 270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org //ASSERT_RVALUE(Class::NonstaticMemberFunction); // identifier: member function 271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Class::baseDataMember); 273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Class::BaseStaticMemberFunction); 274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org //ASSERT_RVALUE(Class::BaseNonstaticMemberFunction); // identifier: member function 275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_call_10() 279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.call/10: A function call is an lvalue if and only if the 281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // result type is a reference. This statement is partially 282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // redundant with basic.lval/5 283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org basic_lval_5(); 284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(ReturnIntReference()); 286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(ReturnEnumReference()); 287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnamespace Namespace 290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int x; 292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void function(); 293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_prim_8() 296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.prim/8 A nested-name-specifier that names a namespace 298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // (7.3), followed by the name of a member of that namespace (or 299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // the name of a member of a namespace made visible by a 300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // using-directive ) is a qualified-id; 3.4.3.2 describes name 301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // lookup for namespace members that appear in qualified-ids. The 302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // result is the member. The type of the result is the type of the 303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // member. The result is an lvalue if the member is a function or 304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // a variable. 305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Namespace::x); 306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Namespace::function); 307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_sub_1(int* pointer) 310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.sub/1 A postfix expression followed by an expression in 312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // square brackets is a postfix expression. One of the expressions 313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // shall have the type "pointer to T" and the other shall have 314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // enumeration or integral type. The result is an lvalue of type 315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // "T." 316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(pointer[1]); 317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The expression E1[E2] is identical (by definition) to *((E1)+(E2)). 319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(*(pointer+1)); 320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_type_conv_1() 323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.type.conv/1 A simple-type-specifier (7.1.5) followed by a 325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // parenthesized expression-list constructs a value of the specified 326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // type given the expression list. ... If the expression list 327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // specifies more than a single value, the type shall be a class with 328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // a suitably declared constructor (8.5, 12.1), and the expression 329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // T(x1, x2, ...) is equivalent in effect to the declaration T t(x1, 330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // x2, ...); for some invented temporary variable t, with the result 331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // being the value of t as an rvalue. 332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(Class(2,2)); 333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_type_conv_2() 336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.type.conv/2 The expression T(), where T is a 338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // simple-type-specifier (7.1.5.2) for a non-array complete object 339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // type or the (possibly cv-qualified) void type, creates an 340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // rvalue of the specified type, 341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(int()); 342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(Class()); 343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(void()); 344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_ref_4() 348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // Applies to expressions of the form E1.E2 350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // If E2 is declared to have type "reference to T", then E1.E2 is 352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // an lvalue;.... Otherwise, one of the following rules applies. 353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Class().staticReferenceDataMember); 354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Class().referenceDataMember); 355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // - If E2 is a static data member, and the type of E2 is T, then 357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // E1.E2 is an lvalue; ... 358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Class().staticNonreferenceDataMember); 359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Class().staticReferenceDataMember); 360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // - If E2 is a non-static data member, ... If E1 is an lvalue, 363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // then E1.E2 is an lvalue... 364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Class lvalue; 365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(lvalue.dataMember); 366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(Class().dataMember); 367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // - If E1.E2 refers to a static member function, ... then E1.E2 369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // is an lvalue 370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(Class().StaticMemberFunction); 371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // - Otherwise, if E1.E2 refers to a non-static member function, 373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // then E1.E2 is not an lvalue. 374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org //ASSERT_RVALUE(Class().NonstaticMemberFunction); 375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // - If E2 is a member enumerator, and the type of E2 is T, the 377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expression E1.E2 is not an lvalue. The type of E1.E2 is T. 378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(Class().Enumerator); 379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(lvalue.Enumerator); 380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_post_incr_1(int x) 384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.post.incr/1 The value obtained by applying a postfix ++ is 386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // the value that the operand had before applying the 387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // operator... The result is an rvalue. 388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(x++); 389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_dynamic_cast_2() 392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.dynamic.cast/2: If T is a pointer type, v shall be an 394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // rvalue of a pointer to complete class type, and the result is 395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // an rvalue of type T. 396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Class instance; 397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(dynamic_cast<Class*>(&instance)); 398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // If T is a reference type, v shall be an 400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // lvalue of a complete class type, and the result is an lvalue of 401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // the type referred to by T. 402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(dynamic_cast<Class&>(instance)); 403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_dynamic_cast_5() 406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.dynamic.cast/5: If T is "reference to cv1 B" and v has type 408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // "cv2 D" such that B is a base class of D, the result is an 409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // lvalue for the unique B sub-object of the D object referred 410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // to by v. 411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org typedef BaseClass B; 412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org typedef Class D; 413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org D object; 414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(dynamic_cast<B&>(object)); 415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// expr.dynamic.cast/8: The run-time check logically executes as follows: 418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// - If, in the most derived object pointed (referred) to by v, v 420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// points (refers) to a public base class subobject of a T object, and 421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// if only one object of type T is derived from the sub-object pointed 422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// (referred) to by v, the result is a pointer (an lvalue referring) 423f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// to that T object. 424f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 425f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// - Otherwise, if v points (refers) to a public base class sub-object 426f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// of the most derived object, and the type of the most derived object 427f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// has a base class, of type T, that is unambiguous and public, the 428f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// result is a pointer (an lvalue referring) to the T sub-object of 429f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// the most derived object. 430f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 431f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// The mention of "lvalue" in the text above appears to be a 432f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// defect that is being corrected by the response to UK65 (see 433f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2841.html). 434f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 435f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#if 0 436f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_typeid_1() 437f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 438f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.typeid/1: The result of a typeid expression is an lvalue... 439f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(typeid(1)); 440f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 441f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif 442f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 443f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_static_cast_1(int x) 444f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 445f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.static.cast/1: The result of the expression 446f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // static_cast<T>(v) is the result of converting the expression v 447f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // to type T. If T is a reference type, the result is an lvalue; 448f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // otherwise, the result is an rvalue. 449f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(static_cast<int&>(x)); 450f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(static_cast<int>(x)); 451f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 452f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 453f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_reinterpret_cast_1() 454f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 455f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.reinterpret.cast/1: The result of the expression 456f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // reinterpret_cast<T>(v) is the result of converting the 457f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expression v to type T. If T is a reference type, the result is 458f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // an lvalue; otherwise, the result is an rvalue 459f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(reinterpret_cast<int*>(0)); 460f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org char const v = 0; 461f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(reinterpret_cast<char const&>(v)); 462f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 463f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 464f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_unary_op_1(int* pointer, struct incomplete* pointerToIncompleteType) 465f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 466f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.unary.op/1: The unary * operator performs indirection: the 467f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expression to which it is applied shall be a pointer to an 468f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // object type, or a pointer to a function type and the result is 469f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // an lvalue referring to the object or function to which the 470f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expression points. 471f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(*pointer); 472f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(*Function); 473f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 474f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // [Note: a pointer to an incomplete type 475f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // (other than cv void ) can be dereferenced. ] 476f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(*pointerToIncompleteType); 477f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 478f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 479f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_pre_incr_1(int operand) 480f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 481f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.pre.incr/1: The operand of prefix ++ ... shall be a 482f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // modifiable lvalue.... The value is the new value of the 483f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // operand; it is an lvalue. 484f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(++operand); 485f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 486f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 487f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_cast_1(int x) 488f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 489f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.cast/1: The result of the expression (T) cast-expression 490f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // is of type T. The result is an lvalue if T is a reference type, 491f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // otherwise the result is an rvalue. 492f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE((void(&)())expr_cast_1); 493f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE((int&)x); 494f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE((void(*)())expr_cast_1); 495f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE((int)x); 496f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 497f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 498f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_mptr_oper() 499f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 500f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.mptr.oper/6: The result of a .* expression is an lvalue 501f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // only if its first operand is an lvalue and its second operand 502f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // is a pointer to data member... (cont'd) 503f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org typedef Class MakeRValue; 504f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(MakeRValue().*(&Class::dataMember)); 505f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org //ASSERT_RVALUE(MakeRValue().*(&Class::NonstaticMemberFunction)); 506f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Class lvalue; 507f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(lvalue.*(&Class::dataMember)); 508f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org //ASSERT_RVALUE(lvalue.*(&Class::NonstaticMemberFunction)); 509f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 510f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // (cont'd)...The result of an ->* expression is an lvalue only 511f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // if its second operand is a pointer to data member. If the 512f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // second operand is the null pointer to member value (4.11), the 513f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // behavior is undefined. 514f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE((&lvalue)->*(&Class::dataMember)); 515f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org //ASSERT_RVALUE((&lvalue)->*(&Class::NonstaticMemberFunction)); 516f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 517f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 518f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_cond(bool cond) 519f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 520f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // 5.16 Conditional operator [expr.cond] 521f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // 522f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // 2 If either the second or the third operand has type (possibly 523f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // cv-qualified) void, one of the following shall hold: 524f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // 525f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // - The second or the third operand (but not both) is a 526f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // (possibly parenthesized) throw-expression (15.1); the result 527f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // is of the type and value category of the other. 528f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 529f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Class classLvalue; 530f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(cond ? throw 1 : (void)0); 531f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(cond ? (void)0 : throw 1); 532f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(cond ? throw 1 : 0); 533f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(cond ? 0 : throw 1); 534f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(cond ? throw 1 : classLvalue); 535f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(cond ? classLvalue : throw 1); 536f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 537f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // - Both the second and the third operands have type void; the result 538f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // is of type void and is an rvalue. [Note: this includes the case 539f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // where both operands are throw-expressions. ] 540f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(cond ? (void)1 : (void)0); 541f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(cond ? throw 1 : throw 0); 542f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 543f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.cond/4: If the second and third operands are lvalues and 544f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // have the same type, the result is of that type and is an 545f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // lvalue. 546f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(cond ? classLvalue : classLvalue); 547f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int intLvalue = 0; 548f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(cond ? intLvalue : intLvalue); 549f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 550f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.cond/5:Otherwise, the result is an rvalue. 551f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org typedef Class MakeRValue; 552f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(cond ? MakeRValue() : classLvalue); 553f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(cond ? classLvalue : MakeRValue()); 554f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(cond ? MakeRValue() : MakeRValue()); 555f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(cond ? classLvalue : intLvalue); 556f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(cond ? intLvalue : int()); 557f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 558f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 559f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_ass_1(int x) 560f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 561f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.ass/1: There are several assignment operators, all of 562f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // which group right-to-left. All require a modifiable lvalue as 563f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // their left operand, and the type of an assignment expression is 564f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // that of its left operand. The result of the assignment 565f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // operation is the value stored in the left operand after the 566f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // assignment has taken place; the result is an lvalue. 567f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(x = 1); 568f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(x += 1); 569f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(x -= 1); 570f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(x *= 1); 571f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(x /= 1); 572f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(x %= 1); 573f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(x ^= 1); 574f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(x &= 1); 575f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(x |= 1); 576f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 577f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 578f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_comma(int x) 579f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 580f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // expr.comma: A pair of expressions separated by a comma is 581f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // evaluated left-to-right and the value of the left expression is 582f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // discarded... result is an lvalue if its right operand is. 583f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 584f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // Can't use the ASSERT_XXXX macros without adding parens around 585f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // the comma expression. 586f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(__is_lvalue_expr(x,x), "expected an lvalue"); 587f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(__is_rvalue_expr(x,1), "expected an rvalue"); 588f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(__is_lvalue_expr(1,x), "expected an lvalue"); 589f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static_assert(__is_rvalue_expr(1,1), "expected an rvalue"); 590f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 591f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 592f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#if 0 593f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtemplate<typename T> void f(); 594f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 595f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// FIXME These currently fail 596f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_fun_lvalue() 597f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 598f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(&f<int>); 599f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 600f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 601f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid expr_fun_rvalue() 602f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 603f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(f<int>); 604f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 605f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif 606f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 607f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtemplate <int NonTypeNonReferenceParameter, int& NonTypeReferenceParameter> 608f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid check_temp_param_6() 609f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 610f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_RVALUE(NonTypeNonReferenceParameter); 611f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ASSERT_LVALUE(NonTypeReferenceParameter); 612f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 613f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 614f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgint AnInt = 0; 615f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 616f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid temp_param_6() 617f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 618f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org check_temp_param_6<3,AnInt>(); 619f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 620f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org