static void
extract_attribute_substring (struct substring *str)
{
- if (str->length > 4 && str->str[0] == '_' && str->str[1] == '_'
- && str->str[str->length - 1] == '_' && str->str[str->length - 2] == '_')
- {
- str->length -= 4;
- str->str += 2;
- }
+ canonicalize_attr_name (str->str, str->length);
}
/* Insert an array of attributes ATTRIBUTES into a namespace. This
/* Attribute names in the table must be in the form 'text' and not
in the form '__text__'. */
- gcc_assert (str.length > 0 && str.str[0] != '_');
+ gcc_checking_assert (!canonicalize_attr_name (str.str, str.length));
slot = name_space->attribute_hash
->find_slot_with_hash (&str, substring_hash (str.str, str.length),
static inline tree
lookup_attribute (const char *attr_name, tree list)
{
- gcc_checking_assert (attr_name[0] != '_');
+ if (CHECKING_P && attr_name[0] != '_')
+ {
+ size_t attr_len = strlen (attr_name);
+ gcc_checking_assert (!canonicalize_attr_name (attr_name, attr_len));
+ }
/* In most cases, list is NULL_TREE. */
if (list == NULL_TREE)
return NULL_TREE;
size_t attr_len = strlen (attr_name);
while (list)
{
- size_t ident_len = IDENTIFIER_LENGTH (get_attribute_name (list));
+ tree name = get_attribute_name (list);
+ size_t ident_len = IDENTIFIER_LENGTH (name);
if (attr_len > ident_len)
{
continue;
}
- const char *p = IDENTIFIER_POINTER (get_attribute_name (list));
+ const char *p = IDENTIFIER_POINTER (name);
gcc_checking_assert (attr_len == 0 || p[0] != '_');
if (strncmp (attr_name, p, attr_len) == 0)
/* PR c++/101940 */
-/* { dg-do compile } */
-/* { dg-additional-options "-std=c++11" { target c++ } } */
+/* { dg-do compile { target { c || c++11 } } } */
/* { dg-additional-options "-Wno-attributes=company::,yoyodyne::attr" } */
/* { dg-additional-options "-Wno-attributes=c1::attr,c1::attr,c1::__attr__" } */
/* { dg-additional-options "-Wno-attributes=c2::,c2::attr" } */
/* PR c++/101940 */
-/* { dg-do compile } */
-/* { dg-additional-options "-std=c++11" { target c++ } } */
+/* { dg-do compile { target { c || c++11 } } } */
#pragma GCC diagnostic ignored_attributes "company::,yoyodyne::attr"
#pragma GCC diagnostic ignored_attributes "c1::attr,c1::attr,c1::__attr__"
--- /dev/null
+/* PR middle-end/103365 */
+/* { dg-do compile { target { c || c++11 } } } */
+/* { dg-additional-options "-Wno-attributes=foo::_bar" } */
+/* { dg-additional-options "-Wno-attributes=_foo::bar" } */
+
+[[foo::_bar]] void foo (void);
+[[_foo::bar]] void bar (void);
--- /dev/null
+/* PR middle-end/103365 */
+/* { dg-do compile { target { c || c++11 } } } */
+
+#pragma GCC diagnostic ignored_attributes "foo::_bar"
+#pragma GCC diagnostic ignored_attributes "_foo::bar"
+
+[[foo::_bar]] void foo (void);
+[[_foo::bar]] void bar (void);