xref: /aosp_15_r20/external/clang/test/Sema/2009-03-09-WeakDeclarations-1.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -verify %s -triple i686-apple-darwin
2*67e74705SXin Li // Insist upon warnings for inappropriate weak attributes.
3*67e74705SXin Li 
4*67e74705SXin Li // O.K.
5*67e74705SXin Li extern int ext_weak_import __attribute__ ((__weak_import__));
6*67e74705SXin Li 
7*67e74705SXin Li // These are inappropriate, and should generate warnings:
8*67e74705SXin Li int decl_weak_import __attribute__ ((__weak_import__)); // expected-warning {{'weak_import' attribute cannot be specified on a definition}}
9*67e74705SXin Li int decl_initialized_weak_import __attribute__ ((__weak_import__)) = 13; // expected-warning {{'weak_import' attribute cannot be specified on a definition}}
10*67e74705SXin Li 
11*67e74705SXin Li // O.K.
12*67e74705SXin Li extern int ext_f(void) __attribute__ ((__weak_import__));
13*67e74705SXin Li 
14*67e74705SXin Li // These are inappropriate, and should generate warnings:
15*67e74705SXin Li int def_f(void) __attribute__ ((__weak_import__));
decl_f(void)16*67e74705SXin Li int __attribute__ ((__weak_import__)) decl_f(void) {return 0;};
17