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 | d543130a3009a350017e2e411ea43bb3e5459b96 (patch) | |
tree | 632095b488d8a87ad902b34f90c95f8cc9936210 /lib | |
parent | 9c7f469318c42c9813be9ac165aaa183d2de7d72 (diff) |
Issue warning if weak_import attribute is added to an already
declared variable and ignore it. // rdar://9538608
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133654 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index fe3b3b4f7c..daf9f034ac 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/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); |