avt77 added inline comments. ================ Comment at: test/SemaCXX/dllimport.cpp:179 @@ -140,1 +178,3 @@ +template <typename T> +int ExternVarTmplDeclInit = 1; ---------------- majnemer wrote: > avt77 wrote: > > rnk wrote: > > > Can you check with MSVC 2015 update 2 actually does with definitions of > > > dllimport variable templates? I bet it doesn't export them. > > They don't support variable templates at all: > > > > error C2399: variable templates are not supported in this release > Your compiler is too old, they are definitely supported. > > > Previously a template declaration was only allowed to be a function, class, > > or alias. Now, in the MSVC compiler it can be a variable as well. > > https://blogs.msdn.microsoft.com/vcblog/2016/02/11/compiler-improvements-in-vs-2015-update-2/ OK, I updated several additional components and now CL supports variable templates. I checked the issue again and got the following:
C:\_bugs>cl -c t1.cpp Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23918 for x86 Copyright (C) Microsoft Corporation. All rights reserved. t1.cpp t1.cpp(8): warning C4273: 'ExternVarTmplDeclInit': inconsistent dll linkage t1.cpp(2): note: see previous definition of 'ExternVarTmplDeclInit' C:\_bugs>dumpbin /directives t1.obj Microsoft (R) COFF/PE Dumper Version 14.00.23918.0 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file t1.obj File Type: COFF OBJECT Linker Directives ----------------- /DEFAULTLIB:LIBCMT /DEFAULTLIB:OLDNAMES /EXPORT:??$ExternVarTmplDeclInit@H@@3HA,DATA// As you see they produce warning and change the export attribute. I suppose Clang should do the same, right? ================ Comment at: test/SemaCXX/dllimport.cpp:1137 @@ -1017,1 +1136,3 @@ +template <typename T> +void ImportClassTmplMembers<T>::normalDef() {} #ifdef GNU ---------------- avt77 wrote: > rnk wrote: > > I'm pretty sure MSVC considers all free function templates to be 'inline', > > i.e. they put them in comdats. I doubt MSVC exports these. Can you verify > > what it does? > They prohibit such a definition in the latest MSVC: > > error C2491: 'ImportClassTmplMembers<T>::normalDef': definition of dllimport > function not allowed > > The same error I see for other definitions as well With the latest compiler they disallow the definition of dllimport functions as well. I suppose Clang should do the same, right? http://reviews.llvm.org/D18953 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits