[PATCH] Sema: Definition of dllimport globals is not allowed
Gao, Yunzhong
yunzhong_gao at playstation.sony.com
Wed Feb 26 11:05:43 PST 2014
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: cfe-commits-bounces at cs.uiuc.edu [cfe-commits-bounces at cs.uiuc.edu] on behalf of Reid Kleckner [rnk at google.com]
Sent: Wednesday, February 26, 2014 10:55 AM
To: Nico Rieck
Cc: cfe-commits at cs.uiuc.edu 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 <nico.rieck at gmail.com<mailto:nico.rieck at gmail.com>> 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
cfe-commits at cs.uiuc.edu<mailto:cfe-commits at cs.uiuc.edu>
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list