From 6d43d245fd27f68b4e093361006f1cd82af6e204 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Wed, 19 Nov 2008 10:59:14 +0000 Subject: [PATCH] extern reference variables may be uninitialized. [r23802] --- parser.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/parser.c b/parser.c index c068651..429d491 100644 --- a/parser.c +++ b/parser.c @@ -5211,11 +5211,16 @@ static void parse_declaration_rest(entity_t *ndeclaration, if (token.type == '=') { parse_init_declarator_rest(entity); } else if (entity->kind == ENTITY_VARIABLE) { - type_t *type = entity->declaration.type; - if (is_type_reference(skip_typeref(type))) { - errorf(&entity->base.source_position, - "reference '%#T' must be initialized", - type, entity->base.symbol); + /* ISO/IEC 14882:1998(E) §8.5.3:3 The initializer can be omitted + * [...] where the extern specifier is explicitly used. */ + declaration_t *decl = &entity->declaration; + if (decl->storage_class != STORAGE_CLASS_EXTERN) { + type_t *type = decl->type; + if (is_type_reference(skip_typeref(type))) { + errorf(&entity->base.source_position, + "reference '%#T' must be initialized", + type, entity->base.symbol); + } } } -- 2.20.1