aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorDoug Evans <dje@gnu.org>1994-02-17 22:48:50 +0000
committerDoug Evans <dje@gnu.org>1994-02-17 22:48:50 +0000
commit5289b66589cf2d63bf7cc780322d2d81e198970b (patch)
treea6087e66778ee48340da0f8fdb1208517275e3b6 /gcc/c-common.c
parent7ffa4f13f0dd735da844b9ce261cb2b320b6771b (diff)
downloadgcc-5289b66589cf2d63bf7cc780322d2d81e198970b.zip
gcc-5289b66589cf2d63bf7cc780322d2d81e198970b.tar.gz
gcc-5289b66589cf2d63bf7cc780322d2d81e198970b.tar.bz2
(decl_attributes): Decode section attribute.
From-SVN: r6582
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 73ae7eb..492ccfc 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -207,6 +207,7 @@ decl_attributes (decl, attributes)
tree decl, attributes;
{
tree a;
+
for (a = attributes; a; a = TREE_CHAIN (a))
if (TREE_VALUE (a) == get_identifier ("packed"))
{
@@ -255,6 +256,32 @@ decl_attributes (decl, attributes)
}
else if (TREE_VALUE (a) != 0
&& TREE_CODE (TREE_VALUE (a)) == TREE_LIST
+ && TREE_PURPOSE (TREE_VALUE (a)) == get_identifier ("section"))
+ {
+#ifdef ASM_OUTPUT_SECTION_NAME
+ if (TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
+ {
+ if (TREE_CODE (decl) == VAR_DECL && current_function_decl != NULL_TREE)
+ error ("section attribute cannot be specified for local variables");
+ /* The decl may have already been given a section attribute from
+ a previous declaration. Ensure they match. */
+ else if (DECL_SECTION_NAME (decl) != NULL_TREE
+ && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)),
+ TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (a)))) != 0)
+ error_with_decl (decl,
+ "section of `%s' conflicts with previous declaration");
+ else
+ DECL_SECTION_NAME (decl) = TREE_VALUE (TREE_VALUE (a));
+ }
+ else
+ error_with_decl (decl,
+ "section attribute not allowed for `%s'");
+#else
+ error_with_decl (decl, "section attributes are not supported for this target");
+#endif
+ }
+ else if (TREE_VALUE (a) != 0
+ && TREE_CODE (TREE_VALUE (a)) == TREE_LIST
&& TREE_PURPOSE (TREE_VALUE (a)) == get_identifier ("aligned"))
{
tree align_expr = TREE_VALUE (TREE_VALUE (a));