[PATCH] D45978: dllexport const variables must have external linkage.

Zahira Ammarguellat via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 12 07:11:18 PST 2019


zahiraam added a subscriber: z.
zahiraam added inline comments.


================
Comment at: test/Sema/dllexport-1.c:8
+
+// CHECK: @y = common dso_local dllexport global i32 0, align 4
+
----------------
aaron.ballman wrote:
> Are x and z also exported as expected?
Only x and y are exported.


**@x = dso_local dllexport constant i32 3, align 4**
@z = dso_local constant i32 4, align 4
**@y = common dso_local dllexport global i32 0, align 4**

But then if I take this simple case:
extern int const z = 4;

int main() {
  int a = z + 2;
  return a;
}
ksh-3.2$ clang -c test3.c
test3.c:1:18: warning: 'extern' variable has an initializer [-Wextern-initializer]
extern int const z = 4;
                 ^
1 warning generated.
ksh-3.2$ dumpbin /symbols test3.o | grep External
00F 00000000 SECT1  notype ()    External     | main
**010 00000000 SECT5  notype       External     | z**
ksh-3.2$
When emitting the IR, z is declared as a local constant (not exported):
@z = dso_local constant i32 4, align 4




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D45978/new/

https://reviews.llvm.org/D45978





More information about the cfe-commits mailing list