[PATCH] Inherit dll attributes to static locals

Nico Rieck nico.rieck at gmail.com
Wed Jun 18 08:08:20 PDT 2014


>>! In D4136#10, @hans wrote:
> Nico: does the new version of the patch look ok to you?

LGTM

================
Comment at: lib/Sema/SemaDecl.cpp:9108
@@ -9107,1 +9107,3 @@
 
+  // Static locals inherit dll attributes from their function.
+  if (VD->isStaticLocal()) {
----------------
Reid Kleckner wrote:
> Hans Wennborg wrote:
> > Reid Kleckner wrote:
> > > Should this go before checkAttributesAfterMerging?  Consider this obnoxious test case:
> > >   int f();
> > >   inline __declspec(dllexport) int g() {
> > >     static __declspec(dllimport) int x = f();
> > >     return x;
> > >   }
> > Local variables cannot have explicit dll attributes. They can only get them by inheriting from the function they're part of, so calling checkAttributesAfterMerging to check up on the attribute we just added seems redundant.
> OK.  I assume this is covered by Nico's extensive test cases.  :)
Yup, this is handled by requiring external linkage.

http://reviews.llvm.org/D4136






More information about the cfe-commits mailing list