summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprathamesh3492 <prathamesh3492@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-08 17:04:35 +0000
committerprathamesh3492 <prathamesh3492@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-08 17:04:35 +0000
commitc43f5e5cc35c32664df4a21a8598c05f2c89688d (patch)
tree40a8e38ed15b8f38742563f23685bc43b2118f81
parentb70664869587a38cd15a44e5d6cbdc592de9b048 (diff)
downloadgcc-c43f5e5cc35c32664df4a21a8598c05f2c89688d.tar.gz
2016-10-08 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
* diagnostic-core.h (warning_at_rich_loc_n): Declare. * diagnostic.c (warning_at_rich_loc_n): New function. (diagnostic_n_impl_richloc): Likewise. (diagnostic_n_impl): Move most of the function to diagnostic_n_impl_richloc and call it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240891 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/diagnostic-core.h3
-rw-r--r--gcc/diagnostic.c44
3 files changed, 48 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1685c7f95aa..92ea9a3f39d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2016-10-08 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
+
+ * diagnostic-core.h (warning_at_rich_loc_n): Declare.
+ * diagnostic.c (warning_at_rich_loc_n): New function.
+ (diagnostic_n_impl_richloc): Likewise.
+ (diagnostic_n_impl): Move most of the function to
+ diagnostic_n_impl_richloc and call it.
+
2016-10-08 Jakub Jelinek <jakub@redhat.com>
* gen-pass-instances.awk: Rewritten.
diff --git a/gcc/diagnostic-core.h b/gcc/diagnostic-core.h
index 51df15028d4..4a1766c1ab3 100644
--- a/gcc/diagnostic-core.h
+++ b/gcc/diagnostic-core.h
@@ -65,6 +65,9 @@ extern bool warning_at (location_t, int, const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
extern bool warning_at_rich_loc (rich_location *, int, const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
+extern bool warning_at_rich_loc_n (rich_location *, int, int, const char *,
+ const char *, ...)
+ ATTRIBUTE_GCC_DIAG(4, 6) ATTRIBUTE_GCC_DIAG(5, 6);
extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void error_n (location_t, int, const char *, const char *, ...)
ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 585028ec211..167a1b58766 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -53,6 +53,10 @@ static bool diagnostic_impl (rich_location *, int, const char *,
static bool diagnostic_n_impl (location_t, int, int, const char *,
const char *, va_list *,
diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0);
+static bool diagnostic_n_impl_richloc (rich_location *, int, int, const char *,
+ const char *, va_list *,
+ diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0);
+
static void error_recursion (diagnostic_context *) ATTRIBUTE_NORETURN;
static void real_abort (void) ATTRIBUTE_NORETURN;
@@ -1064,6 +1068,22 @@ diagnostic_impl (rich_location *richloc, int opt,
return report_diagnostic (&diagnostic);
}
+/* Same as diagonostic_n_impl taking rich_location instead of location_t. */
+static bool
+diagnostic_n_impl_richloc (rich_location *richloc, int opt, int n,
+ const char *singular_gmsgid,
+ const char *plural_gmsgid,
+ va_list *ap, diagnostic_t kind)
+{
+ diagnostic_info diagnostic;
+ diagnostic_set_info_translated (&diagnostic,
+ ngettext (singular_gmsgid, plural_gmsgid, n),
+ ap, richloc, kind);
+ if (kind == DK_WARNING)
+ diagnostic.option_index = opt;
+ return report_diagnostic (&diagnostic);
+}
+
/* Implement inform_n, warning_n, and error_n, as documented and
defined below. */
static bool
@@ -1072,14 +1092,9 @@ diagnostic_n_impl (location_t location, int opt, int n,
const char *plural_gmsgid,
va_list *ap, diagnostic_t kind)
{
- diagnostic_info diagnostic;
rich_location richloc (line_table, location);
- diagnostic_set_info_translated (&diagnostic,
- ngettext (singular_gmsgid, plural_gmsgid, n),
- ap, &richloc, kind);
- if (kind == DK_WARNING)
- diagnostic.option_index = opt;
- return report_diagnostic (&diagnostic);
+ return diagnostic_n_impl_richloc (&richloc, opt, n,
+ singular_gmsgid, plural_gmsgid, ap, kind);
}
bool
@@ -1170,6 +1185,21 @@ warning_at_rich_loc (rich_location *richloc, int opt, const char *gmsgid, ...)
return ret;
}
+/* Same as warning_at_rich_loc but for plural variant. */
+
+bool
+warning_at_rich_loc_n (rich_location *richloc, int opt, int n,
+ const char *singular_gmsgid, const char *plural_gmsgid, ...)
+{
+ va_list ap;
+ va_start (ap, plural_gmsgid);
+ bool ret = diagnostic_n_impl_richloc (richloc, opt, n,
+ singular_gmsgid, plural_gmsgid,
+ &ap, DK_WARNING);
+ va_end (ap);
+ return ret;
+}
+
/* A warning at LOCATION. Use this for code which is correct according to the
relevant language specification but is likely to be buggy anyway.
Returns true if the warning was printed, false if it was inhibited. */