diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-06-22 22:08:50 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-06-22 22:08:50 +0000 |
commit | 33e022650adee965c65f9aea086ee74f3fd1bad5 (patch) | |
tree | 3493a7c5bb5f6e2cb564000278fc3b5ed186844d /clang/lib | |
parent | a60a269e671989b27d46f08a0404ab33109ee22e (diff) | |
download | bcm5719-llvm-33e022650adee965c65f9aea086ee74f3fd1bad5.tar.gz bcm5719-llvm-33e022650adee965c65f9aea086ee74f3fd1bad5.zip |
Issue warning if weak_import attribute is added to an already
declared variable and ignore it. // rdar://9538608
llvm-svn: 133654
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index fe3b3b4f7c1..daf9f034ac9 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2039,12 +2039,17 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) { } mergeDeclAttributes(New, Old, Context); - // weak_import on current declaration is applied to previous - // tentative definiton. + // Warn if an already-declared variable is made a weak_import in a subsequent declaration if (New->getAttr<WeakImportAttr>() && Old->getStorageClass() == SC_None && - !Old->getAttr<WeakImportAttr>()) - Old->addAttr(::new (Context) WeakImportAttr(SourceLocation(), Context)); + !Old->getAttr<WeakImportAttr>()) { + Diag(New->getLocation(), diag::warn_weak_import) << New->getDeclName(); + Diag(Old->getLocation(), diag::note_previous_definition); + // Remove weak_import attribute on new declaration. + // I am just dropping all attributes in curernt decl. We have + // already issued a warning, so we are OK. + New->dropAttrs(); + } // Merge the types. MergeVarDeclTypes(New, Old); |