aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/lex.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-03-09 08:16:49 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-03-09 08:16:49 +0000
commit58ec3cc5c0c441e0e8c49c029be9e25dcb1d853d (patch)
tree4053bda91421405c7881ecbb817f38fb71ebe500 /gcc/cp/lex.c
parentf1c4ca32d04cf16aa78c857acca00f7eebb9b9da (diff)
downloadgcc-58ec3cc5c0c441e0e8c49c029be9e25dcb1d853d.zip
gcc-58ec3cc5c0c441e0e8c49c029be9e25dcb1d853d.tar.gz
gcc-58ec3cc5c0c441e0e8c49c029be9e25dcb1d853d.tar.bz2
re PR c++/14401 (Uninitialized reference error not reported.)
PR c++/14401 * class.c (check_field_decls): Complain about non-static data members of reference type in unions. Propagate CLASSTYPE_REF_FIELDS_NEED_INIT and CLASSTYPE_READONLY_FIELDS_NEED_INIT from the types of non-static data members. * init.c (perform_member_init): Complain about mbmers with const type that are not explicitly initialized. PR c++/14401 * g++.dg/init/ctor3.C: New test. * g++.dg/init/union1.C: New test. * g++.dg/ext/anon-struct4.C: New test. From-SVN: r79158
Diffstat (limited to 'gcc/cp/lex.c')
-rw-r--r--gcc/cp/lex.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 2239c76..66e45ed 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -627,26 +627,18 @@ unqualified_name_lookup_error (tree name)
if (name != ansi_opname (ERROR_MARK))
error ("`%D' not defined", name);
}
- else if (current_function_decl == 0)
- error ("`%D' was not declared in this scope", name);
else
{
- if (IDENTIFIER_NAMESPACE_VALUE (name) != error_mark_node
- || IDENTIFIER_ERROR_LOCUS (name) != current_function_decl)
+ error ("`%D' was not declared in this scope", name);
+ /* Prevent repeated error messages by creating a VAR_DECL with
+ this NAME in the innermost block scope. */
+ if (current_function_decl)
{
- static int undeclared_variable_notice;
-
- error ("`%D' undeclared (first use this function)", name);
-
- if (! undeclared_variable_notice)
- {
- error ("(Each undeclared identifier is reported only once for each function it appears in.)");
- undeclared_variable_notice = 1;
- }
+ tree decl;
+ decl = build_decl (VAR_DECL, name, error_mark_node);
+ DECL_CONTEXT (decl) = current_function_decl;
+ push_local_binding (name, decl, 0);
}
- /* Prevent repeated error messages. */
- SET_IDENTIFIER_NAMESPACE_VALUE (name, error_mark_node);
- SET_IDENTIFIER_ERROR_LOCUS (name, current_function_decl);
}
return error_mark_node;