https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65377
Bug ID: 65377
Summary: [5.0 Regression] cpp attribute check ala clang fails
to compile
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: npl at chello dot at
The following code fails to compile with gcc-5-20150301, gcc 4.8.4 and 4.9.2
are fine.
The command used is simply "gcc test.c"
--------------------
#ifndef __has_cpp_attribute // Optional of course.
# define __has_cpp_attribute(x) 0 // Compatibility with non-clang compilers.
#endif
#if __has_cpp_attribute(clang::fallthrough) || (defined(__clang__) &&
__clang_major__ >= 4 || (__clang_major__ == 3 &&__clang_minor__ >= 3))
# define FALLTHROUGH [[clang::fallthrough]];
#else
# define FALLTHROUGH
#endif
int main()
{
}
--------------------
Error Message is:
test.c:5:30: error: missing ')' after "__has_attribute"
#if __has_cpp_attribute(clang::fallthrough) || (defined(__clang__) &&
__clang_major__ >= 4 || (__clang_major__ == 3 &&__clang_minor__ >= 3))
^
test.c:5:31: error: ':' without preceding '?'
#if __has_cpp_attribute(clang::fallthrough) || (defined(__clang__) &&
__clang_major__ >= 4 || (__clang_major__ == 3 &&__clang_minor__ >= 3))
^