]> git.saurik.com Git - bison.git/commitdiff
diagnostics: factor the deprecated directive message
authorAkim Demaille <akim@lrde.epita.fr>
Sat, 15 Dec 2012 20:54:17 +0000 (21:54 +0100)
committerAkim Demaille <akim@lrde.epita.fr>
Sun, 23 Dec 2012 09:27:40 +0000 (10:27 +0100)
* src/complain.h, src/complain.c (deprecated_directive): New.
* src/muscle-tab.c: Use it.

src/complain.c
src/complain.h
src/scan-gram.l

index 984b13610d8297fe465962926634a9bd5f03c713..30d01bb2554e956687e810c79cf68e59c870cf3d 100644 (file)
@@ -28,6 +28,7 @@
 #include "complain.h"
 #include "files.h"
 #include "getargs.h"
+#include "quote.h"
 
 warnings warnings_flag =
   Wconflicts_sr | Wconflicts_rr | Wdeprecated  | Wother;
@@ -188,4 +189,18 @@ complain_args (location const *loc, warnings w, unsigned *indent,
     complain (loc, fatal, "too many arguments for complains");
     break;
   }
+
+}
+
+void
+deprecated_directive (location const *loc, char const *old, char const *upd)
+{
+  if (feature_flag & feature_caret)
+    complain (loc, Wdeprecated,
+              _("deprecated directive, use %s"),
+              quote_n (1, upd));
+  else
+    complain (loc, Wdeprecated,
+              _("deprecated directive: %s, use %s"),
+              quote (old), quote_n (1, upd));
 }
index b0a1a29368854532d15243d2b9baa6c954469421..2222aca20b80ea06755985fcf73369560a0ea2ab 100644 (file)
@@ -72,6 +72,10 @@ void complain_indent (location const *loc, warnings flags, unsigned *indent,
   __attribute__ ((__format__ (__printf__, 4, 5)));
 
 
+/** Report an obsolete syntax, suggest the updated one.  */
+void deprecated_directive (location const *loc,
+                           char const *obsolete, char const *updated);
+
 /** Warnings treated as errors shouldn't stop the execution as regular errors
     should (because due to their nature, it is safe to go on). Thus, there are
     three possible execution statuses.  */
index d02b26bb618983734e4327ac88ed68762a1ec557..4b7591bb1f9a74c0fe5799ccd160899d0ee8596f 100644 (file)
@@ -77,9 +77,7 @@ static size_t no_cr_read (FILE *, char *, size_t);
 #define DEPRECATED(Msg)                                         \
   do {                                                          \
     size_t i;                                                   \
-    complain (loc, Wdeprecated,                                 \
-              _("deprecated directive: %s, use %s"),            \
-              quote (yytext), quote_n (1, Msg));                \
+    deprecated_directive (loc, yytext, Msg);                    \
     scanner_cursor.column -= mbsnwidth (Msg, strlen (Msg), 0);  \
     for (i = strlen (Msg); i != 0; --i)                         \
       unput (Msg[i - 1]);                                       \