diff mbox

[libcpp] modify undef diagnostic

Message ID CAJXstsCYvNfocx_ztDO4qeH7o+h_6D31fbuBMuUx2Ns4sDorew@mail.gmail.com
State New
Headers show

Commit Message

Prathamesh Kulkarni April 29, 2014, 3:28 p.m. UTC
Append "evaluates to 0", in Wundef diagnostic.

clang prints the following diagnostic for -Wundef:
undef.c:1:5: warning: 'FOO' is not defined, evaluates to 0 [-Wundef]
#if FOO
    ^
OK to commit ?

[libcpp]
* expr.c (eval_token): Modify Wundef diagnostic.

[gcc/testsuite/gcc.dg/cpp]
* warn-undef.c: Append "evaluates to 0" to dg-warning.
* warn-undef-2.c: Append "evaluates to 0" to dg-error.

Thanks and Regards,
Prathamesh

Comments

Jeff Law May 19, 2014, 7:02 p.m. UTC | #1
On 04/29/14 09:28, Prathamesh Kulkarni wrote:
> Append "evaluates to 0", in Wundef diagnostic.
>
> clang prints the following diagnostic for -Wundef:
> undef.c:1:5: warning: 'FOO' is not defined, evaluates to 0 [-Wundef]
> #if FOO
>      ^
> OK to commit ?
>
> [libcpp]
> * expr.c (eval_token): Modify Wundef diagnostic.
>
> [gcc/testsuite/gcc.dg/cpp]
> * warn-undef.c: Append "evaluates to 0" to dg-warning.
> * warn-undef-2.c: Append "evaluates to 0" to dg-error.
OK for the trunk assuming there's no testsuite regresssions with your patch.

jeff
diff mbox

Patch

Index: libcpp/expr.c
===================================================================
--- libcpp/expr.c	(revision 209800)
+++ libcpp/expr.c	(working copy)
@@ -1054,7 +1054,7 @@  eval_token (cpp_reader *pfile, const cpp
 	  result.low = 0;
 	  if (CPP_OPTION (pfile, warn_undef) && !pfile->state.skip_eval)
 	    cpp_warning_with_line (pfile, CPP_W_UNDEF, virtual_location, 0,
-				   "\"%s\" is not defined",
+				   "\"%s\" is not defined, evaluates to 0",
 				   NODE_NAME (token->val.node.node));
 	}
       break;
Index: gcc/testsuite/gcc.dg/cpp/warn-undef-2.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/warn-undef-2.c	(revision 209800)
+++ gcc/testsuite/gcc.dg/cpp/warn-undef-2.c	(working copy)
@@ -1,5 +1,5 @@ 
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=undef" }
 /* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-#if x  // { dg-error "\"x\" is not defined .-Werror=undef." }
+#if x  // { dg-error "\"x\" is not defined, evaluates to 0 .-Werror=undef." }
 #endif
Index: gcc/testsuite/gcc.dg/cpp/warn-undef.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/warn-undef.c	(revision 209800)
+++ gcc/testsuite/gcc.dg/cpp/warn-undef.c	(working copy)
@@ -1,5 +1,5 @@ 
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Wundef" }
 
-#if x  // { dg-warning "\"x\" is not defined .-Wundef." }
+#if x  // { dg-warning "\"x\" is not defined, evaluates to 0 .-Wundef." }
 #endif