diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-07 23:58:18 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-07 23:58:18 +0000 |
commit | 9b79fc9c57dc9d541c2a5737c3e2c24cc68d485d (patch) | |
tree | ef1106603d82a8c98672f7b6986a2054ed60e8e5 /lib/Sema/TargetAttributesSema.cpp | |
parent | ca11510d399ae0493bcb3daf24e3c1df399d75f2 (diff) |
Process attributes in the order they appear in the source code. This make clang
match gcc behavior for two conflicting visibilities in the same decl. It also
makes handling of dllimport/dllexport more natural.
As a bonus we now warn on the dllimport in
void __attribute__((dllimport)) foo13();
void __attribute__((dllexport)) foo13();
as does gcc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156343 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/TargetAttributesSema.cpp')
-rw-r--r-- | lib/Sema/TargetAttributesSema.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/Sema/TargetAttributesSema.cpp b/lib/Sema/TargetAttributesSema.cpp index 8b19be74dd..c0746388e5 100644 --- a/lib/Sema/TargetAttributesSema.cpp +++ b/lib/Sema/TargetAttributesSema.cpp @@ -182,16 +182,6 @@ static void HandleDLLImportAttr(Decl *D, const AttributeList &Attr, Sema &S) { return; } - // The attribute is also overridden by a subsequent declaration as dllexport. - // Warning is emitted. - for (AttributeList *nextAttr = Attr.getNext(); nextAttr; - nextAttr = nextAttr->getNext()) { - if (nextAttr->getKind() == AttributeList::AT_dllexport) { - S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "dllimport"; - return; - } - } - if (D->getAttr<DLLExportAttr>()) { S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "dllimport"; return; @@ -228,6 +218,11 @@ static void HandleDLLExportAttr(Decl *D, const AttributeList &Attr, Sema &S) { return; } + if (DLLImportAttr *Import = D->getAttr<DLLImportAttr>()) { + S.Diag(Import->getLocation(), diag::warn_attribute_ignored) << "dllimport"; + D->dropAttr<DLLImportAttr>(); + } + D->addAttr(::new (S.Context) DLLExportAttr(Attr.getLoc(), S.Context)); } |