aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-decl.c11
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 91267c0..6e11827 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2017-12-07 Martin Sebor <msebor@redhat.com>
+
+ PR c/81544
+ * c-decl.c (c_decl_attributes): Look up existing declaration and
+ pass it to decl_attributes.
+
2017-12-06 David Malcolm <dmalcolm@redhat.com>
PR c/83236
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 607c705..aaa9678 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -4632,7 +4632,16 @@ c_decl_attributes (tree *node, tree attributes, int flags)
attributes = tree_cons (get_identifier ("omp declare target"),
NULL_TREE, attributes);
}
- return decl_attributes (node, attributes, flags);
+
+ /* Look up the current declaration with all the attributes merged
+ so far so that attributes on the current declaration that's
+ about to be pushed that conflict with the former can be detected,
+ diagnosed, and rejected as appropriate. */
+ tree last_decl = lookup_name (DECL_NAME (*node));
+ if (!last_decl)
+ last_decl = lookup_name_in_scope (DECL_NAME (*node), external_scope);
+
+ return decl_attributes (node, attributes, flags, last_decl);
}