public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/65377] New: [5.0 Regression] cpp attribute check ala clang fails to compile
@ 2015-03-10 10:40 npl at chello dot at
  2015-03-10 10:44 ` [Bug c/65377] " mpolacek at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: npl at chello dot at @ 2015-03-10 10:40 UTC (permalink / raw)
  To: gcc-bugs

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))
                               ^


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/65377] [5.0 Regression] cpp attribute check ala clang fails to compile
  2015-03-10 10:40 [Bug c/65377] New: [5.0 Regression] cpp attribute check ala clang fails to compile npl at chello dot at
@ 2015-03-10 10:44 ` mpolacek at gcc dot gnu.org
  2015-03-10 10:46 ` trippels at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-03-10 10:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65377

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Why should it?  We don't define __clang_major__.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/65377] [5.0 Regression] cpp attribute check ala clang fails to compile
  2015-03-10 10:40 [Bug c/65377] New: [5.0 Regression] cpp attribute check ala clang fails to compile npl at chello dot at
  2015-03-10 10:44 ` [Bug c/65377] " mpolacek at gcc dot gnu.org
@ 2015-03-10 10:46 ` trippels at gcc dot gnu.org
  2015-03-10 10:52 ` npl at chello dot at
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-03-10 10:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65377

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |trippels at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #2 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
If you want to compile C++ use g++.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/65377] [5.0 Regression] cpp attribute check ala clang fails to compile
  2015-03-10 10:40 [Bug c/65377] New: [5.0 Regression] cpp attribute check ala clang fails to compile npl at chello dot at
  2015-03-10 10:44 ` [Bug c/65377] " mpolacek at gcc dot gnu.org
  2015-03-10 10:46 ` trippels at gcc dot gnu.org
@ 2015-03-10 10:52 ` npl at chello dot at
  2015-03-10 10:59 ` trippels at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: npl at chello dot at @ 2015-03-10 10:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65377

npl at chello dot at changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |---

--- Comment #3 from npl at chello dot at ---
1) It simply shouldnt fail.
2) this is a generic header for C and C++.

__has_cpp_attribute(clang::fallthrough) should resolve to 0 and not fail. This
is a bug in gcc, unless you can explain why it shouldnt resolve to 0.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/65377] [5.0 Regression] cpp attribute check ala clang fails to compile
  2015-03-10 10:40 [Bug c/65377] New: [5.0 Regression] cpp attribute check ala clang fails to compile npl at chello dot at
                   ` (2 preceding siblings ...)
  2015-03-10 10:52 ` npl at chello dot at
@ 2015-03-10 10:59 ` trippels at gcc dot gnu.org
  2015-03-10 11:01 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-03-10 10:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65377

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
even "clang test.c" fails. Either rename it to test.cpp or use g++.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/65377] [5.0 Regression] cpp attribute check ala clang fails to compile
  2015-03-10 10:40 [Bug c/65377] New: [5.0 Regression] cpp attribute check ala clang fails to compile npl at chello dot at
                   ` (3 preceding siblings ...)
  2015-03-10 10:59 ` trippels at gcc dot gnu.org
@ 2015-03-10 11:01 ` pinskia at gcc dot gnu.org
  2015-03-10 11:02 ` npl at chello dot at
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-03-10 11:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65377

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Use the proper check if you are want check if you are compiling c++ code first.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/65377] [5.0 Regression] cpp attribute check ala clang fails to compile
  2015-03-10 10:40 [Bug c/65377] New: [5.0 Regression] cpp attribute check ala clang fails to compile npl at chello dot at
                   ` (4 preceding siblings ...)
  2015-03-10 11:01 ` pinskia at gcc dot gnu.org
@ 2015-03-10 11:02 ` npl at chello dot at
  2015-03-10 11:07 ` trippels at gcc dot gnu.org
  2015-03-10 11:19 ` npl at chello dot at
  7 siblings, 0 replies; 9+ messages in thread
From: npl at chello dot at @ 2015-03-10 11:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65377

--- Comment #6 from npl at chello dot at ---
(In reply to npl from comment #3)
> 1) It simply shouldnt fail.
> 2) this is a generic header for C and C++.
> 
> __has_cpp_attribute(clang::fallthrough) should resolve to 0 and not fail.
> This is a bug in gcc, unless you can explain why it shouldnt resolve to 0.

I think gcc should simply ignore the __has_cpp_attribute macro, unless it does
compile C++ code?
if I use other names than __has_cpp_attribute it compiles. I will put some C++
guards around this code, but I still think this is a bug?

(And I am compiling with Clang 3.4, but this doesnt support the feature check)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/65377] [5.0 Regression] cpp attribute check ala clang fails to compile
  2015-03-10 10:40 [Bug c/65377] New: [5.0 Regression] cpp attribute check ala clang fails to compile npl at chello dot at
                   ` (5 preceding siblings ...)
  2015-03-10 11:02 ` npl at chello dot at
@ 2015-03-10 11:07 ` trippels at gcc dot gnu.org
  2015-03-10 11:19 ` npl at chello dot at
  7 siblings, 0 replies; 9+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-03-10 11:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65377

--- Comment #7 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Unfortunately https://gcc.gnu.org/ml/gcc-patches/2015-01/msg02357.html hasn't
been checked in yet.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/65377] [5.0 Regression] cpp attribute check ala clang fails to compile
  2015-03-10 10:40 [Bug c/65377] New: [5.0 Regression] cpp attribute check ala clang fails to compile npl at chello dot at
                   ` (6 preceding siblings ...)
  2015-03-10 11:07 ` trippels at gcc dot gnu.org
@ 2015-03-10 11:19 ` npl at chello dot at
  7 siblings, 0 replies; 9+ messages in thread
From: npl at chello dot at @ 2015-03-10 11:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65377

--- Comment #8 from npl at chello dot at ---
This (and the Iso recommendation) doesnt answer the question whether the
__has_cpp_attribute macro should be defined for C sources either (it seems
illogical to me).
Guess its undefined and not a bug, I wont bother you anymore =)


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-03-10 11:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-10 10:40 [Bug c/65377] New: [5.0 Regression] cpp attribute check ala clang fails to compile npl at chello dot at
2015-03-10 10:44 ` [Bug c/65377] " mpolacek at gcc dot gnu.org
2015-03-10 10:46 ` trippels at gcc dot gnu.org
2015-03-10 10:52 ` npl at chello dot at
2015-03-10 10:59 ` trippels at gcc dot gnu.org
2015-03-10 11:01 ` pinskia at gcc dot gnu.org
2015-03-10 11:02 ` npl at chello dot at
2015-03-10 11:07 ` trippels at gcc dot gnu.org
2015-03-10 11:19 ` npl at chello dot at

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).