[cfe-dev] Issue with checkDLLAttributeRedeclaration in SemaDecl.cpp

Loïc Joly via cfe-dev cfe-dev at lists.llvm.org
Tue Nov 15 06:04:37 PST 2016


Hello again,



I've finally been able to reduce it to a working example. I can only get this when trying to compile incorrect code (a missing header), but I think it should not crash anyway:


#include "Zorg.h" // Non existing file

template<typename _Tp, std::size_t _Nm = 42>
struct array
{
};

class __declspec(dllimport) DBConnectivity
{
    static bool myFunc(array<int> args);
};


bool
DBConnectivity::myFunc(array<int> args)
{
}



I’ll fill a Bugzilla issue as soon as I have an account (it looks like this is required, I’ve just sent a mail to llvm-admin at lists.llvm.org<mailto:llvm-admin at lists.llvm.org>).



---

Loïc Joly









-----Message d'origine-----
De : hwennborg at google.com [mailto:hwennborg at google.com] De la part de Hans Wennborg
Envoyé : lundi 14 novembre 2016 19:39
À : Loïc Joly <l.joly at castsoftware.com>
Cc : cfe-dev at lists.llvm.org; d.zobnin.bugzilla at gmail.com
Objet : Re: [cfe-dev] Issue with checkDLLAttributeRedeclaration in SemaDecl.cpp



+Denis who wrote r270686



Yes, if you can report this on the Bugzilla that would be better.



If you can provide the preprocessed source and command-line (Clang should be writing these to files in your temp dir when it crashes), I can try to reduce it for you.



Thanks,

Hans





On Mon, Nov 14, 2016 at 9:39 AM, Loïc Joly via cfe-dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>> wrote:

> Hello,

>

> When running Clang 3.9.0 on some Windows code (I've not yet been able

> to reproduce the issue with a small example), we get a crash. I've

> been able to see that the code crashes in

> checkDLLAttributeRedeclaration, more specifically in the following code:

>

>   if (OldImportAttr && !HasNewAttr && !IsInline && !IsStaticDataMember &&

>       !NewDecl->isLocalExternDecl() && !IsQualifiedFriend) {

>     if (IsMicrosoft && IsDefinition) {

>       S.Diag(NewDecl->getLocation(),

>              diag::warn_redeclaration_without_import_attribute)

>           << NewDecl;

>       S.Diag(OldDecl->getLocation(), diag::note_previous_declaration);

>       NewDecl->dropAttr<DLLImportAttr>();

>       NewDecl->addAttr(::new (S.Context) DLLExportAttr(

>           NewImportAttr->getRange(), S.Context,

>           NewImportAttr->getSpellingListIndex()));

>     } else {

>

> We try to read some data from NewImportAttr, but in our case,

> NewImportAttr is null (which is compatible with the !HasNewAttr test).

> I don't really understand the logic of this code, this is why I ask

> for advice before changing anything... Do you think I should open a

> bug instead of discussing on the mailing list?

>

> It appears the code was changed in the following revision:

> Revision: 270686

> Author: dzobnin

> Date: mercredi 25 mai 2016 13:32:42

> Message:

> [ms][dll] #26935 Defining a dllimport function should cause it to be

> exported

>

> If we have some function with dllimport attribute and then we have the

> function definition in the same module but without dllimport attribute

> we should add dllexport attribute to this function definition.

> The same should be done for variables.

>

> Example:

> struct __declspec(dllimport) C3 {

>   ~C3();

> };

> C3::~C3() {;} // we should export this definition.

>

> Patch by Andrew V. Tischenko

>

> Differential revision: http://reviews.llvm.org/D18953

>

>

>

> Thank you for any help,

>

>

> ---

> Loïc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161115/811d3a22/attachment.html>


More information about the cfe-dev mailing list