diff mbox

PATCH to attribute_takes_identifier_p for c++/46803

Message ID 4D7A95A6.8060605@redhat.com
State New
Headers show

Commit Message

Jason Merrill March 11, 2011, 9:35 p.m. UTC
In 46803 we have an unknown attribute that apparently takes an 
identifier as its first argument; since my introduction of 
attribute_takes_identifier_p, we assume that most attributes do not take 
an identifier as their first argument.  But it won't hurt to assume the 
contrary for unknown attributes, since we're just going to ignore them 
anyway.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit c530bce3d9db3b334ea12bde6cb17e95f0048636
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Mar 11 14:09:30 2011 -0500

    	PR c++/46803
    	* c-common.c (attribute_takes_identifier_p): Assume that an
    	unknown attribute takes an identifier.
diff mbox

Patch

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index f029661..32b9a70 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -5665,9 +5665,14 @@  c_init_attributes (void)
 bool
 attribute_takes_identifier_p (const_tree attr_id)
 {
-  if (is_attribute_p ("mode", attr_id)
-      || is_attribute_p ("format", attr_id)
-      || is_attribute_p ("cleanup", attr_id))
+  struct attribute_spec *spec = lookup_attribute_spec (attr_id);
+  if (spec == NULL)
+    /* Unknown attribute that we'll end up ignoring, return true so we
+       don't complain about an identifier argument.  */
+    return true;
+  else if (!strcmp ("mode", spec->name)
+	   || !strcmp ("format", spec->name)
+	   || !strcmp ("cleanup", spec->name))
     return true;
   else
     return targetm.attribute_takes_identifier_p (attr_id);
diff --git a/gcc/testsuite/g++.dg/ext/attrib40.C b/gcc/testsuite/g++.dg/ext/attrib40.C
new file mode 100644
index 0000000..9c3f761
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/attrib40.C
@@ -0,0 +1,4 @@ 
+// PR c++/46803
+
+int strftime(char *, int, const char *, const struct tm *)
+        __attribute__ ((__bounded__(__string__,1,2))); // { dg-warning "ignored" }