[llvm-branch-commits] [cfe-branch] r243320 - Merging r242973:

Hans Wennborg hans at hanshq.net
Mon Jul 27 13:36:24 PDT 2015


Author: hans
Date: Mon Jul 27 15:36:24 2015
New Revision: 243320

URL: http://llvm.org/viewvc/llvm-project?rev=243320&view=rev
Log:
Merging r242973:
------------------------------------------------------------------------
r242973 | hans | 2015-07-22 16:54:51 -0700 (Wed, 22 Jul 2015) | 3 lines

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.
------------------------------------------------------------------------

Modified:
    cfe/branches/release_37/   (props changed)
    cfe/branches/release_37/lib/Sema/SemaDecl.cpp
    cfe/branches/release_37/test/Sema/dllimport.c

Propchange: cfe/branches/release_37/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul 27 15:36:24 2015
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:242244,242285,242293,242297,242313,242382,242422,242499,242574,242660,242662,242667,242678,242766,242905,243018,243048
+/cfe/trunk:242244,242285,242293,242297,242313,242382,242422,242499,242574,242660,242662,242667,242678,242766,242905,242973,243018,243048
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_37/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_37/lib/Sema/SemaDecl.cpp?rev=243320&r1=243319&r2=243320&view=diff
==============================================================================
--- cfe/branches/release_37/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/release_37/lib/Sema/SemaDecl.cpp Mon Jul 27 15:36:24 2015
@@ -5381,10 +5381,9 @@ static void checkDLLAttributeRedeclarati
   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;
@@ -5393,6 +5392,13 @@ static void checkDLLAttributeRedeclarati
         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)

Modified: cfe/branches/release_37/test/Sema/dllimport.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_37/test/Sema/dllimport.c?rev=243320&r1=243319&r2=243320&view=diff
==============================================================================
--- cfe/branches/release_37/test/Sema/dllimport.c (original)
+++ cfe/branches/release_37/test/Sema/dllimport.c Mon Jul 27 15:36:24 2015
@@ -143,7 +143,7 @@ __declspec(dllimport) void redecl3(); //
 
                       void redecl4(); // expected-note{{previous declaration is here}}
 void useRedecl4() { redecl4(); }
-__declspec(dllimport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllimport' attribute}}
+__declspec(dllimport) void redecl4(); // expected-warning{{redeclaration of 'redecl4' should not add 'dllimport' attribute}}
 
 // Allow with a warning if the decl hasn't been used yet.
                       void redecl5(); // expected-note{{previous declaration is here}}





More information about the llvm-branch-commits mailing list