brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.5 KiB · 5f6ff36 Raw
169 lines · c
1// RUN: %clang_cc1 -triple i686-win32     -fsyntax-only -fms-extensions -verify -std=c99 %s2// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions -verify -std=c11 %s3// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -fms-extensions -verify -std=c11 %s4// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c99 %s5// RUN: %clang_cc1 -triple i686-windows-itanium   -fsyntax-only -fms-extensions -verify -std=c99 %s6// RUN: %clang_cc1 -triple x86_64-windows-itanium -fsyntax-only -fms-extensions -verify -std=c11 %s7// RUN: %clang_cc1 -triple x86_64-sie-ps5         -fsyntax-only -fms-extensions -verify -std=c99 %s8// RUN: %clang_cc1 -triple x86_64-sie-ps5         -fsyntax-only -fms-extensions -verify -std=c11 %s9 10// Invalid usage.11__declspec(dllexport) typedef int typedef1;12// expected-warning@-1{{'dllexport' attribute only applies to functions, variables, classes, and Objective-C interfaces}}13typedef __declspec(dllexport) int typedef2;14// expected-warning@-1{{'dllexport' attribute only applies to}}15typedef int __declspec(dllexport) typedef3;16// expected-warning@-1{{'dllexport' attribute only applies to}}17typedef __declspec(dllexport) void (*FunTy)(void);18// expected-warning@-1{{'dllexport' attribute only applies to}}19enum __declspec(dllexport) Enum { EnumVal };20// expected-warning@-1{{'dllexport' attribute only applies to}}21struct __declspec(dllexport) Record {};22// expected-warning@-1{{'dllexport' attribute only applies to}}23 24 25 26//===----------------------------------------------------------------------===//27// Globals28//===----------------------------------------------------------------------===//29 30// Export declaration.31__declspec(dllexport) extern int ExternGlobalDecl;32 33// dllexport implies a definition.34__declspec(dllexport) int GlobalDef;35 36// Export definition.37__declspec(dllexport) int GlobalInit1 = 1;38int __declspec(dllexport) GlobalInit2 = 1;39 40// Declare, then export definition.41__declspec(dllexport) extern int GlobalDeclInit;42int GlobalDeclInit = 1;43 44// Redeclarations45__declspec(dllexport) extern int GlobalRedecl1;46__declspec(dllexport)        int GlobalRedecl1;47 48__declspec(dllexport) extern int GlobalRedecl2;49                             int GlobalRedecl2;50 51                      extern int GlobalRedecl3; // expected-note{{previous declaration is here}}52int useGlobalRedecl3(void) { return GlobalRedecl3; }53__declspec(dllexport) extern int GlobalRedecl3; // expected-error{{redeclaration of 'GlobalRedecl3' cannot add 'dllexport' attribute}}54 55                      extern int GlobalRedecl4; // expected-note{{previous declaration is here}}56__declspec(dllexport) extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllexport' attribute}}57 58 59// External linkage is required.60__declspec(dllexport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllexport'}}61 62// Thread local variables are invalid.63__declspec(dllexport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllexport'}}64 65// Export in local scope.66void functionScope(void) {67  __declspec(dllexport)        int LocalVarDecl; // expected-error{{'LocalVarDecl' must have external linkage when declared 'dllexport'}}68  __declspec(dllexport)        int LocalVarDef = 1; // expected-error{{'LocalVarDef' must have external linkage when declared 'dllexport'}}69  __declspec(dllexport) extern int ExternLocalVarDecl;70  __declspec(dllexport) static int StaticLocalVar; // expected-error{{'StaticLocalVar' must have external linkage when declared 'dllexport'}}71}72 73 74 75//===----------------------------------------------------------------------===//76// Functions77//===----------------------------------------------------------------------===//78 79// Export function declaration. Check different placements.80__attribute__((dllexport)) void decl1A(void); // Basic check with __attribute__81__declspec(dllexport)      void decl1B(void);82 83void __attribute__((dllexport)) decl2A(void);84void __declspec(dllexport)      decl2B(void);85 86// Export function definition.87__declspec(dllexport) void def(void) {}88 89// Export inline function.90__declspec(dllexport) inline void inlineFunc1(void) {}91extern void inlineFunc1(void);92 93inline void __attribute__((dllexport)) inlineFunc2(void) {}94extern void inlineFunc2(void);95 96// Redeclarations97__declspec(dllexport) void redecl1(void);98__declspec(dllexport) void redecl1(void);99 100__declspec(dllexport) void redecl2(void);101                      void redecl2(void);102 103__declspec(dllexport) void redecl3(void);104                      void redecl3(void) {}105 106                      void redecl4(void); // expected-note{{previous declaration is here}}107void useRedecl4(void) { redecl4(); }108__declspec(dllexport) void redecl4(void); // expected-error{{redeclaration of 'redecl4' cannot add 'dllexport' attribute}}109 110                      void redecl5(void); // expected-note{{previous declaration is here}}111void useRedecl5(void) { redecl5(); }112__declspec(dllexport) inline void redecl5(void) {} // expected-error{{redeclaration of 'redecl5' cannot add 'dllexport' attribute}}113 114// Allow with a warning if the decl hasn't been used yet.115                      void redecl6(void); // expected-note{{previous declaration is here}}116__declspec(dllexport) void redecl6(void); // expected-warning{{redeclaration of 'redecl6' should not add 'dllexport' attribute}}117 118 119// External linkage is required.120__declspec(dllexport) static int staticFunc(void); // expected-error{{'staticFunc' must have external linkage when declared 'dllexport'}}121 122// Static locals don't count as having external linkage.123void staticLocalFunc(void) {124  __declspec(dllexport) static int staticLocal; // expected-error{{'staticLocal' must have external linkage when declared 'dllexport'}}125}126 127 128 129//===----------------------------------------------------------------------===//130// Precedence131//===----------------------------------------------------------------------===//132 133// dllexport takes precedence over dllimport if both are specified.134__attribute__((dllimport, dllexport))       extern int PrecedenceExternGlobal1A; // expected-warning{{'dllimport' attribute ignored}}135__declspec(dllimport) __declspec(dllexport) extern int PrecedenceExternGlobal1B; // expected-warning{{'dllimport' attribute ignored}}136 137__attribute__((dllexport, dllimport))       extern int PrecedenceExternGlobal2A; // expected-warning{{'dllimport' attribute ignored}}138__declspec(dllexport) __declspec(dllimport) extern int PrecedenceExternGlobal2B; // expected-warning{{'dllimport' attribute ignored}}139 140__attribute__((dllimport, dllexport))       int PrecedenceGlobal1A; // expected-warning{{'dllimport' attribute ignored}}141__declspec(dllimport) __declspec(dllexport) int PrecedenceGlobal1B; // expected-warning{{'dllimport' attribute ignored}}142 143__attribute__((dllexport, dllimport))       int PrecedenceGlobal2A; // expected-warning{{'dllimport' attribute ignored}}144__declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B; // expected-warning{{'dllimport' attribute ignored}}145 146__declspec(dllexport) extern int PrecedenceExternGlobalRedecl1;147__declspec(dllimport) extern int PrecedenceExternGlobalRedecl1; // expected-warning{{'dllimport' attribute ignored}}148 149__declspec(dllimport) extern int PrecedenceExternGlobalRedecl2; // expected-warning{{'dllimport' attribute ignored}}150__declspec(dllexport) extern int PrecedenceExternGlobalRedecl2;151 152__declspec(dllexport) extern int PrecedenceGlobalRedecl1;153__declspec(dllimport)        int PrecedenceGlobalRedecl1; // expected-warning{{'dllimport' attribute ignored}}154 155__declspec(dllimport) extern int PrecedenceGlobalRedecl2; // expected-warning{{'dllimport' attribute ignored}}156__declspec(dllexport)        int PrecedenceGlobalRedecl2;157 158void __attribute__((dllimport, dllexport))       precedence1A(void) {} // expected-warning{{'dllimport' attribute ignored}}159void __declspec(dllimport) __declspec(dllexport) precedence1B(void) {} // expected-warning{{'dllimport' attribute ignored}}160 161void __attribute__((dllexport, dllimport))       precedence2A(void) {} // expected-warning{{'dllimport' attribute ignored}}162void __declspec(dllexport) __declspec(dllimport) precedence2B(void) {} // expected-warning{{'dllimport' attribute ignored}}163 164void __declspec(dllimport) precedenceRedecl1(void); // expected-warning{{'dllimport' attribute ignored}}165void __declspec(dllexport) precedenceRedecl1(void) {}166 167void __declspec(dllexport) precedenceRedecl2(void);168void __declspec(dllimport) precedenceRedecl2(void) {} // expected-warning{{'dllimport' attribute ignored}}169