[llvm-bugs] [Bug 24925] New: [ms] Poor diagnostic when having __declspec and __attribute__ in the wrong order

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 24 07:38:30 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24925

            Bug ID: 24925
           Summary: [ms] Poor diagnostic when having __declspec and
                    __attribute__ in the wrong order
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

$ 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;
      ^

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150924/3986edbc/attachment.html>


More information about the llvm-bugs mailing list