Hi Nico,
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 8e18710..4ea1ceb 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -8132,6 +8132,15 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr
*Init,
return;
}
+ // dllimport cannot be used on variable definitions.
+ if (const DLLImportAttr *ImportAttr = VDecl->getAttr<DLLImportAttr>()) {
+ if (!VDecl->isStaticDataMember()) {
+ Diag(VDecl->getLocation(),
diag::err_attribute_dllimport_data_definition);
+ VDecl->setInvalidDecl();
+ return;
+ }
+ }
+
It looks like you do not have to use two if statements here since ImportAttr is
not referenced?
Maybe if (VDecl->hasAttr<DLLImportAttr>() && !VDecl->isStaticDataMember()) will
suffice.
- Gao
________________________________________
From: [email protected] [[email protected]] on
behalf of Reid Kleckner [[email protected]]
Sent: Wednesday, February 26, 2014 10:55 AM
To: Nico Rieck
Cc: [email protected] cfe
Subject: Re: [PATCH] Sema: Definition of dllimport globals is not allowed
LGTM, thanks!
On Wed, Feb 26, 2014 at 2:49 AM, Nico Rieck
<[email protected]<mailto:[email protected]>> wrote:
On 22.02.2014 21:07, Nico Rieck wrote:
> This upgrades the warning when defining dllimport variables to an error
> (consistent with GCC and MSVC).
Ping.
_______________________________________________
cfe-commits mailing list
[email protected]<mailto:[email protected]>
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits