[clang] 786954d - Accept -fno-knr-functions as a driver flag as well

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 30 10:38:04 PDT 2022


Author: Aaron Ballman
Date: 2022-04-30T13:37:55-04:00
New Revision: 786954db06ab253dbd62d059036e06f6bbd9223c

URL: https://github.com/llvm/llvm-project/commit/786954db06ab253dbd62d059036e06f6bbd9223c
DIFF: https://github.com/llvm/llvm-project/commit/786954db06ab253dbd62d059036e06f6bbd9223c.diff

LOG: Accept -fno-knr-functions as a driver flag as well

Due to a think-o, it was only being accepted as a -cc1 flag. This adds
the proper forwarding from the driver to the frontend and adds test
coverage for the option.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/no-knr-functions.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index c5f38762a5d61..388a29261a720 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5311,6 +5311,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   if (Freestanding)
     CmdArgs.push_back("-ffreestanding");
 
+  Args.AddLastArg(CmdArgs, options::OPT_fno_knr_functions);
+
   // This is a coarse approximation of what llvm-gcc actually does, both
   // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more
   // complicated ways.

diff  --git a/clang/test/Driver/no-knr-functions.c b/clang/test/Driver/no-knr-functions.c
index 99f397d38d626..5ebcc8916be67 100644
--- a/clang/test/Driver/no-knr-functions.c
+++ b/clang/test/Driver/no-knr-functions.c
@@ -7,5 +7,9 @@
 // RUN: not %clang -fknr-functions -x c %s 2>&1 | FileCheck --check-prefixes=POS %s
 // RUN: not %clang -fknr-functions -std=c89 -x c %s 2>&1 | FileCheck --check-prefixes=POS %s
 
+// Ensure that the driver flag is actually accepted though.
+// RUN: %clang -fno-knr-functions -### %s 2>&1 | FileCheck --check-prefixes=ACCEPTED %s
+
 // NONO: error: unknown argument: '-fno-no-knr-functions'
 // POS: error: unknown argument: '-fknr-functions'
+// ACCEPTED-NOT: warning: argument unused during compilation: '-fno-knr-functions'


        


More information about the cfe-commits mailing list