summaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog12
-rw-r--r--gcc/c-family/c-ada-spec.c5
-rw-r--r--gcc/c-family/c-common.h1
-rw-r--r--gcc/c-family/c-format.c3
-rw-r--r--gcc/c-family/c-warn.c56
-rw-r--r--gcc/c-family/c.opt5
6 files changed, 80 insertions, 2 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 55c2e609606..2360d9ed17c 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,15 @@
+2016-11-14 Prasad Ghangal <prasad.ghangal@gmail.com>
+ Richard Biener <rguenther@suse.de>
+
+ * c-common.h (c_common_resword): Add RID_GIMPLE, RID_PHI types.
+ * c-common.h (enum rid): Add RID_GIMPLE, RID_PHI.
+ * c.opt (fgimple): New option.
+
+2016-11-13 Eric Botcazou <ebotcazou@adacore.com>
+
+ * c-ada-spec.c (print_ada_declaration): For typedef declarations, look
+ for nested types only if the type is a record or union and dump SLOC.
+
2016-11-09 Jason Merrill <jason@redhat.com>
* c-cppbuiltin.c (c_cpp_builtins): Define __cpp_template_auto.
diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c
index a5395b69489..42a2cd3a302 100644
--- a/gcc/c-family/c-ada-spec.c
+++ b/gcc/c-family/c-ada-spec.c
@@ -2813,7 +2813,7 @@ print_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc)
}
else
{
- if (!TREE_VISITED (stub)
+ if (RECORD_OR_UNION_TYPE_P (typ)
&& DECL_SOURCE_FILE (stub) == source_file_base)
dump_nested_types (buffer, stub, stub, true, spc);
@@ -2821,7 +2821,8 @@ print_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc)
dump_generic_ada_node (buffer, t, type, spc, false, true);
pp_string (buffer, " is ");
dump_generic_ada_node (buffer, typ, type, spc, false, true);
- pp_semicolon (buffer);
+ pp_string (buffer, "; -- ");
+ dump_sloc (buffer, t);
}
TREE_VISITED (t) = 1;
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 1fbe06038a4..241b3454e06 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1498,6 +1498,7 @@ extern void warnings_for_convert_and_check (location_t, tree, tree, tree);
extern void c_do_switch_warnings (splay_tree, location_t, tree, tree, bool,
bool);
extern void warn_for_omitted_condop (location_t, tree);
+extern void warn_for_restrict (unsigned, vec<tree, va_gc> *);
/* Places where an lvalue, or modifiable lvalue, may be required.
Used to select diagnostic messages in lvalue_error and
diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c
index bf39ee06e79..8a4bf6f0d29 100644
--- a/gcc/c-family/c-format.c
+++ b/gcc/c-family/c-format.c
@@ -713,6 +713,7 @@ static const format_char_info gcc_tdiag_char_table[] =
{ "r", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "cR", NULL },
{ "<>'R",0, STD_C89, NOARGUMENTS, "", "", NULL },
{ "m", 0, STD_C89, NOARGUMENTS, "q", "", NULL },
+ { "Z", 1, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "", &gcc_tdiag_char_table[0] },
{ NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL }
};
@@ -736,6 +737,7 @@ static const format_char_info gcc_cdiag_char_table[] =
{ "r", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "cR", NULL },
{ "<>'R",0, STD_C89, NOARGUMENTS, "", "", NULL },
{ "m", 0, STD_C89, NOARGUMENTS, "q", "", NULL },
+ { "Z", 1, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "", &gcc_tdiag_char_table[0] },
{ NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL }
};
@@ -762,6 +764,7 @@ static const format_char_info gcc_cxxdiag_char_table[] =
{ "r", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "cR", NULL },
{ "<>'R",0, STD_C89, NOARGUMENTS, "", "", NULL },
{ "m", 0, STD_C89, NOARGUMENTS, "q", "", NULL },
+ { "Z", 1, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "", &gcc_tdiag_char_table[0] },
{ NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL }
};
diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c
index 18ee24787a9..7197fe3d750 100644
--- a/gcc/c-family/c-warn.c
+++ b/gcc/c-family/c-warn.c
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h"
#include "intl.h"
#include "asan.h"
+#include "gcc-rich-location.h"
/* Print a warning if a constant expression had overflow in folding.
Invoke this function on every expression that the language
@@ -2161,3 +2162,58 @@ maybe_warn_bool_compare (location_t loc, enum tree_code code, tree op0,
"with boolean expression is always false", cst);
}
}
+
+/* Warn if an argument at position param_pos is passed to a
+ restrict-qualified param, and it aliases with another argument. */
+
+void
+warn_for_restrict (unsigned param_pos, vec<tree, va_gc> *args)
+{
+ tree arg = (*args)[param_pos];
+ if (TREE_VISITED (arg) || operand_equal_p (arg, null_pointer_node, 0))
+ return;
+
+ location_t loc = EXPR_LOC_OR_LOC (arg, input_location);
+ gcc_rich_location richloc (loc);
+
+ unsigned i;
+ tree current_arg;
+ int *arg_positions = XNEWVEC (int, args->length ());
+ unsigned arg_positions_len = 0;
+
+ FOR_EACH_VEC_ELT (*args, i, current_arg)
+ {
+ if (i == param_pos)
+ continue;
+
+ tree current_arg = (*args)[i];
+ if (operand_equal_p (arg, current_arg, 0))
+ {
+ TREE_VISITED (current_arg) = 1;
+ arg_positions[arg_positions_len++] = (i + 1);
+ }
+ }
+
+ if (arg_positions_len == 0)
+ {
+ free (arg_positions);
+ return;
+ }
+
+ for (unsigned i = 0; i < arg_positions_len; i++)
+ {
+ unsigned pos = arg_positions[i];
+ tree arg = (*args)[pos - 1];
+ if (EXPR_HAS_LOCATION (arg))
+ richloc.add_range (EXPR_LOCATION (arg), false);
+ }
+
+ warning_at_rich_loc_n (&richloc, OPT_Wrestrict, arg_positions_len,
+ "passing argument %i to restrict-qualified parameter"
+ " aliases with argument %Z",
+ "passing argument %i to restrict-qualified parameter"
+ " aliases with arguments %Z",
+ param_pos + 1, arg_positions, arg_positions_len);
+
+ free (arg_positions);
+}
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 2476954c067..722d3800cf0 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -1089,6 +1089,11 @@ Wduplicate-decl-specifier
C ObjC Var(warn_duplicate_decl_specifier) Warning LangEnabledBy(C ObjC,Wall)
Warn when a declaration has duplicate const, volatile, restrict or _Atomic specifier.
+Wrestrict
+C ObjC C++ ObjC++ Var(warn_restrict) Warning LangEnabledBy(C ObjC C++ ObjC++)
+Warn when an argument passed to a restrict-qualified parameter aliases with
+another argument.
+
ansi
C ObjC C++ ObjC++
A synonym for -std=c89 (for C) or -std=c++98 (for C++).