attributes.c revision 2968b7741da535810250b919c95d12105882d19f
1d7d5f0223bd30dfd618762349c6209dd1d5ea3e6Daniel Dunbar// RUN: clang-cc -emit-llvm -o %t %s && 2d58139e1d42fd8b3a841258862a6b1e643b5e67bDaniel Dunbar// RUN: grep 't1.*noreturn' %t && 3d58139e1d42fd8b3a841258862a6b1e643b5e67bDaniel Dunbar// RUN: grep 't2.*nounwind' %t && 4d58139e1d42fd8b3a841258862a6b1e643b5e67bDaniel Dunbar// RUN: grep 'weak.*t3' %t && 5d58139e1d42fd8b3a841258862a6b1e643b5e67bDaniel Dunbar// RUN: grep 'hidden.*t4' %t && 6d58139e1d42fd8b3a841258862a6b1e643b5e67bDaniel Dunbar// RUN: grep 't5.*weak' %t && 7d58139e1d42fd8b3a841258862a6b1e643b5e67bDaniel Dunbar// RUN: grep 't6.*protected' %t && 8d58139e1d42fd8b3a841258862a6b1e643b5e67bDaniel Dunbar// RUN: grep 't7.*noreturn' %t && 9d58139e1d42fd8b3a841258862a6b1e643b5e67bDaniel Dunbar// RUN: grep 't7.*nounwind' %t && 1017f194f4393a67fd28ad822c06d32b8cb99bad3fDaniel Dunbar// RUN: grep 't9.*alias.*weak.*t8' %t && 1117f194f4393a67fd28ad822c06d32b8cb99bad3fDaniel Dunbar// RUN: grep '@t10().*section "SECT"' %t && 1217f194f4393a67fd28ad822c06d32b8cb99bad3fDaniel Dunbar// RUN: grep '@t11().*section "SECT"' %t && 1317f194f4393a67fd28ad822c06d32b8cb99bad3fDaniel Dunbar// RUN: grep '@t12 =.*section "SECT"' %t && 1430510abee628c645285e01cfd4779610d46a822cDaniel Dunbar// RUN: grep '@t13 =.*section "SECT"' %t && 1530510abee628c645285e01cfd4779610d46a822cDaniel Dunbar// RUN: grep '@t14.x =.*section "SECT"' %t 165e27314eb5a9cba7997cf9f6fc82428d99667077Daniel Dunbar// RUN: grep 'declare extern_weak i32 @t15()' %t && 172968b7741da535810250b919c95d12105882d19fDaniel Dunbar// RUN: grep '@t16 = extern_weak global i32' %t && 18d58139e1d42fd8b3a841258862a6b1e643b5e67bDaniel Dunbar 19ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattnervoid t1() __attribute__((noreturn)); 20ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattnervoid t1() {} 21ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattner 22ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattnervoid t2() __attribute__((nothrow)); 23ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattnervoid t2() {} 24ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattner 25ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattnervoid t3() __attribute__((weak)); 26ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattnervoid t3() {} 27ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattner 287b937ae68258ce212e39e8e78ad5321e96547f50Chris Lattnervoid t4() __attribute__((visibility("hidden"))); 29ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattnervoid t4() {} 30ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattner 31ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattnerint t5 __attribute__((weak)) = 2; 32ddee4231e9bdfbac1e1f5385ff1a17fd0e0b0e39Chris Lattner 337b937ae68258ce212e39e8e78ad5321e96547f50Chris Lattnerint t6 __attribute__((visibility("protected"))); 34f89e88d1278828e43d4a67687ba96af88a66d634Chris Lattner 35f89e88d1278828e43d4a67687ba96af88a66d634Chris Lattnervoid t7() __attribute__((noreturn, nothrow)); 36f89e88d1278828e43d4a67687ba96af88a66d634Chris Lattnervoid t7() {} 37d4cbda6292b321c2e7dce7f039d92918fee99b3aNuno Lopes 38d4cbda6292b321c2e7dce7f039d92918fee99b3aNuno Lopesvoid __t8() {} 39d4cbda6292b321c2e7dce7f039d92918fee99b3aNuno Lopesvoid t9() __attribute__((weak, alias("__t8"))); 4017f194f4393a67fd28ad822c06d32b8cb99bad3fDaniel Dunbar 4117f194f4393a67fd28ad822c06d32b8cb99bad3fDaniel Dunbarvoid t10(void) __attribute__((section("SECT"))); 4217f194f4393a67fd28ad822c06d32b8cb99bad3fDaniel Dunbarvoid t10(void) {} 4317f194f4393a67fd28ad822c06d32b8cb99bad3fDaniel Dunbarvoid __attribute__((section("SECT"))) t11(void) {} 4417f194f4393a67fd28ad822c06d32b8cb99bad3fDaniel Dunbar 4517f194f4393a67fd28ad822c06d32b8cb99bad3fDaniel Dunbarint t12 __attribute__((section("SECT"))); 4617f194f4393a67fd28ad822c06d32b8cb99bad3fDaniel Dunbarstruct s0 { int x; }; 4730510abee628c645285e01cfd4779610d46a822cDaniel Dunbarstruct s0 t13 __attribute__((section("SECT"))) = { 0 }; 4830510abee628c645285e01cfd4779610d46a822cDaniel Dunbar 4930510abee628c645285e01cfd4779610d46a822cDaniel Dunbarvoid t14(void) { 5030510abee628c645285e01cfd4779610d46a822cDaniel Dunbar static int x __attribute__((section("SECT"))) = 0; 5130510abee628c645285e01cfd4779610d46a822cDaniel Dunbar} 525e27314eb5a9cba7997cf9f6fc82428d99667077Daniel Dunbar 535e27314eb5a9cba7997cf9f6fc82428d99667077Daniel Dunbarint __attribute__((weak_import)) t15(void); 545e27314eb5a9cba7997cf9f6fc82428d99667077Daniel Dunbarextern int t16 __attribute__((weak_import)); 555e27314eb5a9cba7997cf9f6fc82428d99667077Daniel Dunbarint t17() { 565e27314eb5a9cba7997cf9f6fc82428d99667077Daniel Dunbar return t15() + t16; 575e27314eb5a9cba7997cf9f6fc82428d99667077Daniel Dunbar} 585e27314eb5a9cba7997cf9f6fc82428d99667077Daniel Dunbar 592968b7741da535810250b919c95d12105882d19fDaniel Dunbar// RUN: grep '@t18 = global i[0-9]* 1, align .*' %t && 602968b7741da535810250b919c95d12105882d19fDaniel Dunbarextern int t18 __attribute__((weak_import)); 612968b7741da535810250b919c95d12105882d19fDaniel Dunbarint t18 = 1; 625e27314eb5a9cba7997cf9f6fc82428d99667077Daniel Dunbar 632968b7741da535810250b919c95d12105882d19fDaniel Dunbar// RUN: grep 'define i[0-9]* @t19() nounwind {' %t && 642968b7741da535810250b919c95d12105882d19fDaniel Dunbarextern int t19(void) __attribute__((weak_import)); 652968b7741da535810250b919c95d12105882d19fDaniel Dunbarint t19(void) { 662968b7741da535810250b919c95d12105882d19fDaniel Dunbar return 10; 672968b7741da535810250b919c95d12105882d19fDaniel Dunbar} 682968b7741da535810250b919c95d12105882d19fDaniel Dunbar 692968b7741da535810250b919c95d12105882d19fDaniel Dunbar// RUN: true 70