summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2015-07-22 23:54:51 +0000
committerHans Wennborg <hans@hanshq.net>2015-07-22 23:54:51 +0000
commit0106479fa83bd655bb6a69f4a305530c6d5290ce (patch)
tree072ec81fdd178660d6a533b87649bf02840ead35 /clang/lib/Sema/SemaDecl.cpp
parent38e874e4877067c28266b11b910333e395123b39 (diff)
downloadbcm5719-llvm-0106479fa83bd655bb6a69f4a305530c6d5290ce.tar.gz
bcm5719-llvm-0106479fa83bd655bb6a69f4a305530c6d5290ce.zip
Downgrade error about adding 'dllimport' to used free function to warning (PR24215)
The code will still work as it can reference the function via its thunk. llvm-svn: 242973
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d25b4dda885..0eea0e689dc 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5368,10 +5368,9 @@ static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl,
bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
if (AddsAttr && !IsSpecialization && !OldDecl->isImplicit()) {
- // If the declaration hasn't been used yet, allow with a warning for
- // free functions and global variables.
+ // Allow with a warning for free functions and global variables.
bool JustWarn = false;
- if (!OldDecl->isUsed() && !OldDecl->isCXXClassMember()) {
+ if (!OldDecl->isCXXClassMember()) {
auto *VD = dyn_cast<VarDecl>(OldDecl);
if (VD && !VD->getDescribedVarTemplate())
JustWarn = true;
@@ -5380,6 +5379,13 @@ static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl,
JustWarn = true;
}
+ // We cannot change a declaration that's been used because IR has already
+ // been emitted. Dllimported functions will still work though (modulo
+ // address equality) as they can use the thunk.
+ if (OldDecl->isUsed())
+ if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
+ JustWarn = false;
+
unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
: diag::err_attribute_dll_redeclaration;
S.Diag(NewDecl->getLocation(), DiagID)
OpenPOWER on IntegriCloud