1*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wunused-value %s 2*67e74705SXin Li 3*67e74705SXin Li void f() __attribute__((const)); 4*67e74705SXin Li 5*67e74705SXin Li namespace PR18571 { 6*67e74705SXin Li // Unevaluated contexts should not trigger unused result warnings. 7*67e74705SXin Li template <typename T> foo(T)8*67e74705SXin Liauto foo(T) -> decltype(f(), bool()) { // Should not warn. 9*67e74705SXin Li return true; 10*67e74705SXin Li } 11*67e74705SXin Li g()12*67e74705SXin Livoid g() { 13*67e74705SXin Li foo(1); 14*67e74705SXin Li } 15*67e74705SXin Li h()16*67e74705SXin Livoid h() { 17*67e74705SXin Li int i = 0; 18*67e74705SXin Li (void)noexcept(++i); // expected-warning {{expression with side effects has no effect in an unevaluated context}} 19*67e74705SXin Li decltype(i++) j = 0; // expected-warning {{expression with side effects has no effect in an unevaluated context}} 20*67e74705SXin Li } 21*67e74705SXin Li 22*67e74705SXin Li struct S { 23*67e74705SXin Li S operator++(int); 24*67e74705SXin Li S(int i); 25*67e74705SXin Li S(); 26*67e74705SXin Li 27*67e74705SXin Li int& f(); 28*67e74705SXin Li S g(); 29*67e74705SXin Li }; 30*67e74705SXin Li j()31*67e74705SXin Livoid j() { 32*67e74705SXin Li S s; 33*67e74705SXin Li int i = 0; 34*67e74705SXin Li (void)noexcept(s++); // Ok 35*67e74705SXin Li (void)noexcept(i++); // expected-warning {{expression with side effects has no effect in an unevaluated context}} 36*67e74705SXin Li (void)noexcept(i = 5); // expected-warning {{expression with side effects has no effect in an unevaluated context}} 37*67e74705SXin Li (void)noexcept(s = 5); // Ok 38*67e74705SXin Li 39*67e74705SXin Li (void)sizeof(s.f()); // Ok 40*67e74705SXin Li (void)sizeof(s.f() = 5); // expected-warning {{expression with side effects has no effect in an unevaluated context}} 41*67e74705SXin Li (void)noexcept(s.g() = 5); // Ok 42*67e74705SXin Li } 43*67e74705SXin Li 44*67e74705SXin Li }