Handle __attribute__((used)) for functions, i.e. make the function entity sticky.
authorChristoph Mallon <christoph.mallon@gmx.de>
Wed, 13 Aug 2008 07:28:32 +0000 (07:28 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Wed, 13 Aug 2008 07:28:32 +0000 (07:28 +0000)
[r21135]

ast2firm.c
ast_t.h
parser.c

index e9d4267..da71dfb 100644 (file)
@@ -1012,6 +1012,10 @@ static ir_entity *get_function_entity(declaration_t *declaration)
        entity               = new_d_entity(global_type, id, ir_type_method, dbgi);
        set_entity_ld_ident(entity, create_ld_ident(entity, declaration));
 
+       if (declaration->modifiers & DM_USED) {
+               set_entity_stickyness(entity, stickyness_sticky);
+       }
+
        /* static inline             => local
         * extern inline             => local
         * inline without definition => local
diff --git a/ast_t.h b/ast_t.h
index aa5a8bb..340e340 100644 (file)
--- a/ast_t.h
+++ b/ast_t.h
@@ -510,24 +510,25 @@ typedef enum gnu_attribute_kind_t {
  * Extended microsoft modifier.
  */
 typedef enum {
-       DM_DLLIMPORT         = (1 <<  0),
-       DM_DLLEXPORT         = (1 <<  1),
-       DM_THREAD            = (1 <<  2),
-       DM_NAKED             = (1 <<  3),
-       DM_MICROSOFT_INLINE  = (1 <<  4),
-       DM_FORCEINLINE       = (1 <<  5),
-       DM_SELECTANY         = (1 <<  6),
-       DM_NOTHROW           = (1 <<  7),
-       DM_NOVTABLE          = (1 <<  8),
-       DM_NORETURN          = (1 <<  9),
-       DM_NOINLINE          = (1 << 10),
-       DM_RESTRICT          = (1 << 11),
-       DM_NOALIAS           = (1 << 12),
-       DM_PACKED            = (1 << 13),
-       DM_TRANSPARENT_UNION = (1 << 14),
-       DM_PURE              = (1 << 15),
-       DM_CONSTRUCTOR       = (1 << 16),
-       DM_DESTRUCTOR        = (1 << 17)
+       DM_DLLIMPORT         = 1 <<  0,
+       DM_DLLEXPORT         = 1 <<  1,
+       DM_THREAD            = 1 <<  2,
+       DM_NAKED             = 1 <<  3,
+       DM_MICROSOFT_INLINE  = 1 <<  4,
+       DM_FORCEINLINE       = 1 <<  5,
+       DM_SELECTANY         = 1 <<  6,
+       DM_NOTHROW           = 1 <<  7,
+       DM_NOVTABLE          = 1 <<  8,
+       DM_NORETURN          = 1 <<  9,
+       DM_NOINLINE          = 1 << 10,
+       DM_RESTRICT          = 1 << 11,
+       DM_NOALIAS           = 1 << 12,
+       DM_PACKED            = 1 << 13,
+       DM_TRANSPARENT_UNION = 1 << 14,
+       DM_PURE              = 1 << 15,
+       DM_CONSTRUCTOR       = 1 << 16,
+       DM_DESTRUCTOR        = 1 << 17,
+       DM_USED              = 1 << 18
 } decl_modifier_t;
 
 typedef unsigned decl_modifiers_t;
index 47556d6..bc22feb 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1555,7 +1555,6 @@ static decl_modifiers_t parse_gnu_attribute(gnu_attribute_t **attributes)
                                case GNU_AK_NOCOMMON:
                                case GNU_AK_SHARED:
                                case GNU_AK_NOTSHARED:
-                               case GNU_AK_USED:
                                case GNU_AK_UNUSED:
                                case GNU_AK_NO_INSTRUMENT_FUNCTION:
                                case GNU_AK_WARN_UNUSED_RESULT:
@@ -1583,6 +1582,11 @@ static decl_modifiers_t parse_gnu_attribute(gnu_attribute_t **attributes)
                                        check_no_argument(attribute, name);
                                        break;
 
+                               case GNU_AK_USED:
+                                       modifiers |= DM_USED;
+                                       check_no_argument(attribute, name);
+                                       break;
+
                                case GNU_AK_PURE:
                                        check_no_argument(attribute, name);
                                        modifiers |= DM_PURE;