Fixed visibility of inline functions
authorMoritz Kroll <Moritz.Kroll@gmx.de>
Tue, 5 Aug 2008 00:32:07 +0000 (00:32 +0000)
committerMoritz Kroll <Moritz.Kroll@gmx.de>
Tue, 5 Aug 2008 00:32:07 +0000 (00:32 +0000)
[r20974]

ast2firm.c
parsetest/cp_error037.c

index 655f6d4..85aa6b9 100644 (file)
@@ -998,7 +998,16 @@ 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->storage_class == STORAGE_CLASS_STATIC
+       /* static inline             => local
+        * extern inline             => local
+        * inline without definition => local
+        * inline with definition    => external_visible */
+
+       if (declaration->is_inline && declaration->storage_class == STORAGE_CLASS_NONE
+                       && declaration->init.statement != NULL) {
+               set_entity_visibility(entity, visibility_external_visible);
+       }
+       else if (declaration->storage_class == STORAGE_CLASS_STATIC
                        || declaration->is_inline) {
                if (declaration->init.statement == NULL) {
                        /* this entity was declared, but is defined nowhere */
index 976e3bc..42edf67 100644 (file)
@@ -1,4 +1,13 @@
 extern __inline__ unsigned int ntohl(unsigned int);
+__inline__ unsigned int ntohl2(unsigned int);
+static __inline__ unsigned int ntohl3(unsigned int);
+
+extern __inline__ unsigned int xntohl(unsigned int a) { return 1; }
+__inline__ unsigned int xntohl2(unsigned int a) { return 2; }
+static __inline__ unsigned int xntohl3(unsigned int a) { return 3; }
+
+// only xntohl2 should be globally visible
+// the others should not even exist in the object file
 
 int main(void)
 {