[llvm-bugs] [Bug 34304] New: attribute ignored is a warning with gcc, an error with clang

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 23 15:12:55 PDT 2017


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

            Bug ID: 34304
           Summary: attribute ignored is a warning with gcc, an error with
                    clang
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sylvestre at debian.org
                CC: llvm-bugs at lists.llvm.org

This impacts a lot of qt programs:
http://clang.debian.net/status.php?version=5.0&key=NO_DISCARD_ATTRIBUTE

Simple example:
int a [[]];
int & [[nodiscard]] b = a;

$ clang++ -std=c++11 -c foo.cpp
foo.cpp:2:9: error: 'nodiscard' attribute cannot be applied to types
int & [[nodiscard]] b = a;
        ^
1 error generated.

$ g++ -std=c++11 -c foo.cpp
foo.cpp:2:20: warning: attribute ignored [-Wattributes]
 int & [[nodiscard]] b = a;
                    ^
foo.cpp:2:20: note: an attribute that appertains to a type-specifier is ignored

As we see clang as a drop-in replacement of gcc, maybe we should not trigger an
error here.

-- 
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/20170823/d0346bbb/attachment.html>


More information about the llvm-bugs mailing list