From: Moritz Kroll Date: Tue, 5 Aug 2008 00:32:07 +0000 (+0000) Subject: Fixed visibility of inline functions X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=3cffc6ff88fd43a8c0204b811a80b4aabb3b0290;p=cparser Fixed visibility of inline functions [r20974] --- diff --git a/ast2firm.c b/ast2firm.c index 655f6d4..85aa6b9 100644 --- a/ast2firm.c +++ b/ast2firm.c @@ -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 */ diff --git a/parsetest/cp_error037.c b/parsetest/cp_error037.c index 976e3bc..42edf67 100644 --- a/parsetest/cp_error037.c +++ b/parsetest/cp_error037.c @@ -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) {