From 316d4b547e6de0d43de81011508fe23aa009b38a Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 17 Jun 1998 18:52:18 +0000 Subject: [PATCH] typeck.c (build_binary_op_nodefault): Change % in format strings to %%. * typeck.c (build_binary_op_nodefault): Change % in format strings to %%. * decl.c (grokvardecl): Don't build_static_name for decls that aren't at namespace scope. * init.c (perform_member_init): Catch default-initialization of references. From-SVN: r20547 --- gcc/cp/ChangeLog | 13 ++++++++++++- gcc/cp/decl.c | 2 +- gcc/cp/init.c | 6 ++++++ gcc/cp/typeck.c | 4 ++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 318b7337178..f3e2cfb7f40 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +1998-06-17 Jason Merrill + + * typeck.c (build_binary_op_nodefault): Change % in format strings + to %%. + + * decl.c (grokvardecl): Don't build_static_name for decls that + aren't at namespace scope. + + * init.c (perform_member_init): Catch default-initialization of + references. + 1998-06-17 Mark Mitchell * errfn.c (cp_thing): Handle the `%%' formatting sequence. @@ -139,7 +150,7 @@ 1998-06-10 Jason Merrill - * init.c (resolve_offset_ref): Handle default-initialization. + * init.c (perform_member_init): Handle default-initialization. * except.c (build_throw): Handle throwing NULL. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 674d668471b..6e5b102345a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7848,7 +7848,7 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace) { tree context = in_namespace ? in_namespace : current_namespace; decl = build_decl (VAR_DECL, declarator, complete_type (type)); - if (context != global_namespace && declarator) + if (context != global_namespace && namespace_bindings_p ()) DECL_ASSEMBLER_NAME (decl) = build_static_name (context, declarator); } diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 84015b07efd..79891554421 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -200,6 +200,12 @@ perform_member_init (member, name, init, explicit) /* default-initialization. */ if (AGGREGATE_TYPE_P (type)) init = build (CONSTRUCTOR, type, NULL_TREE, NULL_TREE); + else if (TREE_CODE (type) == REFERENCE_TYPE) + { + cp_error ("default-initialization of `%#D', which has reference type", + member); + init = error_mark_node; + } else init = integer_zero_node; } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 65101266d31..5176c567112 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3354,9 +3354,9 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code) case TRUNC_MOD_EXPR: case FLOOR_MOD_EXPR: if (code1 == INTEGER_TYPE && integer_zerop (op1)) - cp_warning ("division by zero in `%E % 0'", op0); + cp_warning ("division by zero in `%E %% 0'", op0); else if (code1 == REAL_TYPE && real_zerop (op1)) - cp_warning ("division by zero in `%E % 0.'", op0); + cp_warning ("division by zero in `%E %% 0.'", op0); if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) { -- 2.30.2