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

Zahira Ammarguellat via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 8 00:38:01 PST 2019


zahiraam updated this revision to Diff 185920.

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

https://reviews.llvm.org/D45978

Files:
  test/Sema/dllexport-1.cpp
  test/Sema/dllexport-2.cpp
  test/Sema/dllexport.c


Index: test/Sema/dllexport.c
===================================================================
--- test/Sema/dllexport.c
+++ test/Sema/dllexport.c
@@ -162,3 +162,16 @@
 
 void __declspec(dllexport) precedenceRedecl2();
 void __declspec(dllimport) precedenceRedecl2() {} // expected-warning{{'dllimport' attribute ignored}}
+
+// Export const variable.
+
+// CHECK: @y = common dso_local dllexport global i32 0, align 4
+
+__declspec(dllexport) int const x = 3;
+__declspec(dllexport) const int y;
+extern int const z = 4; // expected-warning{{'extern' variable has an initializer}}
+
+int main() {
+  int a = x + y + z;
+  return a;
+}
Index: test/Sema/dllexport-2.cpp
===================================================================
--- test/Sema/dllexport-2.cpp
+++ test/Sema/dllexport-2.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions -verify %s
-// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -fms-extensions -verify -std=c++11 %s
 
 // Export const variable.
 
Index: test/Sema/dllexport-1.cpp
===================================================================
--- test/Sema/dllexport-1.cpp
+++ test/Sema/dllexport-1.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions -verify %s
-// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -fms-extensions -verify -std=c++11 %s
 
 // CHECK: @"?x@@3HB" = dso_local dllexport constant i32 3, align 4
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45978.185920.patch
Type: text/x-patch
Size: 1631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190208/7cd0e359/attachment-0001.bin>


More information about the cfe-commits mailing list