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/67488] New: Incorrect error message on call of nested functions


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

            Bug ID: 67488
           Summary: Incorrect error message on call of nested functions
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com
  Target Milestone: ---

The function 'f' is declared locally in a function scope, and then called
outside. GCC emits an error that 'f' has incompatible declarations. I wonder
whether this message could be improved by pinpointing the root cause, like
Clang.


$: cat t.c
void g() {
  void f(void);
}
void k() {f();}
$: clang-trunk -c t.c
t.c:4:11: warning: use of out-of-scope declaration of 'f'
void k() {f();}
          ^
t.c:2:8: note: previous declaration is here
  void f(void);
       ^
1 warning generated.
$: gcc-trunk -c t.c
t.c: In function âkâ:
t.c:4:11: warning: implicit declaration of function âfâ
[-Wimplicit-function-declaration]
 void k() {f();}
           ^
t.c:2:8: note: previous declaration of âfâ was here
   void f(void);
        ^
t.c:4:11: error: incompatible implicit declaration of function âfâ
 void k() {f();}
           ^
t.c:2:8: note: previous implicit declaration of âfâ was here
   void f(void);
        ^
$: 
$: gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror
--with-gmp=/usr/local/gcc-trunk --with-mpfr=/usr/local/gcc-trunk
--with-mpc=/usr/local/gcc-trunk --with-cloog=/usr/local/gcc-trunk
--prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 6.0.0 20150907 (experimental) [trunk revision 227515] (GCC) 
$:

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