summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorNico Rieck <nico.rieck@gmail.com>2014-02-26 21:27:13 +0000
committerNico Rieck <nico.rieck@gmail.com>2014-02-26 21:27:13 +0000
commit8e9791f62c453e80c50c7ad342b10f969eeffd0d (patch)
tree38c9e5e6a6dbc68c246e3a6985f37c86ab3fa364 /clang/lib/Sema/SemaDecl.cpp
parentb3d4821ae5d186759bb9c084994f2532cb3d0dbd (diff)
downloadbcm5719-llvm-8e9791f62c453e80c50c7ad342b10f969eeffd0d.tar.gz
bcm5719-llvm-8e9791f62c453e80c50c7ad342b10f969eeffd0d.zip
Sema: Definition of dllimport globals is not allowed
Upgrades the warning to an error and clarifies the message by treating the definition as error instead of the attribute. llvm-svn: 202300
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 266f66844e2..601c16109f5 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8123,6 +8123,13 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
return;
}
+ // dllimport cannot be used on variable definitions.
+ if (VDecl->hasAttr<DLLImportAttr>() && !VDecl->isStaticDataMember()) {
+ Diag(VDecl->getLocation(), diag::err_attribute_dllimport_data_definition);
+ VDecl->setInvalidDecl();
+ return;
+ }
+
if (VDecl->isLocalVarDecl() && VDecl->hasExternalStorage()) {
// C99 6.7.8p5. C++ has no such restriction, but that is a defect.
Diag(VDecl->getLocation(), diag::err_block_extern_cant_init);
OpenPOWER on IntegriCloud