xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/conditional-expr-lvalue.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm-only %s
f(bool flag)2*f4a2713aSLionel Sambuc void f(bool flag) {
3*f4a2713aSLionel Sambuc   int a = 1;
4*f4a2713aSLionel Sambuc   int b = 2;
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc   (flag ? a : b) = 3;
7*f4a2713aSLionel Sambuc }
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc // PR10756
10*f4a2713aSLionel Sambuc namespace test0 {
11*f4a2713aSLionel Sambuc   struct A {
12*f4a2713aSLionel Sambuc     A(const A &);
13*f4a2713aSLionel Sambuc     A &operator=(const A &);
14*f4a2713aSLionel Sambuc     A sub() const;
15*f4a2713aSLionel Sambuc     void foo() const;
16*f4a2713aSLionel Sambuc   };
foo(bool cond,const A & a)17*f4a2713aSLionel Sambuc   void foo(bool cond, const A &a) {
18*f4a2713aSLionel Sambuc     (cond ? a : a.sub()).foo();
19*f4a2713aSLionel Sambuc   }
20*f4a2713aSLionel Sambuc }
21