paul-j-lucas / cdecl

Composing and deciphering C (or C++) declarations or casts, aka ‘‘gibberish.’’
GNU General Public License v3.0
90 stars 11 forks source link

FTBFS 12.0 #22

Closed jengelh closed 2 years ago

jengelh commented 2 years ago
gcc -DHAVE_CONFIG_H -I.  -I../lib -I../lib -I/include      -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g  -Wcast-align -Wconversion -Wextra -Wfloat-equal -Wimplicit-fallthrough -Wredundant-decls -Wshadow -Wsign-compare -Wsign-conversion -Wuninitialized -Wunreachable-code -Wunused -Wwrite-strings -c -o parser.o parser.c
In file included from c_ast.h:35,
                 from parser.y:36:
c_operator.h:243:1: warning: 'nodiscard' attribute ignored [-Wattributes]
  243 | bool c_oper_is_ambiguous( c_operator_t const *op ) {
      | ^~~~
In file included from c_operator.h:36:
c_operator.h:243:1: error: expected identifier or '(' before '_Bool'
  243 | bool c_oper_is_ambiguous( c_operator_t const *op ) {
      | ^~~~

The source at that location is

C_OPERATOR_H_INLINE NODISCARD
bool c_oper_is_ambiguous( c_operator_t const *op ) {
  return op->params_min == 0 && op->params_max == 2;
}

The culprit would appear to be:

config.h:# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]

Because this test snippet also wouldn't compile:

inline [[__nodiscard__]] void f(){}

result

x.c:1:1: warning: ‘nodiscard’ attribute ignored [-Wattributes]
    1 | inline [[__nodiscard__]] void f(){}
      | ^~~~~~
x.c:1:26: error: expected identifier or ‘(’ before ‘void’
    1 | inline [[__nodiscard__]] void f(){}
      |                          ^~~~

Compiler is

gcc version 12.1.1 20220721 [revision 4f15d2234608e82159d030dadb17af678cfad626] (SUSE Linux) 
paul-j-lucas commented 2 years ago

Try the following patch. (Remove the .txt extension first, then use patch.)

nodiscard.patch.txt

jengelh commented 2 years ago

attribute works, but I like putting [[nodiscard]] in the right place better :-p

paul-j-lucas commented 2 years ago

I misunderstood the issue. I thought it simply didn't understand __nodiscard__. I merged your PR. Thanks.

Since it's been less than 24 hours, I'll cheat and just force-move the 12.0 tag.