[ms] Poor diagnostic when having __declspec and __attribute__ in the wrong order #25299
Labels
bugzilla
Issues migrated from bugzilla
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
duplicate
Resolved as duplicate
Extended Description
$ 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;
^
The text was updated successfully, but these errors were encountered: