public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/3] improve detection of attribute conflicts (PR 81544)
@ 2017-08-08 16:14 Martin Sebor
  2017-08-16 23:00 ` [PATCH 4/3] " Martin Sebor
  2017-08-17  6:41 ` [PATCH 5/3] C++ bits to " Martin Sebor
  0 siblings, 2 replies; 13+ messages in thread
From: Martin Sebor @ 2017-08-08 16:14 UTC (permalink / raw)
  To: Gcc Patch List; +Cc: Marek Polacek, Joseph Myers, Jason Merrill

This patch series improves the attribute checking infrastructure
to make it easy to express mutual exclusivity between attributes,
detect and drop conflicting attributes as they are being added
to declarations, and help find sources of conflicts when they
involve two distinct declarations of the same symbols.

The details are below.

Thanks
Martin

The existing attribute handling infrastructure doesn't make
it possible for an attribute handler to diagnose conflicts
between attributes specified on distinct declarations of
the same function or object.  As a result, the handlers that
make an effort to detect conflicts only diagnose them when
they occur on the same declaration.  Such conflicts are easy
to spot during code review and so the diagnostics are of only
marginal help.  The hard-to-spot conflicts are those that are
between attributes on distinct declarations, and those for
the most part aren't detected.

Marek made a nice improvement in this area last year in r236129
by detecting a small subset of these problems in c-common.c (now
in c-warn.c).  The diagnose_mismatched_attributes function detects
conflicts between attribute always_inline and noinline.  However,
the function issues warnings only after the conflicting attributes
have been applied to the declaration without removing any, so code
that then makes use of the attributes and isn't prepared to deal
with the conflict may work in surprising ways.

To help solve the problem the patch adds to each attribute
an optional array of "exclusions" or names of other attributes
that a given attribute is mutually exclusive with.  It then
modifies the decl_attributes function to traverse the array and
diagnose (and drop) each attribute on a newly seen declaration
that is in conflict with an attribute already applied to it.
When a conflict involves two declarations of the same symbols
decl_attributes also points to the last known declarations to
help find the source of the conflict.

The patch only adds exclusions to the C and C++ front ends, but
other than initializing the new exclusion pointer to NULL doesn't
take advantage of this new feature in the back ends.  I'd like
to go and add exclusions to a small number of back ends as
examples for maintainers to follow after this patch has been
reviewed and approved.  My hope is that the exclusions array
will serve as a reminder to consider potential conflicts when
new attributes are being added, and provide an easier mechanism
to reject them than having to handcode it in each new handler.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 4/3] improve detection of attribute conflicts (PR 81544)
  2017-08-08 16:14 [PATCH 0/3] improve detection of attribute conflicts (PR 81544) Martin Sebor
@ 2017-08-16 23:00 ` Martin Sebor
  2017-08-18 14:06   ` Jonathan Wakely
  2017-08-17  6:41 ` [PATCH 5/3] C++ bits to " Martin Sebor
  1 sibling, 1 reply; 13+ messages in thread
From: Martin Sebor @ 2017-08-16 23:00 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Gcc Patch List, libstdc++

[-- Attachment #1: Type: text/plain, Size: 335 bytes --]

Jon,

Attached is the libstdc++ only patch to remove the pointless
const attribute from __pool<true>::_M_destroy_thread_key(void*).

   https://gcc.gnu.org/ml/gcc/2017-08/msg00027.html

I only belatedly now broke it out of the larger patch under
review here:

   https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00599.html

Thanks
Martin

[-- Attachment #2: gcc-81544-4.diff --]
[-- Type: text/x-patch, Size: 549 bytes --]

libstdc++-v3/ChangeLog:

	PR c/81544
	* include/ext/mt_allocator.h (_M_destroy_thread_key): Remove
	pointless attribute const.

diff --git a/libstdc++-v3/include/ext/mt_allocator.h b/libstdc++-v3/include/ext/mt_allocator.h
index effb13b..f349ff8 100644
--- a/libstdc++-v3/include/ext/mt_allocator.h
+++ b/libstdc++-v3/include/ext/mt_allocator.h
@@ -355,7 +355,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 
       // XXX GLIBCXX_ABI Deprecated
-      _GLIBCXX_CONST void 
+      void
       _M_destroy_thread_key(void*) throw ();
 
       size_t 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 5/3] C++ bits to improve detection of attribute conflicts (PR 81544)
  2017-08-08 16:14 [PATCH 0/3] improve detection of attribute conflicts (PR 81544) Martin Sebor
  2017-08-16 23:00 ` [PATCH 4/3] " Martin Sebor
@ 2017-08-17  6:41 ` Martin Sebor
  2017-08-23  5:15   ` Jason Merrill
  1 sibling, 1 reply; 13+ messages in thread
From: Martin Sebor @ 2017-08-17  6:41 UTC (permalink / raw)
  To: Gcc Patch List, Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]

To make review easier I broke out the C++ changes for the attributes
work into a patch of their own.  I also found the API I had asked
about, to look up a declaration based on one that's about to be
added/merged.

This patch depends on the foundation bits posted here:

   https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00599.html

Thanks
Martin

PS The decls_match changes were required only because the x86_64
target's targetm.target_option.function_versions() fails with
a hard error when it finds a conflict in the target attribute
while comparing declarations.  That doesn't seem quite right
for a predicate-type of an API but I didn't see a better way
around it than to introduce a new argument and avoid calling
into the back end when comparing attributes.

PPS I found a surprising number of bugs in the C++ front end
while working on this project: 81873, 81762, 81761, and 81609
so I split up the tests I had initially added under c-c++-common
between C and C++ and left in c-c++-common only the subset that
passes in both languages.

[-- Attachment #2: gcc-81544-5.diff --]
[-- Type: text/x-patch, Size: 5033 bytes --]

PR c/81544 - attribute noreturn and warn_unused_result on the same function accepted

gcc/cp/ChangeLog:

	PR c/81544
	* cp-tree.h (decls_match): Add default argument.
	* decl.c (decls_match): Avoid calling into the target back end
	and triggering an error.
	* decl2.c (cplus_decl_attributes): Look up existing declaration and
	pass it to decl_attributes.
	* tree.c (cxx_attribute_table): Initialize new member of struct
	attribute_spec.

gcc/testsuite/ChangeLog:

	PR c/81544
	* g++.dg/Wattributes-2.C: New test.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 115cdaf..f2bac2a 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6080,7 +6080,7 @@ extern void finish_scope			(void);
 extern void push_switch				(tree);
 extern void pop_switch				(void);
 extern tree make_lambda_name			(void);
-extern int decls_match				(tree, tree);
+extern int decls_match				(tree, tree, bool = true);
 extern tree duplicate_decls			(tree, tree, bool);
 extern tree declare_local_label			(tree);
 extern tree define_label			(location_t, tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index aab2019..c9c8cd1 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -993,7 +993,7 @@ push_local_name (tree decl)
    `const int&'.  */
 
 int
-decls_match (tree newdecl, tree olddecl)
+decls_match (tree newdecl, tree olddecl, bool record_versions /* = true */)
 {
   int types_match;
 
@@ -1088,6 +1088,7 @@ decls_match (tree newdecl, tree olddecl)
       if (types_match
 	  && !DECL_EXTERN_C_P (newdecl)
 	  && !DECL_EXTERN_C_P (olddecl)
+	  && record_versions
 	  && targetm.target_option.function_versions (newdecl, olddecl))
 	{
 	  /* Mark functions as versions if necessary.  Modify the mangled decl
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 2a52f8c..82df5e3 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1404,7 +1404,31 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags)
 		       attributes, flags);
     }
   else
-    decl_attributes (decl, attributes, flags);
+    {
+      tree last_decl = (DECL_P (*decl) && DECL_NAME (*decl)
+			? lookup_name (DECL_NAME (*decl)) : NULL_TREE);
+
+      if (last_decl && TREE_CODE (last_decl) == OVERLOAD)
+	for (ovl_iterator iter (last_decl, true); ; ++iter)
+	  {
+	    if (!iter)
+	      {
+		last_decl = NULL_TREE;
+		break;
+	      }
+
+	    if (TREE_CODE (*iter) == OVERLOAD)
+	      continue;
+
+	    if (decls_match (*decl, *iter, /*record_decls=*/false))
+	      {
+		last_decl = *iter;
+		break;
+	      }
+	  }
+
+      decl_attributes (decl, attributes, flags, last_decl);
+    }
 
   if (TREE_CODE (*decl) == TYPE_DECL)
     SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (*decl), TREE_TYPE (*decl));
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 8f18665..6cbf4b2 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -4314,10 +4314,10 @@ const struct attribute_spec cxx_attribute_table[] =
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
        affects_type_identity } */
   { "init_priority",  1, 1, true,  false, false,
-    handle_init_priority_attribute, false },
+    handle_init_priority_attribute, false, NULL },
   { "abi_tag", 1, -1, false, false, false,
-    handle_abi_tag_attribute, true },
-  { NULL,	      0, 0, false, false, false, NULL, false }
+    handle_abi_tag_attribute, true, NULL },
+  { NULL, 0, 0, false, false, false, NULL, false, NULL }
 };
 
 /* Table of C++ standard attributes.  */
@@ -4326,10 +4326,10 @@ const struct attribute_spec std_attribute_table[] =
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
        affects_type_identity } */
   { "maybe_unused", 0, 0, false, false, false,
-    handle_unused_attribute, false },
+    handle_unused_attribute, false, NULL },
   { "nodiscard", 0, 0, false, false, false,
-    handle_nodiscard_attribute, false },
-  { NULL,	      0, 0, false, false, false, NULL, false }
+    handle_nodiscard_attribute, false, NULL },
+  { NULL, 0, 0, false, false, false, NULL, false, NULL }
 };
 
 /* Handle an "init_priority" attribute; arguments as in
diff --git a/gcc/testsuite/g++.dg/Wattributes-2.C b/gcc/testsuite/g++.dg/Wattributes-2.C
new file mode 100644
index 0000000..1470b16
--- /dev/null
+++ b/gcc/testsuite/g++.dg/Wattributes-2.C
@@ -0,0 +1,35 @@
+// Test to verify that attributes on distinct overloads of a function
+//  with the same name are properly looked up and applied.
+// { dg-do compile }
+// { dg-options "-Wall" }
+
+int
+foo (int);
+
+int __attribute__ ((noreturn))
+foo (int, int);
+
+int __attribute__ ((warn_unused_result))
+foo (int, int, int);
+
+int call_foo_1 ()
+{
+  foo (1);
+}                       // { dg-warning "\\\[-Wreturn-type]" }
+
+int call_foo_2 ()
+{
+  foo (1, 2);
+}
+
+int call_foo_3 ()
+{
+  foo (1, 2, 3);        // { dg-warning "\\\[-Wunused-result]" }
+}                       // { dg-warning "\\\[-Wreturn-type]" }
+
+int call_foo_4 ()
+{
+  // Make sure an error doesn't trigger bogus warnings or an ICE.
+  foo (1, 2, 3, 4);     // { dg-error "no matching function" }
+  return 0;
+}

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/3] improve detection of attribute conflicts (PR 81544)
  2017-08-16 23:00 ` [PATCH 4/3] " Martin Sebor
@ 2017-08-18 14:06   ` Jonathan Wakely
  0 siblings, 0 replies; 13+ messages in thread
From: Jonathan Wakely @ 2017-08-18 14:06 UTC (permalink / raw)
  To: Martin Sebor; +Cc: Gcc Patch List, libstdc++

On 16/08/17 16:38 -0600, Martin Sebor wrote:
>Jon,
>
>Attached is the libstdc++ only patch to remove the pointless
>const attribute from __pool<true>::_M_destroy_thread_key(void*).
>
>  https://gcc.gnu.org/ml/gcc/2017-08/msg00027.html
>
>I only belatedly now broke it out of the larger patch under
>review here:
>
>  https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00599.html
>
>Thanks
>Martin

>libstdc++-v3/ChangeLog:
>
>	PR c/81544
>	* include/ext/mt_allocator.h (_M_destroy_thread_key): Remove
>	pointless attribute const.

OK.

>diff --git a/libstdc++-v3/include/ext/mt_allocator.h b/libstdc++-v3/include/ext/mt_allocator.h
>index effb13b..f349ff8 100644
>--- a/libstdc++-v3/include/ext/mt_allocator.h
>+++ b/libstdc++-v3/include/ext/mt_allocator.h
>@@ -355,7 +355,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>       }
> 
>       // XXX GLIBCXX_ABI Deprecated
>-      _GLIBCXX_CONST void 
>+      void
>       _M_destroy_thread_key(void*) throw ();
> 
>       size_t 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/3] C++ bits to improve detection of attribute conflicts (PR 81544)
  2017-08-17  6:41 ` [PATCH 5/3] C++ bits to " Martin Sebor
@ 2017-08-23  5:15   ` Jason Merrill
  2017-08-23 15:30     ` Martin Sebor
  0 siblings, 1 reply; 13+ messages in thread
From: Jason Merrill @ 2017-08-23  5:15 UTC (permalink / raw)
  To: Martin Sebor, Gcc Patch List

The C and C++ front ends already have a diagnose_mismatched_attributes 
function, which seems like the natural place to add more conflict checking.

Jason

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/3] C++ bits to improve detection of attribute conflicts (PR 81544)
  2017-08-23  5:15   ` Jason Merrill
@ 2017-08-23 15:30     ` Martin Sebor
  2017-12-03 14:59       ` Martin Sebor
  0 siblings, 1 reply; 13+ messages in thread
From: Martin Sebor @ 2017-08-23 15:30 UTC (permalink / raw)
  To: Jason Merrill, Gcc Patch List

On 08/22/2017 09:51 PM, Jason Merrill wrote:
> The C and C++ front ends already have a diagnose_mismatched_attributes
> function, which seems like the natural place to add more conflict checking.

There are a few major problems with handling attribute conflicts
in diagnose_mismatched_attributes.

The function only diagnoses conflicts, it doesn't resolve them
(choose one attribute or the other).  Currently, when they are
resolved, it's done in each attribute handler.  But this is done
inconsistently because of the limitations of the infrastructure:
no access to the last pushed declaration.  Often, it's not done
at all.  Making the declaration  available to every handler is
one of the design improvements of the patch.

Attributes are defined in the attribute_spec tables in a number
of different places: all the back ends, in addition to the front
ends, but processed by the general infrastructure in
decl_attributes in attribs.c.  The infrastructure already has
all the smarts to either accept or reject a conflicting attribute.
None of this is available in diagnose_mismatched_attributes.
The current implementation of the function hardcodes knowledge
about a small number of attribute relationships in the code.
That's a poor approach given the table-driven attribute_spec
design.  For one, it makes it difficult for back-end maintainers
to add a new attribute that's mutually exclusive with another
(the back-end maintainer would need to change the front end).
It might explain why no back-end attribute conflicts are
diagnosed there.

Some, maybe even most of these problems could be overcome by
moving the conflict resolution from decl_attributes to
diagnose_mismatched_attributes.  But it would mean duplicating
a fair amount of the logic between the two functions.  I think
that would result in an inferior solution.  From both a design
and implementation point of view, I feel the logic fits best
in the attribs.c.

Martin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/3] C++ bits to improve detection of attribute conflicts (PR 81544)
  2017-08-23 15:30     ` Martin Sebor
@ 2017-12-03 14:59       ` Martin Sebor
  2017-12-05  3:21         ` Jason Merrill
  2017-12-08  9:44         ` Rainer Orth
  0 siblings, 2 replies; 13+ messages in thread
From: Martin Sebor @ 2017-12-03 14:59 UTC (permalink / raw)
  To: Jason Merrill, Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 2274 bytes --]

Ping: https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01034.html

The attached C++ only patch is rebased on the top of trunk.

The remaining patches in the series (C FE and the back ends)
have been approved.

Martin

On 08/23/2017 08:36 AM, Martin Sebor wrote:
> On 08/22/2017 09:51 PM, Jason Merrill wrote:
>> The C and C++ front ends already have a diagnose_mismatched_attributes
>> function, which seems like the natural place to add more conflict
>> checking.
>
> There are a few major problems with handling attribute conflicts
> in diagnose_mismatched_attributes.
>
> The function only diagnoses conflicts, it doesn't resolve them
> (choose one attribute or the other).  Currently, when they are
> resolved, it's done in each attribute handler.  But this is done
> inconsistently because of the limitations of the infrastructure:
> no access to the last pushed declaration.  Often, it's not done
> at all.  Making the declaration  available to every handler is
> one of the design improvements of the patch.
>
> Attributes are defined in the attribute_spec tables in a number
> of different places: all the back ends, in addition to the front
> ends, but processed by the general infrastructure in
> decl_attributes in attribs.c.  The infrastructure already has
> all the smarts to either accept or reject a conflicting attribute.
> None of this is available in diagnose_mismatched_attributes.
> The current implementation of the function hardcodes knowledge
> about a small number of attribute relationships in the code.
> That's a poor approach given the table-driven attribute_spec
> design.  For one, it makes it difficult for back-end maintainers
> to add a new attribute that's mutually exclusive with another
> (the back-end maintainer would need to change the front end).
> It might explain why no back-end attribute conflicts are
> diagnosed there.
>
> Some, maybe even most of these problems could be overcome by
> moving the conflict resolution from decl_attributes to
> diagnose_mismatched_attributes.  But it would mean duplicating
> a fair amount of the logic between the two functions.  I think
> that would result in an inferior solution.  From both a design
> and implementation point of view, I feel the logic fits best
> in the attribs.c.
>
> Martin


[-- Attachment #2: gcc-81544-5.diff --]
[-- Type: text/x-patch, Size: 5141 bytes --]

PR c/81544 - attribute noreturn and warn_unused_result on the same function accepted

gcc/cp/ChangeLog:

	PR c/81544
	* cp-tree.h (decls_match): Add default argument.
	* decl.c (decls_match): Avoid calling into the target back end
	and triggering an error.
	* decl2.c (cplus_decl_attributes): Look up existing declaration and
	pass it to decl_attributes.
	* tree.c (cxx_attribute_table): Initialize new member of struct
	attribute_spec.

gcc/testsuite/ChangeLog:

	PR c/81544
	* g++.dg/Wattributes-2.C: New test.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index e77241f..736c484 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6116,7 +6116,7 @@ extern void note_break_stmt			(void);
 extern bool note_iteration_stmt_body_start	(void);
 extern void note_iteration_stmt_body_end	(bool);
 extern tree make_lambda_name			(void);
-extern int decls_match				(tree, tree);
+extern int decls_match				(tree, tree, bool = true);
 extern bool maybe_version_functions		(tree, tree);
 extern tree duplicate_decls			(tree, tree, bool);
 extern tree declare_local_label			(tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 7085d5a..99b22dc 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -992,7 +992,7 @@ push_local_name (tree decl)
    `const int&'.  */
 
 int
-decls_match (tree newdecl, tree olddecl)
+decls_match (tree newdecl, tree olddecl, bool record_versions /* = true */)
 {
   int types_match;
 
@@ -1087,6 +1087,7 @@ decls_match (tree newdecl, tree olddecl)
       if (types_match
 	  && !DECL_EXTERN_C_P (newdecl)
 	  && !DECL_EXTERN_C_P (olddecl)
+	  && record_versions
 	  && maybe_version_functions (newdecl, olddecl))
 	return 0;
     }
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 13e7b1d..f20c54d 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1473,7 +1473,31 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags)
 		       attributes, flags);
     }
   else
-    decl_attributes (decl, attributes, flags);
+    {
+      tree last_decl = (DECL_P (*decl) && DECL_NAME (*decl)
+			? lookup_name (DECL_NAME (*decl)) : NULL_TREE);
+
+      if (last_decl && TREE_CODE (last_decl) == OVERLOAD)
+	for (ovl_iterator iter (last_decl, true); ; ++iter)
+	  {
+	    if (!iter)
+	      {
+		last_decl = NULL_TREE;
+		break;
+	      }
+
+	    if (TREE_CODE (*iter) == OVERLOAD)
+	      continue;
+
+	    if (decls_match (*decl, *iter, /*record_decls=*/false))
+	      {
+		last_decl = *iter;
+		break;
+	      }
+	  }
+
+      decl_attributes (decl, attributes, flags, last_decl);
+    }
 
   if (TREE_CODE (*decl) == TYPE_DECL)
     SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (*decl), TREE_TYPE (*decl));
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index c76dea4..1ebee70 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -4323,24 +4323,24 @@ handle_nodiscard_attribute (tree *node, tree name, tree /*args*/,
 const struct attribute_spec cxx_attribute_table[] =
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
-       affects_type_identity } */
+       affects_type_identity, exclusions } */
   { "init_priority",  1, 1, true,  false, false,
-    handle_init_priority_attribute, false },
+    handle_init_priority_attribute, false, NULL },
   { "abi_tag", 1, -1, false, false, false,
-    handle_abi_tag_attribute, true },
-  { NULL,	      0, 0, false, false, false, NULL, false }
+    handle_abi_tag_attribute, true, NULL },
+  { NULL, 0, 0, false, false, false, NULL, false, NULL }
 };
 
 /* Table of C++ standard attributes.  */
 const struct attribute_spec std_attribute_table[] =
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
-       affects_type_identity } */
+       affects_type_identity, exclusions } */
   { "maybe_unused", 0, 0, false, false, false,
-    handle_unused_attribute, false },
+    handle_unused_attribute, false, NULL },
   { "nodiscard", 0, 0, false, false, false,
-    handle_nodiscard_attribute, false },
-  { NULL,	      0, 0, false, false, false, NULL, false }
+    handle_nodiscard_attribute, false, NULL },
+  { NULL, 0, 0, false, false, false, NULL, false, NULL }
 };
 
 /* Handle an "init_priority" attribute; arguments as in
diff --git a/gcc/testsuite/g++.dg/Wattributes-2.C b/gcc/testsuite/g++.dg/Wattributes-2.C
new file mode 100644
index 0000000..1470b16
--- /dev/null
+++ b/gcc/testsuite/g++.dg/Wattributes-2.C
@@ -0,0 +1,35 @@
+// Test to verify that attributes on distinct overloads of a function
+//  with the same name are properly looked up and applied.
+// { dg-do compile }
+// { dg-options "-Wall" }
+
+int
+foo (int);
+
+int __attribute__ ((noreturn))
+foo (int, int);
+
+int __attribute__ ((warn_unused_result))
+foo (int, int, int);
+
+int call_foo_1 ()
+{
+  foo (1);
+}                       // { dg-warning "\\\[-Wreturn-type]" }
+
+int call_foo_2 ()
+{
+  foo (1, 2);
+}
+
+int call_foo_3 ()
+{
+  foo (1, 2, 3);        // { dg-warning "\\\[-Wunused-result]" }
+}                       // { dg-warning "\\\[-Wreturn-type]" }
+
+int call_foo_4 ()
+{
+  // Make sure an error doesn't trigger bogus warnings or an ICE.
+  foo (1, 2, 3, 4);     // { dg-error "no matching function" }
+  return 0;
+}

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/3] C++ bits to improve detection of attribute conflicts (PR 81544)
  2017-12-03 14:59       ` Martin Sebor
@ 2017-12-05  3:21         ` Jason Merrill
  2017-12-08  9:44         ` Rainer Orth
  1 sibling, 0 replies; 13+ messages in thread
From: Jason Merrill @ 2017-12-05  3:21 UTC (permalink / raw)
  To: Martin Sebor; +Cc: Gcc Patch List

OK.

On Sun, Dec 3, 2017 at 9:59 AM, Martin Sebor <msebor@gmail.com> wrote:
> Ping: https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01034.html
>
> The attached C++ only patch is rebased on the top of trunk.
>
> The remaining patches in the series (C FE and the back ends)
> have been approved.
>
> Martin
>
>
> On 08/23/2017 08:36 AM, Martin Sebor wrote:
>>
>> On 08/22/2017 09:51 PM, Jason Merrill wrote:
>>>
>>> The C and C++ front ends already have a diagnose_mismatched_attributes
>>> function, which seems like the natural place to add more conflict
>>> checking.
>>
>>
>> There are a few major problems with handling attribute conflicts
>> in diagnose_mismatched_attributes.
>>
>> The function only diagnoses conflicts, it doesn't resolve them
>> (choose one attribute or the other).  Currently, when they are
>> resolved, it's done in each attribute handler.  But this is done
>> inconsistently because of the limitations of the infrastructure:
>> no access to the last pushed declaration.  Often, it's not done
>> at all.  Making the declaration  available to every handler is
>> one of the design improvements of the patch.
>>
>> Attributes are defined in the attribute_spec tables in a number
>> of different places: all the back ends, in addition to the front
>> ends, but processed by the general infrastructure in
>> decl_attributes in attribs.c.  The infrastructure already has
>> all the smarts to either accept or reject a conflicting attribute.
>> None of this is available in diagnose_mismatched_attributes.
>> The current implementation of the function hardcodes knowledge
>> about a small number of attribute relationships in the code.
>> That's a poor approach given the table-driven attribute_spec
>> design.  For one, it makes it difficult for back-end maintainers
>> to add a new attribute that's mutually exclusive with another
>> (the back-end maintainer would need to change the front end).
>> It might explain why no back-end attribute conflicts are
>> diagnosed there.
>>
>> Some, maybe even most of these problems could be overcome by
>> moving the conflict resolution from decl_attributes to
>> diagnose_mismatched_attributes.  But it would mean duplicating
>> a fair amount of the logic between the two functions.  I think
>> that would result in an inferior solution.  From both a design
>> and implementation point of view, I feel the logic fits best
>> in the attribs.c.
>>
>> Martin
>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/3] C++ bits to improve detection of attribute conflicts (PR 81544)
  2017-12-03 14:59       ` Martin Sebor
  2017-12-05  3:21         ` Jason Merrill
@ 2017-12-08  9:44         ` Rainer Orth
  2017-12-08 10:13           ` Jakub Jelinek
  1 sibling, 1 reply; 13+ messages in thread
From: Rainer Orth @ 2017-12-08  9:44 UTC (permalink / raw)
  To: Martin Sebor; +Cc: Jason Merrill, Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 1794 bytes --]

Hi Martin,

> Ping: https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01034.html
>
> The attached C++ only patch is rebased on the top of trunk.
>
> The remaining patches in the series (C FE and the back ends)
> have been approved.

your patch broke Solaris bootstrap:

/vol/gcc/src/hg/trunk/local/gcc/config/sparc/sparc.c:699:1: error: missing initializer for member 'attribute_spec::exclude' [-Werror=missing-field-initializers]
 };
 ^
/vol/gcc/src/hg/trunk/local/gcc/config/sparc/sparc.c:699:1: error: missing initializer for member 'attribute_spec::exclude' [-Werror=missing-field-initializers]

/vol/gcc/src/hg/trunk/local/gcc/config/i386/i386.c:44761:1: error: missing initializer for member 'attribute_spec::exclude' [-Werror=missing-field-initializers]
 };
 ^
/vol/gcc/src/hg/trunk/local/gcc/config/i386/i386.c:44761:1: error: missing initializer for member 'attribute_spec::exclude' [-Werror=missing-field-initializers]


The line numbers are completely misleading, unfortunately.  Hadn't
SUBTARGET_ATTRIBUTE_TABLE been used at the end of the (very short)
sparc_attribute_table, I wouldn't have seen what was wrong.

The following patch fixes the problem, installed on mainline after
i386-pc-solaris2.11 and sparc-sun-solaris2.11 bootstraps completed
without regressions.

However, there are two more SUBTARGET_ATTRIBUTE_TABLE defines:

gcc/config/darwin.h:#define SUBTARGET_ATTRIBUTE_TABLE                               \
gcc/config/i386/cygming.h:#define SUBTARGET_ATTRIBUTE_TABLE \

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2017-12-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* config/sol2.h (SOLARIS_ATTRIBUTE_TABLE): Initialize new member
	of struct attribute_spec.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-solaris_attribute_table.patch --]
[-- Type: text/x-patch, Size: 791 bytes --]

# HG changeset patch
# Parent  437a73acf1a5ffdc19298cad526f5f85d5496ed0
Initialize new member of SOLARIS_ATTRIBUTE_TABLE

diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -409,8 +409,8 @@ along with GCC; see the file COPYING3.  
 /* #pragma init and #pragma fini are implemented on top of init and
    fini attributes.  */
 #define SOLARIS_ATTRIBUTE_TABLE						\
-  { "init",      0, 0, true,  false,  false, NULL, false },		\
-  { "fini",      0, 0, true,  false,  false, NULL, false }
+  { "init",      0, 0, true,  false,  false, NULL, false, NULL },	\
+  { "fini",      0, 0, true,  false,  false, NULL, false, NULL }
 
 /* Solaris-specific #pragmas are implemented on top of attributes.  Hook in
    the bits from config/sol2.c.  */

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/3] C++ bits to improve detection of attribute conflicts (PR 81544)
  2017-12-08  9:44         ` Rainer Orth
@ 2017-12-08 10:13           ` Jakub Jelinek
  2017-12-08 10:33             ` Rainer Orth
  0 siblings, 1 reply; 13+ messages in thread
From: Jakub Jelinek @ 2017-12-08 10:13 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Martin Sebor, Jason Merrill, Gcc Patch List

On Fri, Dec 08, 2017 at 10:43:58AM +0100, Rainer Orth wrote:
> The line numbers are completely misleading, unfortunately.  Hadn't
> SUBTARGET_ATTRIBUTE_TABLE been used at the end of the (very short)
> sparc_attribute_table, I wouldn't have seen what was wrong.
> 
> The following patch fixes the problem, installed on mainline after
> i386-pc-solaris2.11 and sparc-sun-solaris2.11 bootstraps completed
> without regressions.
> 
> However, there are two more SUBTARGET_ATTRIBUTE_TABLE defines:
> 
> gcc/config/darwin.h:#define SUBTARGET_ATTRIBUTE_TABLE                               \
> gcc/config/i386/cygming.h:#define SUBTARGET_ATTRIBUTE_TABLE \

I'll deal with this.

> 2017-12-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
> 
> 	* config/sol2.h (SOLARIS_ATTRIBUTE_TABLE): Initialize new member
> 	of struct attribute_spec.

Ok for trunk.

	Jakub

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/3] C++ bits to improve detection of attribute conflicts (PR 81544)
  2017-12-08 10:13           ` Jakub Jelinek
@ 2017-12-08 10:33             ` Rainer Orth
  2017-12-08 11:31               ` Jakub Jelinek
  0 siblings, 1 reply; 13+ messages in thread
From: Rainer Orth @ 2017-12-08 10:33 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Martin Sebor, Jason Merrill, Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 1116 bytes --]

Jakub Jelinek <jakub@redhat.com> writes:

> On Fri, Dec 08, 2017 at 10:43:58AM +0100, Rainer Orth wrote:
>> The line numbers are completely misleading, unfortunately.  Hadn't
>> SUBTARGET_ATTRIBUTE_TABLE been used at the end of the (very short)
>> sparc_attribute_table, I wouldn't have seen what was wrong.
>> 
>> The following patch fixes the problem, installed on mainline after
>> i386-pc-solaris2.11 and sparc-sun-solaris2.11 bootstraps completed
>> without regressions.
>> 
>> However, there are two more SUBTARGET_ATTRIBUTE_TABLE defines:
>> 
>> gcc/config/darwin.h:#define SUBTARGET_ATTRIBUTE_TABLE \
>> gcc/config/i386/cygming.h:#define SUBTARGET_ATTRIBUTE_TABLE \
>
> I'll deal with this.

This is what I'm currently testing with an  x86_64-apple-darwin11.4.2
bootstrap.  Ok if it passes?

Thanks.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2017-12-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* config/darwin.h (SUBTARGET_ATTRIBUTE_TABLE): Initialize new
	member of struct attribute_spec.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: macos-subtarget_attribute_table.patch --]
[-- Type: text/x-patch, Size: 921 bytes --]

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -742,11 +742,11 @@ extern GTY(()) section * darwin_sections
 /* Extra attributes for Darwin.  */
 #define SUBTARGET_ATTRIBUTE_TABLE					     \
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,     \
-       affects_type_identity } */						     \
+       affects_type_identity, exclude } */				     \
   { "apple_kext_compatibility", 0, 0, false, true, false,		     \
-    darwin_handle_kext_attribute, false },				     \
+    darwin_handle_kext_attribute, false, NULL },			     \
   { "weak_import", 0, 0, true, false, false,				     \
-    darwin_handle_weak_import_attribute, false }
+    darwin_handle_weak_import_attribute, false, NULL }
 
 /* Make local constant labels linker-visible, so that if one follows a
    weak_global constant, ld64 will be able to separate the atoms.  */

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/3] C++ bits to improve detection of attribute conflicts (PR 81544)
  2017-12-08 10:33             ` Rainer Orth
@ 2017-12-08 11:31               ` Jakub Jelinek
  2017-12-08 16:00                 ` Martin Sebor
  0 siblings, 1 reply; 13+ messages in thread
From: Jakub Jelinek @ 2017-12-08 11:31 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Martin Sebor, Jason Merrill, Gcc Patch List

On Fri, Dec 08, 2017 at 11:32:54AM +0100, Rainer Orth wrote:
> Jakub Jelinek <jakub@redhat.com> writes:
> 
> > On Fri, Dec 08, 2017 at 10:43:58AM +0100, Rainer Orth wrote:
> >> The line numbers are completely misleading, unfortunately.  Hadn't
> >> SUBTARGET_ATTRIBUTE_TABLE been used at the end of the (very short)
> >> sparc_attribute_table, I wouldn't have seen what was wrong.
> >> 
> >> The following patch fixes the problem, installed on mainline after
> >> i386-pc-solaris2.11 and sparc-sun-solaris2.11 bootstraps completed
> >> without regressions.
> >> 
> >> However, there are two more SUBTARGET_ATTRIBUTE_TABLE defines:
> >> 
> >> gcc/config/darwin.h:#define SUBTARGET_ATTRIBUTE_TABLE \
> >> gcc/config/i386/cygming.h:#define SUBTARGET_ATTRIBUTE_TABLE \
> >
> > I'll deal with this.
> 
> This is what I'm currently testing with an  x86_64-apple-darwin11.4.2
> bootstrap.  Ok if it passes?

I've committed this instead, while only darwin.h and cygming.h were left
broken, the comments haven't been adjusted in many more cases.

BTW, we should swap handler and affects_type_identity fields at some point,
3 bools, then pointer, then bool, then pointer needs quite a lot of padding.

2017-12-08  Jakub Jelinek  <jakub@redhat.com>

	* config/arc/arc.c (arc_attribute_table): Add exclusions to
	the comment.
	* config/avr/avr.c (avr_attribute_table): Likewise.
	* config/msp430/msp430.c (msp430_attribute_table): Likewise.
	* config/rl78/rl78.c (rl78_attribute_table): Likewise.
	* config/nds32/nds32.c (nds32_attribute_table): Likewise.
	* config/darwin.h (SUBTARGET_ATTRIBUTE_TABLE): Initialize new member
	of struct attribute_spec.
	* config/i386/cygming.h (SUBTARGET_ATTRIBUTE_TABLE): Likewise.
ada/
	* gcc-interface/utils.c (gnat_internal_attribute_table): Add
	exclusions to the comment.
brig/
	* brig-lang.c (brig_attribute_table): Fix up comment.

--- gcc/config/arc/arc.c.jj	2017-12-07 18:05:03.000000000 +0100
+++ gcc/config/arc/arc.c	2017-12-08 11:20:24.605501619 +0100
@@ -218,7 +218,7 @@ static tree arc_handle_fndecl_attribute
 const struct attribute_spec arc_attribute_table[] =
 {
  /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
-      affects_type_identity } */
+      affects_type_identity, exclusions } */
   { "interrupt", 1, 1, true, false, false, arc_handle_interrupt_attribute,
       true, NULL },
   /* Function calls made to this symbol must be done indirectly, because
--- gcc/config/avr/avr.c.jj	2017-12-07 18:05:02.000000000 +0100
+++ gcc/config/avr/avr.c	2017-12-08 11:24:32.270391537 +0100
@@ -9875,7 +9875,7 @@ static const struct attribute_spec
 avr_attribute_table[] =
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
-       affects_type_identity } */
+       affects_type_identity, exclusions } */
   { "progmem",   0, 0, false, false, false,  avr_handle_progmem_attribute,
     false, NULL },
   { "signal",    0, 0, true,  false, false,  avr_handle_fndecl_attribute,
--- gcc/config/darwin.h.jj	2017-11-28 12:11:41.000000000 +0100
+++ gcc/config/darwin.h	2017-12-08 11:18:05.866243854 +0100
@@ -741,11 +741,11 @@ extern GTY(()) section * darwin_sections
 /* Extra attributes for Darwin.  */
 #define SUBTARGET_ATTRIBUTE_TABLE					     \
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,     \
-       affects_type_identity } */						     \
+       affects_type_identity, exclusions } */				     \
   { "apple_kext_compatibility", 0, 0, false, true, false,		     \
-    darwin_handle_kext_attribute, false },				     \
+    darwin_handle_kext_attribute, false, NULL },			     \
   { "weak_import", 0, 0, true, false, false,				     \
-    darwin_handle_weak_import_attribute, false }
+    darwin_handle_weak_import_attribute, false, NULL }
 
 /* Make local constant labels linker-visible, so that if one follows a
    weak_global constant, ld64 will be able to separate the atoms.  */
--- gcc/config/i386/cygming.h.jj	2017-10-30 12:02:35.000000000 +0100
+++ gcc/config/i386/cygming.h	2017-12-08 11:25:12.372887945 +0100
@@ -448,9 +448,9 @@ do {						\
 
 #define SUBTARGET_ATTRIBUTE_TABLE \
   { "selectany", 0, 0, true, false, false, ix86_handle_selectany_attribute, \
-    false }
+    false, NULL }
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
-       affects_type_identity } */
+       affects_type_identity, exclusions } */
 
 /*  mcount() does not need a counter variable.  */
 #undef NO_PROFILE_COUNTERS
--- gcc/config/msp430/msp430.c.jj	2017-12-07 18:05:03.000000000 +0100
+++ gcc/config/msp430/msp430.c	2017-12-08 11:26:47.634691684 +0100
@@ -2050,7 +2050,7 @@ msp430_data_attr (tree * node,
 const struct attribute_spec msp430_attribute_table[] =
 {
   /* Name        min_num_args     type_req,             affects_type_identity
-                      max_num_args,     fn_type_req
+		      max_num_args,     fn_type_req		exclusions
                           decl_req               handler.  */
   { ATTR_INTR,        0, 1, true,  false, false, msp430_attr, false, NULL },
   { ATTR_NAKED,       0, 0, true,  false, false, msp430_attr, false, NULL },
--- gcc/config/rl78/rl78.c.jj	2017-12-07 18:05:03.000000000 +0100
+++ gcc/config/rl78/rl78.c	2017-12-08 11:27:25.024222160 +0100
@@ -858,7 +858,7 @@ rl78_handle_saddr_attribute (tree * node
 const struct attribute_spec rl78_attribute_table[] =
 {
   /* Name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
-     affects_type_identity.  */
+     affects_type_identity, exclusions.  */
   { "interrupt",      0, 0, true, false, false, rl78_handle_func_attribute,
     false, NULL },
   { "brk_interrupt",  0, 0, true, false, false, rl78_handle_func_attribute,
--- gcc/config/nds32/nds32.c.jj	2017-12-07 18:05:02.000000000 +0100
+++ gcc/config/nds32/nds32.c	2017-12-08 11:27:54.160856273 +0100
@@ -83,7 +83,8 @@ static const char * const nds32_intrinsi
 static const struct attribute_spec nds32_attribute_table[] =
 {
   /* Syntax: { name, min_len, max_len, decl_required, type_required,
-	       function_type_required, handler, affects_type_identity } */
+	       function_type_required, handler, affects_type_identity,
+	       exclusions } */
 
   /* The interrupt vid: [0-63]+ (actual vector number starts from 9 to 72).  */
   { "interrupt",    1, 64, false, false, false, NULL, false, NULL },
--- gcc/ada/gcc-interface/utils.c.jj	2017-12-07 18:04:59.000000000 +0100
+++ gcc/ada/gcc-interface/utils.c	2017-12-08 11:29:11.796881349 +0100
@@ -108,7 +108,7 @@ static tree fake_attribute_handler (tree
 const struct attribute_spec gnat_internal_attribute_table[] =
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
-       affects_type_identity } */
+       affects_type_identity, exclusions } */
   { "const",        0, 0,  true,  false, false, handle_const_attribute,
     false, NULL },
   { "nothrow",      0, 0,  true,  false, false, handle_nothrow_attribute,
--- gcc/brig/brig-lang.c.jj	2017-12-07 18:04:55.000000000 +0100
+++ gcc/brig/brig-lang.c	2017-12-08 12:20:40.475998143 +0100
@@ -448,7 +448,7 @@ brig_localize_identifier (const char *id
 const struct attribute_spec brig_attribute_table[] =
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
-       do_diagnostic } */
+       affects_type_identity, exclusions } */
   { "leaf",		      0, 0, true,  false, false,
 			      handle_leaf_attribute, false, NULL },
   { "const",                  0, 0, true,  false, false,


	Jakub

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/3] C++ bits to improve detection of attribute conflicts (PR 81544)
  2017-12-08 11:31               ` Jakub Jelinek
@ 2017-12-08 16:00                 ` Martin Sebor
  0 siblings, 0 replies; 13+ messages in thread
From: Martin Sebor @ 2017-12-08 16:00 UTC (permalink / raw)
  To: Jakub Jelinek, Rainer Orth; +Cc: Jason Merrill, Gcc Patch List

On 12/08/2017 04:30 AM, Jakub Jelinek wrote:
> On Fri, Dec 08, 2017 at 11:32:54AM +0100, Rainer Orth wrote:
>> Jakub Jelinek <jakub@redhat.com> writes:
>>
>>> On Fri, Dec 08, 2017 at 10:43:58AM +0100, Rainer Orth wrote:
>>>> The line numbers are completely misleading, unfortunately.  Hadn't
>>>> SUBTARGET_ATTRIBUTE_TABLE been used at the end of the (very short)
>>>> sparc_attribute_table, I wouldn't have seen what was wrong.
>>>>
>>>> The following patch fixes the problem, installed on mainline after
>>>> i386-pc-solaris2.11 and sparc-sun-solaris2.11 bootstraps completed
>>>> without regressions.
>>>>
>>>> However, there are two more SUBTARGET_ATTRIBUTE_TABLE defines:
>>>>
>>>> gcc/config/darwin.h:#define SUBTARGET_ATTRIBUTE_TABLE \
>>>> gcc/config/i386/cygming.h:#define SUBTARGET_ATTRIBUTE_TABLE \
>>>
>>> I'll deal with this.
>>
>> This is what I'm currently testing with an  x86_64-apple-darwin11.4.2
>> bootstrap.  Ok if it passes?
>
> I've committed this instead, while only darwin.h and cygming.h were left
> broken, the comments haven't been adjusted in many more cases.

Sorry about that and thanks for fixing it up.  Hopefully the Solaris
and Darwin files were the only ones I missed.  They were hidden from
my search by macros.

Martin

>
> BTW, we should swap handler and affects_type_identity fields at some point,
> 3 bools, then pointer, then bool, then pointer needs quite a lot of padding.
>
> 2017-12-08  Jakub Jelinek  <jakub@redhat.com>
>
> 	* config/arc/arc.c (arc_attribute_table): Add exclusions to
> 	the comment.
> 	* config/avr/avr.c (avr_attribute_table): Likewise.
> 	* config/msp430/msp430.c (msp430_attribute_table): Likewise.
> 	* config/rl78/rl78.c (rl78_attribute_table): Likewise.
> 	* config/nds32/nds32.c (nds32_attribute_table): Likewise.
> 	* config/darwin.h (SUBTARGET_ATTRIBUTE_TABLE): Initialize new member
> 	of struct attribute_spec.
> 	* config/i386/cygming.h (SUBTARGET_ATTRIBUTE_TABLE): Likewise.
> ada/
> 	* gcc-interface/utils.c (gnat_internal_attribute_table): Add
> 	exclusions to the comment.
> brig/
> 	* brig-lang.c (brig_attribute_table): Fix up comment.
>
> --- gcc/config/arc/arc.c.jj	2017-12-07 18:05:03.000000000 +0100
> +++ gcc/config/arc/arc.c	2017-12-08 11:20:24.605501619 +0100
> @@ -218,7 +218,7 @@ static tree arc_handle_fndecl_attribute
>  const struct attribute_spec arc_attribute_table[] =
>  {
>   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
> -      affects_type_identity } */
> +      affects_type_identity, exclusions } */
>    { "interrupt", 1, 1, true, false, false, arc_handle_interrupt_attribute,
>        true, NULL },
>    /* Function calls made to this symbol must be done indirectly, because
> --- gcc/config/avr/avr.c.jj	2017-12-07 18:05:02.000000000 +0100
> +++ gcc/config/avr/avr.c	2017-12-08 11:24:32.270391537 +0100
> @@ -9875,7 +9875,7 @@ static const struct attribute_spec
>  avr_attribute_table[] =
>  {
>    /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
> -       affects_type_identity } */
> +       affects_type_identity, exclusions } */
>    { "progmem",   0, 0, false, false, false,  avr_handle_progmem_attribute,
>      false, NULL },
>    { "signal",    0, 0, true,  false, false,  avr_handle_fndecl_attribute,
> --- gcc/config/darwin.h.jj	2017-11-28 12:11:41.000000000 +0100
> +++ gcc/config/darwin.h	2017-12-08 11:18:05.866243854 +0100
> @@ -741,11 +741,11 @@ extern GTY(()) section * darwin_sections
>  /* Extra attributes for Darwin.  */
>  #define SUBTARGET_ATTRIBUTE_TABLE					     \
>    /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,     \
> -       affects_type_identity } */						     \
> +       affects_type_identity, exclusions } */				     \
>    { "apple_kext_compatibility", 0, 0, false, true, false,		     \
> -    darwin_handle_kext_attribute, false },				     \
> +    darwin_handle_kext_attribute, false, NULL },			     \
>    { "weak_import", 0, 0, true, false, false,				     \
> -    darwin_handle_weak_import_attribute, false }
> +    darwin_handle_weak_import_attribute, false, NULL }
>
>  /* Make local constant labels linker-visible, so that if one follows a
>     weak_global constant, ld64 will be able to separate the atoms.  */
> --- gcc/config/i386/cygming.h.jj	2017-10-30 12:02:35.000000000 +0100
> +++ gcc/config/i386/cygming.h	2017-12-08 11:25:12.372887945 +0100
> @@ -448,9 +448,9 @@ do {						\
>
>  #define SUBTARGET_ATTRIBUTE_TABLE \
>    { "selectany", 0, 0, true, false, false, ix86_handle_selectany_attribute, \
> -    false }
> +    false, NULL }
>    /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
> -       affects_type_identity } */
> +       affects_type_identity, exclusions } */
>
>  /*  mcount() does not need a counter variable.  */
>  #undef NO_PROFILE_COUNTERS
> --- gcc/config/msp430/msp430.c.jj	2017-12-07 18:05:03.000000000 +0100
> +++ gcc/config/msp430/msp430.c	2017-12-08 11:26:47.634691684 +0100
> @@ -2050,7 +2050,7 @@ msp430_data_attr (tree * node,
>  const struct attribute_spec msp430_attribute_table[] =
>  {
>    /* Name        min_num_args     type_req,             affects_type_identity
> -                      max_num_args,     fn_type_req
> +		      max_num_args,     fn_type_req		exclusions
>                            decl_req               handler.  */
>    { ATTR_INTR,        0, 1, true,  false, false, msp430_attr, false, NULL },
>    { ATTR_NAKED,       0, 0, true,  false, false, msp430_attr, false, NULL },
> --- gcc/config/rl78/rl78.c.jj	2017-12-07 18:05:03.000000000 +0100
> +++ gcc/config/rl78/rl78.c	2017-12-08 11:27:25.024222160 +0100
> @@ -858,7 +858,7 @@ rl78_handle_saddr_attribute (tree * node
>  const struct attribute_spec rl78_attribute_table[] =
>  {
>    /* Name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
> -     affects_type_identity.  */
> +     affects_type_identity, exclusions.  */
>    { "interrupt",      0, 0, true, false, false, rl78_handle_func_attribute,
>      false, NULL },
>    { "brk_interrupt",  0, 0, true, false, false, rl78_handle_func_attribute,
> --- gcc/config/nds32/nds32.c.jj	2017-12-07 18:05:02.000000000 +0100
> +++ gcc/config/nds32/nds32.c	2017-12-08 11:27:54.160856273 +0100
> @@ -83,7 +83,8 @@ static const char * const nds32_intrinsi
>  static const struct attribute_spec nds32_attribute_table[] =
>  {
>    /* Syntax: { name, min_len, max_len, decl_required, type_required,
> -	       function_type_required, handler, affects_type_identity } */
> +	       function_type_required, handler, affects_type_identity,
> +	       exclusions } */
>
>    /* The interrupt vid: [0-63]+ (actual vector number starts from 9 to 72).  */
>    { "interrupt",    1, 64, false, false, false, NULL, false, NULL },
> --- gcc/ada/gcc-interface/utils.c.jj	2017-12-07 18:04:59.000000000 +0100
> +++ gcc/ada/gcc-interface/utils.c	2017-12-08 11:29:11.796881349 +0100
> @@ -108,7 +108,7 @@ static tree fake_attribute_handler (tree
>  const struct attribute_spec gnat_internal_attribute_table[] =
>  {
>    /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
> -       affects_type_identity } */
> +       affects_type_identity, exclusions } */
>    { "const",        0, 0,  true,  false, false, handle_const_attribute,
>      false, NULL },
>    { "nothrow",      0, 0,  true,  false, false, handle_nothrow_attribute,
> --- gcc/brig/brig-lang.c.jj	2017-12-07 18:04:55.000000000 +0100
> +++ gcc/brig/brig-lang.c	2017-12-08 12:20:40.475998143 +0100
> @@ -448,7 +448,7 @@ brig_localize_identifier (const char *id
>  const struct attribute_spec brig_attribute_table[] =
>  {
>    /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
> -       do_diagnostic } */
> +       affects_type_identity, exclusions } */
>    { "leaf",		      0, 0, true,  false, false,
>  			      handle_leaf_attribute, false, NULL },
>    { "const",                  0, 0, true,  false, false,
>
>
> 	Jakub
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-12-08 16:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-08 16:14 [PATCH 0/3] improve detection of attribute conflicts (PR 81544) Martin Sebor
2017-08-16 23:00 ` [PATCH 4/3] " Martin Sebor
2017-08-18 14:06   ` Jonathan Wakely
2017-08-17  6:41 ` [PATCH 5/3] C++ bits to " Martin Sebor
2017-08-23  5:15   ` Jason Merrill
2017-08-23 15:30     ` Martin Sebor
2017-12-03 14:59       ` Martin Sebor
2017-12-05  3:21         ` Jason Merrill
2017-12-08  9:44         ` Rainer Orth
2017-12-08 10:13           ` Jakub Jelinek
2017-12-08 10:33             ` Rainer Orth
2017-12-08 11:31               ` Jakub Jelinek
2017-12-08 16:00                 ` Martin Sebor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).