aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r--gcc/cp/tree.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index c6f216d..e74b79c 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -4428,6 +4428,31 @@ handle_nodiscard_attribute (tree *node, tree name, tree /*args*/,
return NULL_TREE;
}
+/* Handle a C++2a "no_unique_address" attribute; arguments as in
+ struct attribute_spec.handler. */
+static tree
+handle_no_unique_addr_attribute (tree* node,
+ tree name,
+ tree /*args*/,
+ int /*flags*/,
+ bool* no_add_attrs)
+{
+ if (TREE_CODE (*node) != FIELD_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute can only be applied to "
+ "non-static data members", name);
+ *no_add_attrs = true;
+ }
+ else if (DECL_C_BIT_FIELD (*node))
+ {
+ warning (OPT_Wattributes, "%qE attribute cannot be applied to "
+ "a bit-field", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
/* Table of valid C++ attributes. */
const struct attribute_spec cxx_attribute_table[] =
{
@@ -4449,6 +4474,8 @@ const struct attribute_spec std_attribute_table[] =
handle_unused_attribute, NULL },
{ "nodiscard", 0, 0, false, false, false, false,
handle_nodiscard_attribute, NULL },
+ { "no_unique_address", 0, 0, true, false, false, false,
+ handle_no_unique_addr_attribute, NULL },
{ NULL, 0, 0, false, false, false, false, NULL, NULL }
};