1 // RUN: %clang_cc1 -std=c++11 -fsanitize=signed-integer-overflow,integer-divide-by-zero,float-divide-by-zero,shift,unreachable,return,vla-bound,alignment,null,vptr,object-size,float-cast-overflow,bool,enum,array-bounds,function -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
2 // RUN: %clang_cc1 -std=c++11 -fsanitize=vptr,address -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-ASAN
3 // RUN: %clang_cc1 -std=c++11 -fsanitize=vptr -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=DOWNCAST-NULL
4 
5 struct S {
6   double d;
7   int a, b;
8   virtual int f();
9 };
10 
11 // Check that type descriptor global is not modified by ASan.
12 // CHECK-ASAN: [[TYPE_DESCR:@[0-9]+]] = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'S'\00" }
13 
14 // Check that type mismatch handler is not modified by ASan.
15 // CHECK-ASAN: private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }*, i8*, i8 } { {{.*}}, { i16, i16, [4 x i8] }* [[TYPE_DESCR]], {{.*}} }
16 
17 struct T : S {};
18 
19 // CHECK-LABEL: @_Z17reference_binding
20 void reference_binding(int *p, S *q) {
21   // C++ core issue 453: If an lvalue to which a reference is directly bound
22   // designates neither an existing object or function of an appropriate type,
23   // nor a region of storage of suitable size and alignment to contain an object
24   // of the reference's type, the behavior is undefined.
25 
26   // CHECK: icmp ne {{.*}}, null
27 
28   // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64
29   // CHECK-NEXT: icmp uge i64 %[[SIZE]], 4
30 
31   // CHECK: %[[PTRINT:.*]] = ptrtoint
32   // CHECK-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRINT]], 3
33   // CHECK-NEXT: icmp eq i64 %[[MISALIGN]], 0
34   int &r = *p;
35 
36   // A reference is not required to refer to an object within its lifetime.
37   // CHECK-NOT: __ubsan_handle_dynamic_type_cache_miss
38   S &r2 = *q;
39 }
40 
41 // CHECK-LABEL: @_Z13member_access
42 // CHECK-ASAN-LABEL: @_Z13member_access
43 void member_access(S *p) {
44   // (1a) Check 'p' is appropriately sized and aligned for member access.
45 
46   // CHECK: icmp ne {{.*}}, null
47 
48   // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64
49   // CHECK-NEXT: icmp uge i64 %[[SIZE]], 24
50 
51   // CHECK: %[[PTRINT:.*]] = ptrtoint
52   // CHECK-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRINT]], 7
53   // CHECK-NEXT: icmp eq i64 %[[MISALIGN]], 0
54 
55   // (1b) Check that 'p' actually points to an 'S'.
56 
57   // CHECK: %[[VPTRADDR:.*]] = bitcast {{.*}} to i64*
58   // CHECK-NEXT: %[[VPTR:.*]] = load i64* %[[VPTRADDR]]
59   //
60   // hash_16_bytes:
61   //
62   // If this number changes, it indicates that either the mangled name of ::S
63   // has changed, or that LLVM's hashing function has changed. The latter case
64   // is OK if the hashing function is still stable.
65   //
66   // The two hash values are for 64- and 32-bit Clang binaries, respectively.
67   // FIXME: We should produce a 64-bit value either way.
68   //
69   // CHECK-NEXT: xor i64 {{-4030275160588942838|2562089159}}, %[[VPTR]]
70   // CHECK-NEXT: mul i64 {{.*}}, -7070675565921424023
71   // CHECK-NEXT: lshr i64 {{.*}}, 47
72   // CHECK-NEXT: xor i64
73   // CHECK-NEXT: xor i64 %[[VPTR]]
74   // CHECK-NEXT: mul i64 {{.*}}, -7070675565921424023
75   // CHECK-NEXT: lshr i64 {{.*}}, 47
76   // CHECK-NEXT: xor i64
77   // CHECK-NEXT: %[[HASH:.*]] = mul i64 {{.*}}, -7070675565921424023
78   //
79   // Check the hash against the table:
80   //
81   // CHECK-NEXT: %[[IDX:.*]] = and i64 %{{.*}}, 127
82   // CHECK-NEXT: getelementptr inbounds [128 x i64]* @__ubsan_vptr_type_cache, i32 0, i64 %[[IDX]]
83   // CHECK-NEXT: %[[CACHEVAL:.*]] = load i64*
84   // CHECK-NEXT: icmp eq i64 %[[CACHEVAL]], %[[HASH]]
85   // CHECK-NEXT: br i1
86 
87   // CHECK: call void @__ubsan_handle_dynamic_type_cache_miss({{.*}}, i64 %{{.*}}, i64 %[[HASH]])
88   // CHECK-NOT: unreachable
89   // CHECK: {{.*}}:
90 
91   // (2) Check 'p->b' is appropriately sized and aligned for a load.
92 
93   // FIXME: Suppress this in the trivial case of a member access, because we
94   // know we've just checked the member access expression itself.
95 
96   // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64
97   // CHECK-NEXT: icmp uge i64 %[[SIZE]], 4
98 
99   // CHECK: %[[PTRINT:.*]] = ptrtoint
100   // CHECK-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRINT]], 3
101   // CHECK-NEXT: icmp eq i64 %[[MISALIGN]], 0
102   int k = p->b;
103 
104   // (3a) Check 'p' is appropriately sized and aligned for member function call.
105 
106   // CHECK: icmp ne {{.*}}, null
107 
108   // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64
109   // CHECK-NEXT: icmp uge i64 %[[SIZE]], 24
110 
111   // CHECK: %[[PTRINT:.*]] = ptrtoint
112   // CHECK-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRINT]], 7
113   // CHECK-NEXT: icmp eq i64 %[[MISALIGN]], 0
114 
115   // (3b) Check that 'p' actually points to an 'S'
116 
117   // CHECK: load i64*
118   // CHECK-NEXT: xor i64 {{-4030275160588942838|2562089159}},
119   // [...]
120   // CHECK: getelementptr inbounds [128 x i64]* @__ubsan_vptr_type_cache, i32 0, i64 %
121   // CHECK: br i1
122   // CHECK: call void @__ubsan_handle_dynamic_type_cache_miss({{.*}}, i64 %{{.*}}, i64 %{{.*}})
123   // CHECK-NOT: unreachable
124   // CHECK: {{.*}}:
125 
126   k = p->f();
127 }
128 
129 // CHECK-LABEL: @_Z12lsh_overflow
130 int lsh_overflow(int a, int b) {
131   // CHECK: %[[INBOUNDS:.*]] = icmp ule i32 %[[RHS:.*]], 31
132   // CHECK-NEXT: br i1 %[[INBOUNDS]]
133 
134   // CHECK: %[[SHIFTED_OUT_WIDTH:.*]] = sub nuw nsw i32 31, %[[RHS]]
135   // CHECK-NEXT: %[[SHIFTED_OUT:.*]] = lshr i32 %[[LHS:.*]], %[[SHIFTED_OUT_WIDTH]]
136 
137   // This is present for C++11 but not for C: C++ core issue 1457 allows a '1'
138   // to be shifted into the sign bit, but not out of it.
139   // CHECK-NEXT: %[[SHIFTED_OUT_NOT_SIGN:.*]] = lshr i32 %[[SHIFTED_OUT]], 1
140 
141   // CHECK-NEXT: %[[NO_OVERFLOW:.*]] = icmp eq i32 %[[SHIFTED_OUT_NOT_SIGN]], 0
142 
143   // CHECK: %[[VALID:.*]] = phi i1 [ %[[INBOUNDS]], {{.*}} ], [ %[[NO_OVERFLOW]], {{.*}} ]
144   // CHECK-NEXT: br i1 %[[VALID]]
145 
146   // CHECK: call void @__ubsan_handle_shift_out_of_bounds
147   // CHECK-NOT: call void @__ubsan_handle_shift_out_of_bounds
148 
149   // CHECK: %[[RET:.*]] = shl i32 %[[LHS]], %[[RHS]]
150   // CHECK-NEXT: ret i32 %[[RET]]
151   return a << b;
152 }
153 
154 // CHECK-LABEL: @_Z9no_return
155 int no_return() {
156   // CHECK:      call void @__ubsan_handle_missing_return(i8* bitcast ({{.*}}* @{{.*}} to i8*)) [[NR_NUW:#[0-9]+]]
157   // CHECK-NEXT: unreachable
158 }
159 
160 // CHECK-LABEL: @_Z9sour_bool
161 bool sour_bool(bool *p) {
162   // CHECK: %[[OK:.*]] = icmp ule i8 {{.*}}, 1
163   // CHECK: br i1 %[[OK]]
164   // CHECK: call void @__ubsan_handle_load_invalid_value(i8* bitcast ({{.*}}), i64 {{.*}})
165   return *p;
166 }
167 
168 enum E1 { e1a = 0, e1b = 127 } e1;
169 enum E2 { e2a = -1, e2b = 64 } e2;
170 enum E3 { e3a = (1u << 31) - 1 } e3;
171 
172 // CHECK-LABEL: @_Z14bad_enum_value
173 int bad_enum_value() {
174   // CHECK: %[[E1:.*]] = icmp ule i32 {{.*}}, 127
175   // CHECK: br i1 %[[E1]]
176   // CHECK: call void @__ubsan_handle_load_invalid_value(
177   int a = e1;
178 
179   // CHECK: %[[E2HI:.*]] = icmp sle i32 {{.*}}, 127
180   // CHECK: %[[E2LO:.*]] = icmp sge i32 {{.*}}, -128
181   // CHECK: %[[E2:.*]] = and i1 %[[E2HI]], %[[E2LO]]
182   // CHECK: br i1 %[[E2]]
183   // CHECK: call void @__ubsan_handle_load_invalid_value(
184   int b = e2;
185 
186   // CHECK: %[[E3:.*]] = icmp ule i32 {{.*}}, 2147483647
187   // CHECK: br i1 %[[E3]]
188   // CHECK: call void @__ubsan_handle_load_invalid_value(
189   int c = e3;
190   return a + b + c;
191 }
192 
193 // CHECK-LABEL: @_Z20bad_downcast_pointer
194 // DOWNCAST-NULL-LABEL: @_Z20bad_downcast_pointer
195 void bad_downcast_pointer(S *p) {
196   // CHECK: %[[NONNULL:.*]] = icmp ne {{.*}}, null
197   // CHECK: br i1 %[[NONNULL]],
198 
199   // A null poiner access is guarded without -fsanitize=null.
200   // DOWNCAST-NULL: %[[NONNULL:.*]] = icmp ne {{.*}}, null
201   // DOWNCAST-NULL: br i1 %[[NONNULL]],
202 
203   // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(
204   // CHECK: %[[E1:.*]] = icmp uge i64 %[[SIZE]], 24
205   // CHECK: %[[MISALIGN:.*]] = and i64 %{{.*}}, 7
206   // CHECK: %[[E2:.*]] = icmp eq i64 %[[MISALIGN]], 0
207   // CHECK: %[[E12:.*]] = and i1 %[[E1]], %[[E2]]
208   // CHECK: br i1 %[[E12]],
209 
210   // CHECK: call void @__ubsan_handle_type_mismatch
211   // CHECK: br label
212 
213   // CHECK: br i1 %{{.*}},
214 
215   // CHECK: call void @__ubsan_handle_dynamic_type_cache_miss
216   // CHECK: br label
217   (void) static_cast<T*>(p);
218 }
219 
220 // CHECK-LABEL: @_Z22bad_downcast_reference
221 void bad_downcast_reference(S &p) {
222   // CHECK: %[[E1:.*]] = icmp ne {{.*}}, null
223   // CHECK-NOT: br i1
224   // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(
225   // CHECK: %[[E2:.*]] = icmp uge i64 %[[SIZE]], 24
226   // CHECK: %[[E12:.*]] = and i1 %[[E1]], %[[E2]]
227   // CHECK: %[[MISALIGN:.*]] = and i64 %{{.*}}, 7
228   // CHECK: %[[E3:.*]] = icmp eq i64 %[[MISALIGN]], 0
229   // CHECK: %[[E123:.*]] = and i1 %[[E12]], %[[E3]]
230   // CHECK: br i1 %[[E123]],
231 
232   // CHECK: call void @__ubsan_handle_type_mismatch
233   // CHECK: br label
234 
235   // CHECK: br i1 %{{.*}},
236 
237   // CHECK: call void @__ubsan_handle_dynamic_type_cache_miss
238   // CHECK: br label
239   (void) static_cast<T&>(p);
240 }
241 
242 // CHECK-LABEL: @_Z11array_index
243 int array_index(const int (&a)[4], int n) {
244   // CHECK: %[[K1_OK:.*]] = icmp ult i64 %{{.*}}, 4
245   // CHECK: br i1 %[[K1_OK]]
246   // CHECK: call void @__ubsan_handle_out_of_bounds(
247   int k1 = a[n];
248 
249   // CHECK: %[[R1_OK:.*]] = icmp ule i64 %{{.*}}, 4
250   // CHECK: br i1 %[[R1_OK]]
251   // CHECK: call void @__ubsan_handle_out_of_bounds(
252   const int *r1 = &a[n];
253 
254   // CHECK: %[[K2_OK:.*]] = icmp ult i64 %{{.*}}, 8
255   // CHECK: br i1 %[[K2_OK]]
256   // CHECK: call void @__ubsan_handle_out_of_bounds(
257   int k2 = ((const int(&)[8])a)[n];
258 
259   // CHECK: %[[K3_OK:.*]] = icmp ult i64 %{{.*}}, 4
260   // CHECK: br i1 %[[K3_OK]]
261   // CHECK: call void @__ubsan_handle_out_of_bounds(
262   int k3 = n[a];
263 
264   return k1 + *r1 + k2;
265 }
266 
267 // CHECK-LABEL: @_Z17multi_array_index
268 int multi_array_index(int n, int m) {
269   int arr[4][6];
270 
271   // CHECK: %[[IDX2_OK:.*]] = icmp ult i64 %{{.*}}, 6
272   // CHECK: br i1 %[[IDX2_OK]]
273   // CHECK: call void @__ubsan_handle_out_of_bounds(
274 
275   // CHECK: %[[IDX1_OK:.*]] = icmp ult i64 %{{.*}}, 4
276   // CHECK: br i1 %[[IDX1_OK]]
277   // CHECK: call void @__ubsan_handle_out_of_bounds(
278   return arr[n][m];
279 }
280 
281 // CHECK-LABEL: @_Z11array_arith
282 int array_arith(const int (&a)[4], int n) {
283   // CHECK: %[[K1_OK:.*]] = icmp ule i64 %{{.*}}, 4
284   // CHECK: br i1 %[[K1_OK]]
285   // CHECK: call void @__ubsan_handle_out_of_bounds(
286   const int *k1 = a + n;
287 
288   // CHECK: %[[K2_OK:.*]] = icmp ule i64 %{{.*}}, 8
289   // CHECK: br i1 %[[K2_OK]]
290   // CHECK: call void @__ubsan_handle_out_of_bounds(
291   const int *k2 = (const int(&)[8])a + n;
292 
293   return *k1 + *k2;
294 }
295 
296 struct ArrayMembers {
297   int a1[5];
298   int a2[1];
299 };
300 // CHECK-LABEL: @_Z18struct_array_index
301 int struct_array_index(ArrayMembers *p, int n) {
302   // CHECK: %[[IDX_OK:.*]] = icmp ult i64 %{{.*}}, 5
303   // CHECK: br i1 %[[IDX_OK]]
304   // CHECK: call void @__ubsan_handle_out_of_bounds(
305   return p->a1[n];
306 }
307 
308 // CHECK-LABEL: @_Z16flex_array_index
309 int flex_array_index(ArrayMembers *p, int n) {
310   // CHECK-NOT: call void @__ubsan_handle_out_of_bounds(
311   return p->a2[n];
312 }
313 
314 extern int incomplete[];
315 // CHECK-LABEL: @_Z22incomplete_array_index
316 int incomplete_array_index(int n) {
317   // CHECK-NOT: call void @__ubsan_handle_out_of_bounds(
318   return incomplete[n];
319 }
320 
321 typedef __attribute__((ext_vector_type(4))) int V4I;
322 // CHECK-LABEL: @_Z12vector_index
323 int vector_index(V4I v, int n) {
324   // CHECK: %[[IDX_OK:.*]] = icmp ult i64 %{{.*}}, 4
325   // CHECK: br i1 %[[IDX_OK]]
326   // CHECK: call void @__ubsan_handle_out_of_bounds(
327   return v[n];
328 }
329 
330 // CHECK-LABEL: @_Z12string_index
331 char string_index(int n) {
332   // CHECK: %[[IDX_OK:.*]] = icmp ult i64 %{{.*}}, 6
333   // CHECK: br i1 %[[IDX_OK]]
334   // CHECK: call void @__ubsan_handle_out_of_bounds(
335   return "Hello"[n];
336 }
337 
338 class A // align=4
339 {
340   int a1, a2, a3;
341 };
342 
343 class B // align=8
344 {
345   long b1, b2;
346 };
347 
348 class C : public A, public B // align=16
349 {
350   alignas(16) int c1;
351 };
352 
353 // Make sure we check the alignment of the pointer after subtracting any
354 // offset. The pointer before subtraction doesn't need to be aligned for
355 // the destination type.
356 
357 // CHECK-LABEL: define void @_Z16downcast_pointerP1B(%class.B* %b)
358 void downcast_pointer(B *b) {
359   (void) static_cast<C*>(b);
360   // Alignment check from EmitTypeCheck(TCK_DowncastPointer, ...)
361   // CHECK: [[SUB:%[.a-z0-9]*]] = getelementptr i8* {{.*}}, i64 -16
362   // CHECK-NEXT: [[C:%[0-9]*]] = bitcast i8* [[SUB]] to %class.C*
363   // null check goes here
364   // CHECK: [[FROM_PHI:%[0-9]*]] = phi %class.C* [ [[C]], {{.*}} ], {{.*}}
365   // Objectsize check goes here
366   // CHECK: [[C_INT:%[0-9]*]] = ptrtoint %class.C* [[FROM_PHI]] to i64
367   // CHECK-NEXT: [[MASKED:%[0-9]*]] = and i64 [[C_INT]], 15
368   // CHECK-NEXT: [[TEST:%[0-9]*]] = icmp eq i64 [[MASKED]], 0
369   // AND the alignment test with the objectsize test.
370   // CHECK-NEXT: [[AND:%[0-9]*]] = and i1 {{.*}}, [[TEST]]
371   // CHECK-NEXT: br i1 [[AND]]
372 }
373 
374 // CHECK-LABEL: define void @_Z18downcast_referenceR1B(%class.B* dereferenceable({{[0-9]+}}) %b)
375 void downcast_reference(B &b) {
376   (void) static_cast<C&>(b);
377   // Alignment check from EmitTypeCheck(TCK_DowncastReference, ...)
378   // CHECK:      [[SUB:%[.a-z0-9]*]] = getelementptr i8* {{.*}}, i64 -16
379   // CHECK-NEXT: [[C:%[0-9]*]] = bitcast i8* [[SUB]] to %class.C*
380   // Objectsize check goes here
381   // CHECK:      [[C_INT:%[0-9]*]] = ptrtoint %class.C* [[C]] to i64
382   // CHECK-NEXT: [[MASKED:%[0-9]*]] = and i64 [[C_INT]], 15
383   // CHECK-NEXT: [[TEST:%[0-9]*]] = icmp eq i64 [[MASKED]], 0
384   // AND the alignment test with the objectsize test.
385   // CHECK-NEXT: [[AND:%[0-9]*]] = and i1 {{.*}}, [[TEST]]
386   // CHECK-NEXT: br i1 [[AND]]
387 }
388 
389 // CHECK-LABEL: @_Z22indirect_function_callPFviE({{.*}} prefix <{ i32, i8* }> <{ i32 1413876459, i8* bitcast ({ i8*, i8* }* @_ZTIFvPFviEE to i8*) }>
390 void indirect_function_call(void (*p)(int)) {
391   // CHECK: [[PTR:%[0-9]*]] = bitcast void (i32)* {{.*}} to <{ i32, i8* }>*
392 
393   // Signature check
394   // CHECK-NEXT: [[SIGPTR:%[0-9]*]] = getelementptr <{ i32, i8* }>* [[PTR]], i32 0, i32 0
395   // CHECK-NEXT: [[SIG:%[0-9]*]] = load i32* [[SIGPTR]]
396   // CHECK-NEXT: [[SIGCMP:%[0-9]*]] = icmp eq i32 [[SIG]], 1413876459
397   // CHECK-NEXT: br i1 [[SIGCMP]]
398 
399   // RTTI pointer check
400   // CHECK: [[RTTIPTR:%[0-9]*]] = getelementptr <{ i32, i8* }>* [[PTR]], i32 0, i32 1
401   // CHECK-NEXT: [[RTTI:%[0-9]*]] = load i8** [[RTTIPTR]]
402   // CHECK-NEXT: [[RTTICMP:%[0-9]*]] = icmp eq i8* [[RTTI]], bitcast ({ i8*, i8* }* @_ZTIFviE to i8*)
403   // CHECK-NEXT: br i1 [[RTTICMP]]
404   p(42);
405 }
406 
407 namespace CopyValueRepresentation {
408   // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S3aSERKS0_
409   // CHECK-NOT: call {{.*}} @__ubsan_handle_load_invalid_value
410   // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S4aSEOS0_
411   // CHECK-NOT: call {{.*}} @__ubsan_handle_load_invalid_value
412   // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S5C2ERKS0_
413   // CHECK-NOT: call {{.*}} __ubsan_handle_load_invalid_value
414   // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S2C2ERKS0_
415   // CHECK: __ubsan_handle_load_invalid_value
416   // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S1C2ERKS0_
417   // CHECK-NOT: call {{.*}} __ubsan_handle_load_invalid_value
418 
419   struct CustomCopy { CustomCopy(); CustomCopy(const CustomCopy&); };
420   struct S1 {
421     CustomCopy CC;
422     bool b;
423   };
424   void callee1(S1);
425   void test1() {
426     S1 s11;
427     callee1(s11);
428     S1 s12;
429     s12 = s11;
430   }
431 
432   static bool some_global_bool;
433   struct ExprCopy {
434     ExprCopy();
435     ExprCopy(const ExprCopy&, bool b = some_global_bool);
436   };
437   struct S2 {
438     ExprCopy EC;
439     bool b;
440   };
441   void callee2(S2);
442   void test2(void) {
443     S2 s21;
444     callee2(s21);
445     S2 s22;
446     s22 = s21;
447   }
448 
449   struct CustomAssign { CustomAssign &operator=(const CustomAssign&); };
450   struct S3 {
451     CustomAssign CA;
452     bool b;
453   };
454   void test3() {
455     S3 x, y;
456     x = y;
457   }
458 
459   struct CustomMove {
460     CustomMove();
461     CustomMove(const CustomMove&&);
462     CustomMove &operator=(const CustomMove&&);
463   };
464   struct S4 {
465     CustomMove CM;
466     bool b;
467   };
468   void test4() {
469     S4 x, y;
470     x = static_cast<S4&&>(y);
471   }
472 
473   struct EnumCustomCopy {
474     EnumCustomCopy();
475     EnumCustomCopy(const EnumCustomCopy&);
476   };
477   struct S5 {
478     EnumCustomCopy ECC;
479     bool b;
480   };
481   void callee5(S5);
482   void test5() {
483     S5 s51;
484     callee5(s51);
485     S5 s52;
486     s52 = s51;
487   }
488 }
489 
490 // CHECK: attributes [[NR_NUW]] = { noreturn nounwind }
491