This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/81779] New: bool define from stdbool.h suppresses -Wdeclaration-after-statement


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

            Bug ID: 81779
           Summary: bool define from stdbool.h suppresses
                    -Wdeclaration-after-statement
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sirl at gcc dot gnu.org
  Target Milestone: ---

This testcase warns only once with -Wdeclaration-after-statement since at least
gcc-4.8:

#include <stdbool.h>

bool f2(char *pRedo)
{
        if (!pRedo)
                return false;

        bool ret = true;
        return ret;
}

int f3(char *pRedo)
{
        if (!pRedo)
                return 0;

        int ret = 1;
        return ret;
}

# gcc-7 -c -Wdeclaration-after-statement Wdeclaration-after-statement.c
Wdeclaration-after-statement.c: In function 'f3':
Wdeclaration-after-statement.c:18:2: warning: ISO C90 forbids mixed
declarations and code [-Wdeclaration-after-statement]
  int ret = 1;
  ^~~

gcc-4.4 warned 2 for both occurences:
# gcc-4.4 -c -Wdeclaration-after-statement Wdeclaration-after-statement.c
Wdeclaration-after-statement.c: In function 'f2':
Wdeclaration-after-statement.c:10: warning: ISO C90 forbids mixed declarations
and code
Wdeclaration-after-statement.c: In function 'f3':
Wdeclaration-after-statement.c:17: warning: ISO C90 forbids mixed declarations
and code

Adding -Wsystem-headers shows 2 warnings also with newer GCC, but I don't think
that this option should influence -Wdeclaration-after-statement.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]