c-family: Fix up -fno-debug-cpp [PR111965]

Message ID ZXF6Afn0+K3Mx+I7@tucnak
State Unresolved
Headers
Series c-family: Fix up -fno-debug-cpp [PR111965] |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Jakub Jelinek Dec. 7, 2023, 7:53 a.m. UTC
  Hi!

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.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

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.


	Jakub
  

Comments

Richard Biener Dec. 7, 2023, 8:01 a.m. UTC | #1
On Thu, Dec 7, 2023 at 8:54 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> 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.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK

> 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.jj   2023-12-05 09:06:05.867881859 +0100
> +++ gcc/c-family/c-opts.cc      2023-12-06 18:02:20.445469185 +0100
> @@ -532,7 +532,7 @@ c_common_handle_option (size_t scode, co
>        break;
>
>      case OPT_fdebug_cpp:
> -      cpp_opts->debug = 1;
> +      cpp_opts->debug = value;
>        break;
>
>      case OPT_ftrack_macro_expansion:
> --- gcc/testsuite/gcc.dg/cpp/pr111965-1.c.jj    2023-12-06 17:54:03.696424916 +0100
> +++ gcc/testsuite/gcc.dg/cpp/pr111965-1.c       2023-12-06 18:01:32.341142764 +0100
> @@ -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;
> --- gcc/testsuite/gcc.dg/cpp/pr111965-2.c.jj    2023-12-06 17:59:36.953758477 +0100
> +++ gcc/testsuite/gcc.dg/cpp/pr111965-2.c       2023-12-06 18:01:27.147215490 +0100
> @@ -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;
>
>         Jakub
>
  
Marek Polacek Dec. 7, 2023, 3:59 p.m. UTC | #2
On Thu, Dec 07, 2023 at 08:53:37AM +0100, Jakub Jelinek wrote:
> Hi!
> 
> 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.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok, thanks.
 
> 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.jj	2023-12-05 09:06:05.867881859 +0100
> +++ gcc/c-family/c-opts.cc	2023-12-06 18:02:20.445469185 +0100
> @@ -532,7 +532,7 @@ c_common_handle_option (size_t scode, co
>        break;
>  
>      case OPT_fdebug_cpp:
> -      cpp_opts->debug = 1;
> +      cpp_opts->debug = value;
>        break;
>  
>      case OPT_ftrack_macro_expansion:
> --- gcc/testsuite/gcc.dg/cpp/pr111965-1.c.jj	2023-12-06 17:54:03.696424916 +0100
> +++ gcc/testsuite/gcc.dg/cpp/pr111965-1.c	2023-12-06 18:01:32.341142764 +0100
> @@ -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;
> --- gcc/testsuite/gcc.dg/cpp/pr111965-2.c.jj	2023-12-06 17:59:36.953758477 +0100
> +++ gcc/testsuite/gcc.dg/cpp/pr111965-2.c	2023-12-06 18:01:27.147215490 +0100
> @@ -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;
> 
> 	Jakub
> 

Marek
  

Patch

--- gcc/c-family/c-opts.cc.jj	2023-12-05 09:06:05.867881859 +0100
+++ gcc/c-family/c-opts.cc	2023-12-06 18:02:20.445469185 +0100
@@ -532,7 +532,7 @@  c_common_handle_option (size_t scode, co
       break;
 
     case OPT_fdebug_cpp:
-      cpp_opts->debug = 1;
+      cpp_opts->debug = value;
       break;
 
     case OPT_ftrack_macro_expansion:
--- gcc/testsuite/gcc.dg/cpp/pr111965-1.c.jj	2023-12-06 17:54:03.696424916 +0100
+++ gcc/testsuite/gcc.dg/cpp/pr111965-1.c	2023-12-06 18:01:32.341142764 +0100
@@ -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;
--- gcc/testsuite/gcc.dg/cpp/pr111965-2.c.jj	2023-12-06 17:59:36.953758477 +0100
+++ gcc/testsuite/gcc.dg/cpp/pr111965-2.c	2023-12-06 18:01:27.147215490 +0100
@@ -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;