[PATCH] D122983: [C11/C2x] Change the behavior of the implicit function declaration warning

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 5 13:45:05 PDT 2022


erichkeane added a comment.

In D122983#3427518 <https://reviews.llvm.org/D122983#3427518>, @xbolva00 wrote:

> Could you please check that https://github.com/llvm/llvm-test-suite is buildable with your patch?

Aaron wasn't able to get this working on his system, but I was.  I ended up collecting the following errors (though, if the build ended early and my workaround of adding the flag failed, i likely missed others):

  /iusers/ekeane1/workspaces/test-suite-build/tools/timeit --summary MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o.time /iusers/ekeane1/workspaces/llvm-project2/build/bin/clang -DNDEBUG  -O3   -w -Werror=date-time -D__USE_MISC -D__USE_GNU -D__USE_SVID -D__USE_XOPEN_EXTENDED -D__USE_XOPEN -Dunix -MD -MT MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o -MF MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o.d -o MultiSource/Applications/siod/CMakeFiles/siod.dir/slibu.c.o   -c /iusers/ekeane1/workspaces/test-suite/MultiSource/Applications/siod/slibu.c
  /iusers/ekeane1/workspaces/test-suite/MultiSource/Applications/siod/slibu.c:1720:6: error: implicit declaration of function 'strptime' is invalid in C99 and later and unsupported in C2x [-Wimplicit-function-declaration]
   if (strptime(get_c_string(str),get_c_string(fmt),&tm))
       ^
  1 error generated.
  
  
  
  
  /iusers/ekeane1/workspaces/test-suite-build/tools/timeit --summary MultiSource/Benchmarks/Prolangs-C/plot2fig/CMakeFiles/plot2fig.dir/fontname.c.o.time /iusers/ekeane1/workspaces/llvm-project2/build/bin/clang -DNDEBUG  -O3   -w -Werror=date-time -MD -MT MultiSource/Benchmarks/Prolangs-C/plot2fig/CMakeFiles/plot2fig.dir/fontname.c.o -MF MultiSource/Benchmarks/Prolangs-C/plot2fig/CMakeFiles/plot2fig.dir/fontname.c.o.d -o MultiSource/Benchmarks/Prolangs-C/plot2fig/CMakeFiles/plot2fig.dir/fontname.c.o   -c /iusers/ekeane1/workspaces/test-suite/MultiSource/Benchmarks/Prolangs-C/plot2fig/fontname.c
  /iusers/ekeane1/workspaces/test-suite/MultiSource/Benchmarks/Prolangs-C/plot2fig/fontname.c:98:18: error: implicit declaration of function 're_comp' is invalid in C99 and later and unsupported in C2x [-Wimplicit-function-declaration]
    res = (char *) re_comp (s);
                   ^
  /iusers/ekeane1/workspaces/test-suite/MultiSource/Benchmarks/Prolangs-C/plot2fig/fontname.c:106:7: error: implicit declaration of function 're_exec' is invalid in C99 and later and unsupported in C2x [-Wimplicit-function-declaration]
    if (re_exec("typewriter")
        ^
  2 errors generated.
  
  
  
  /iusers/ekeane1/workspaces/test-suite-build/tools/timeit --summary MultiSource/Benchmarks/Prolangs-C/archie-client/CMakeFiles/archie.dir/dirsend.c.o.time /iusers/ekeane1/workspaces/llvm-project2/build/bin/clang -DNDEBUG -I/iusers/ekeane1/workspaces/test-suite/MultiSource/Benchmarks/Prolangs-C/archie-client -O3   -w -Werror=date-time -MD -MT MultiSource/Benchmarks/Prolangs-C/archie-client/CMakeFiles/archie.dir/dirsend.c.o -MF MultiSource/Benchmarks/Prolangs-C/archie-client/CMakeFiles/archie.dir/dirsend.c.o.d -o MultiSource/Benchmarks/Prolangs-C/archie-client/CMakeFiles/archie.dir/dirsend.c.o   -c /iusers/ekeane1/workspaces/test-suite/MultiSource/Benchmarks/Prolangs-C/archie-client/dirsend.c
  /iusers/ekeane1/workspaces/test-suite/MultiSource/Benchmarks/Prolangs-C/archie-client/dirsend.c:298:17: error: implicit declaration of function 'time' is invalid in C99 and later and unsupported in C2x [-Wimplicit-function-declaration]
          srand(getpid()+time(0)); /* XXX: arg ok, but not right type. */
                         ^
  1 error generated.
  
  
  /iusers/ekeane1/workspaces/test-suite-build/tools/timeit --summary MultiSource/Benchmarks/MiBench/office-ispell/CMakeFiles/office-ispell.dir/term.c.o.time /iusers/ekeane1/workspaces/llvm-project2/build/bin/clang -DNDEBUG  -O3   -w -Werror=date-time -Dconst= -MD -MT MultiSource/Benchmarks/MiBench/office-ispell/CMakeFiles/office-ispell.dir/term.c.o -MF MultiSource/Benchmarks/MiBench/office-ispell/CMakeFiles/office-ispell.dir/term.c.o.d -o MultiSource/Benchmarks/MiBench/office-ispell/CMakeFiles/office-ispell.dir/term.c.o   -c /iusers/ekeane1/workspaces/test-suite/MultiSource/Benchmarks/MiBench/office-ispell/term.c
  /iusers/ekeane1/workspaces/test-suite/MultiSource/Benchmarks/MiBench/office-ispell/term.c:519:9: error: implicit declaration of function 'wait' is invalid in C99 and later and unsupported in C2x [-Wimplicit-function-declaration]
          while (wait (&termstat) != i)
                 ^
  1 error generated.
  
  
  /iusers/ekeane1/workspaces/test-suite-build/tools/timeit --summary SingleSource/Regression/C/gcc-c-torture/execute/CMakeFiles/GCC-C-execute-cmpsi-1.dir/cmpsi-1.c.o.time /iusers/ekeane1/workspaces/llvm-project2/build/bin/clang -DNDEBUG  -O3   -w -Werror=date-time -w -MD -MT SingleSource/Regression/C/gcc-c-torture/execute/CMakeFiles/GCC-C-execute-cmpsi-1.dir/cmpsi-1.c.o -MF SingleSource/Regression/C/gcc-c-torture/execute/CMakeFiles/GCC-C-execute-cmpsi-1.dir/cmpsi-1.c.o.d -o SingleSource/Regression/C/gcc-c-torture/execute/CMakeFiles/GCC-C-execute-cmpsi-1.dir/cmpsi-1.c.o   -c /iusers/ekeane1/workspaces/test-suite/SingleSource/Regression/C/gcc-c-torture/execute/cmpsi-1.c
  /iusers/ekeane1/workspaces/test-suite/SingleSource/Regression/C/gcc-c-torture/execute/cmpsi-1.c:4:5: error: implicit declaration of function 'dummy' is invalid in C99 and later and unsupported in C2x [-Wimplicit-function-declaration]
      dummy ();
      ^
  /iusers/ekeane1/workspaces/test-suite/SingleSource/Regression/C/gcc-c-torture/execute/cmpsi-1.c:15:5: error: implicit declaration of function 'dummy' is invalid in C99 and later and unsupported in C2x [-Wimplicit-function-declaration]
      dummy ();
      ^
  2 errors generated.

With the following 'diff', I was able to get through these:

  [ekeane1 at scsel-clx-24 test-suite]$ git diff
  diff --git a/MultiSource/Applications/siod/CMakeLists.txt b/MultiSource/Applications/siod/CMakeLists.txt
  index a562f50d..6473e22e 100644
  --- a/MultiSource/Applications/siod/CMakeLists.txt
  +++ b/MultiSource/Applications/siod/CMakeLists.txt
  @@ -1,4 +1,4 @@
  -list(APPEND CPPFLAGS -D__USE_MISC -D__USE_GNU -D__USE_SVID -D__USE_XOPEN_EXTENDED -D__USE_XOPEN -Dunix)
  +list(APPEND CPPFLAGS -D__USE_MISC -D__USE_GNU -D__USE_SVID -D__USE_XOPEN_EXTENDED -D__USE_XOPEN -Dunix -Wno-implicit-function-declaration)
   list(APPEND LDFLAGS -lm)
   set(RUN_OPTIONS -v1 test.scm)
   llvm_multisource(siod)
  diff --git a/MultiSource/Benchmarks/MiBench/office-ispell/CMakeLists.txt b/MultiSource/Benchmarks/MiBench/office-ispell/CMakeLists.txt
  index 13920af8..a102311b 100644
  --- a/MultiSource/Benchmarks/MiBench/office-ispell/CMakeLists.txt
  +++ b/MultiSource/Benchmarks/MiBench/office-ispell/CMakeLists.txt
  @@ -1,4 +1,4 @@
  -list(APPEND CPPFLAGS -Dconst=)
  +list(APPEND CPPFLAGS  -Wno-implicit-function-declaration -Dconst=)
   list(APPEND LDFLAGS -lm)
   set(RUN_OPTIONS -a -d americanmed+ < large.txt)
   llvm_multisource(office-ispell)
  diff --git a/MultiSource/Benchmarks/Prolangs-C/archie-client/CMakeLists.txt b/MultiSource/Benchmarks/Prolangs-C/archie-client/CMakeLists.txt
  index bf3b189b..f939f2a3 100644
  --- a/MultiSource/Benchmarks/Prolangs-C/archie-client/CMakeLists.txt
  +++ b/MultiSource/Benchmarks/Prolangs-C/archie-client/CMakeLists.txt
  @@ -1,4 +1,5 @@
   include(CheckFunctionExists)
  +list(APPEND CPPFLAGS -Wno-implicit-function-declaration)
   check_function_exists(re_comp HAVE_RE_COMP)
  
   if(HAVE_RE_COMP)
  diff --git a/MultiSource/Benchmarks/Prolangs-C/plot2fig/CMakeLists.txt b/MultiSource/Benchmarks/Prolangs-C/plot2fig/CMakeLists.txt
  index 06090ee0..c7019582 100644
  --- a/MultiSource/Benchmarks/Prolangs-C/plot2fig/CMakeLists.txt
  +++ b/MultiSource/Benchmarks/Prolangs-C/plot2fig/CMakeLists.txt
  @@ -1,5 +1,6 @@
   include(CheckFunctionExists)
   check_function_exists(re_comp HAVE_RE_COMP)
  +list(APPEND CPPFLAGS -Wno-implicit-function-declaration)
   if(HAVE_RE_COMP)
     list(APPEND LDFLAGS -lm)
     llvm_multisource(plot2fig)
  diff --git a/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt b/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt
  index 4daf07e7..d95836af 100644
  --- a/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt
  +++ b/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt
  @@ -1,7 +1,7 @@
   add_subdirectory(ieee)
  
   # GCC C Torture Suite is conventionally run without warnings
  -list(APPEND CFLAGS "-w")
  +list(APPEND CFLAGS  -Wno-implicit-function-declaration "-w")
  
   set(TestsToSkip)
  
  [ekeane1 at scsel-clx-24 test-suite]$

I note that we likely cannot add those until the flag is added to 'clang', so either these changes need to happen at the same time, or we need to add the clang-warning-flag WITHOUT this patch's changes, THEN add these changes to the cmake lists, THEN add the rest of this patch.  (Or some variety of other things).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122983/new/

https://reviews.llvm.org/D122983



More information about the cfe-commits mailing list