OSDN Git Service

cexp.y (warn_undef): New variable.
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 13 Apr 1997 16:49:45 +0000 (16:49 +0000)
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 13 Apr 1997 16:49:45 +0000 (16:49 +0000)
(exp): Optionally warn about undefined identifiers that evaluate to 0.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@13877 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cexp.y

index 2d2d34f..133539f 100644 (file)
@@ -164,6 +164,9 @@ extern int traditional;
 /* Flag for -lang-c89.  */
 extern int c89;
 
+/* Flag for -Wundef.  */
+extern int warn_undef;
+
 #ifndef CHAR_TYPE_SIZE
 #define CHAR_TYPE_SIZE BITS_PER_UNIT
 #endif
@@ -445,7 +448,10 @@ exp        :       exp '*' exp
        |       CHAR
                        { $$ = yylval.integer; }
        |       NAME
-                       { $$.value = 0;
+                       { if (warn_undef && !skip_evaluation)
+                           warning ("`%.*s' is not defined",
+                                    $1.length, $1.address);
+                         $$.value = 0;
                          $$.signedp = SIGNED; }
        ;