LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 24925 - [ms] Poor diagnostic when having __declspec and __attribute__ in the wrong order
Summary: [ms] Poor diagnostic when having __declspec and __attribute__ in the wrong order
Status: RESOLVED DUPLICATE of bug 24559
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-24 09:38 PDT by Nico Weber
Modified: 2015-09-24 09:41 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nico Weber 2015-09-24 09:38:30 PDT
$ cat test2.cc
class __declspec(dllexport)
    __attribute__((annotate("blink_gc_plugin_ignore"))) Foo {};


$ bin/clang-cl -c test2.cc
test2.cc(1,1) :  error: declaration of anonymous class must be a definition
class __declspec(dllexport)
^
test2.cc(1,1) :  warning: declaration does not declare anything [-Wmissing-declarations]
class __declspec(dllexport)
^
1 warning and 1 error generated.


In real life, this causes several cascading errors [1]. We should detect this and say "__declspec must come before __attribute__" or something like that. (Or we could allow interleaving declspecs and attributes – these are usually hidden behind macros, and having to know which macros happen to be declspecs and which are attributes is a bit annoying. On the other hand, it's nice that this enforces a consistent ordering. On the third hand, this consistent ordering isn't enforced if you have two attribute-based macros or two declspec-based ones)


1: The diagnostic we got on our bots:
FAILED: ninja -t msvc -e environment.x86 -- "..\..\third_party/llvm-build/Release+Asserts/bin/clang-cl" -m32 /nologo /showIncludes /FC @obj\third_party\WebKit\Source\core\animation\webcore_shared.DeferredLegacyStyleInterpolation.obj.rsp /c ..\..\third_party\WebKit\Source\core\animation\DeferredLegacyStyleInterpolation.cpp /Foobj\third_party\WebKit\Source\core\animation\webcore_shared.DeferredLegacyStyleInterpolation.obj /Fdobj\third_party\WebKit\Source\core\webcore_shared.cc.pdb 
In file included from ..\..\third_party\WebKit\Source\core\animation\DeferredLegacyStyleInterpolation.cpp:10:
..\..\third_party\WebKit\Source\core/css/CSSBasicShapeValue.h(46,1) : error: declaration of anonymous class must be a definition
class CORE_EXPORT GC_PLUGIN_IGNORE("535448") CSSBasicShapeValue : public CSSValue {
^
..\..\third_party\WebKit\Source\core/css/CSSBasicShapeValue.h(46,1) : error: declaration does not declare anything [-Werror,-Wmissing-declarations]
class CORE_EXPORT GC_PLUGIN_IGNORE("535448") CSSBasicShapeValue : public CSSValue {
^
..\..\third_party\WebKit\Source\core/css/CSSBasicShapeValue.h(78,47) : error: base class has incomplete type
class CSSBasicShapeCircleValue final : public CSSBasicShapeValue {
                                       ~~~~~~~^~~~~~~~~~~~~~~~~~
..\..\third_party\WebKit\Source\core/animation/DeferredLegacyStyleInterpolation.h(15,7) :  note: forward declaration of 'blink::CSSBasicShapeValue'
class CSSBasicShapeValue;
      ^
Comment 1 Aaron Ballman 2015-09-24 09:41:22 PDT

*** This bug has been marked as a duplicate of bug 24559 ***