blob: d2a73f7d33e6cbdf3ce926ffbf768aeac05619d5 [file] [log] [blame]
Hans Wennborgc9bd88e2014-01-14 19:35:09 +00001// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s
Douglas Gregore0610152011-02-15 18:11:42 +00002
3// <rdar://problem/8684363>: clang++ not respecting __attribute__((used)) on destructors
4struct X0 {
Richard Smith1ba0a072014-08-01 20:39:36 +00005 // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X0C1Ev
Douglas Gregore0610152011-02-15 18:11:42 +00006 __attribute__((used)) X0() {}
Richard Smith1ba0a072014-08-01 20:39:36 +00007 // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X0D1Ev
Douglas Gregore0610152011-02-15 18:11:42 +00008 __attribute__((used)) ~X0() {}
9};
Hans Wennborga926d842014-05-23 20:37:38 +000010
11// PR19743: not emitting __attribute__((used)) inline methods in nested classes.
12struct X1 {
13 struct Nested {
Richard Smith1ba0a072014-08-01 20:39:36 +000014 // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X16Nested1fEv
Hans Wennborga926d842014-05-23 20:37:38 +000015 void __attribute__((used)) f() {}
16 };
17};
Hans Wennborgdfcb7d62014-06-06 17:36:17 +000018
19struct X2 {
20 // We must delay emission of bar() until foo() has had its body parsed,
21 // otherwise foo() would not be emitted.
22 void __attribute__((used)) bar() { foo(); }
23 void foo() { }
24
Richard Smith1ba0a072014-08-01 20:39:36 +000025 // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X23barEv
26 // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X23fooEv
Hans Wennborgdfcb7d62014-06-06 17:36:17 +000027};