]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-family: Fix up -fno-debug-cpp [PR111965]
authorJakub Jelinek <jakub@redhat.com>
Thu, 7 Dec 2023 08:47:54 +0000 (09:47 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 7 Dec 2023 08:47:54 +0000 (09:47 +0100)
As can be seen in the second testcase, -fno-debug-cpp is actually
implemented the same as -fdebug-cpp and so doesn't turn the debugging
off.

The following patch fixes that.

2023-12-07  Andrew Pinski  <pinskia@gmail.com>
    Jakub Jelinek  <jakub@redhat.com>

PR preprocessor/111965
gcc/c-family/
* c-opts.cc (c_common_handle_option) <case OPT_fdebug_cpp>: Set
cpp_opts->debug to value rather than 1.
gcc/testsuite/
* gcc.dg/cpp/pr111965-1.c: New test.
* gcc.dg/cpp/pr111965-2.c: New test.

gcc/c-family/c-opts.cc
gcc/testsuite/gcc.dg/cpp/pr111965-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/pr111965-2.c [new file with mode: 0644]

index 60aa7c5fd4303a90dd466f284470a426191effce..0399899387f7a86a54fb63f0689873a98ba5d15d 100644 (file)
@@ -532,7 +532,7 @@ c_common_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
       break;
 
     case OPT_fdebug_cpp:
-      cpp_opts->debug = 1;
+      cpp_opts->debug = value;
       break;
 
     case OPT_ftrack_macro_expansion:
diff --git a/gcc/testsuite/gcc.dg/cpp/pr111965-1.c b/gcc/testsuite/gcc.dg/cpp/pr111965-1.c
new file mode 100644 (file)
index 0000000..9790055
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR preprocessor/111965
+   { dg-do preprocess }
+   { dg-options "-fdebug-cpp" }
+   { dg-final { scan-file pr111965-1.i "P:<built-in>;F:<NULL>;" } } */
+int x;
diff --git a/gcc/testsuite/gcc.dg/cpp/pr111965-2.c b/gcc/testsuite/gcc.dg/cpp/pr111965-2.c
new file mode 100644 (file)
index 0000000..44f3012
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR preprocessor/111965
+   { dg-do preprocess }
+   { dg-options "-fdebug-cpp -fno-debug-cpp" }
+   { dg-final { scan-file-not pr111965-2.i "P:<built-in>;F:<NULL>;" } } */
+int x;