From b19b4a787d30cce8e4b12e7e521ea642e680fa9d Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Tue, 4 Apr 1995 17:51:34 +0000 Subject: [PATCH] 63rd Cygnus<->FSF merge From-SVN: r9311 --- gcc/cp/ChangeLog | 34 ++++++++++++++++++++ gcc/cp/decl2.c | 4 +-- gcc/cp/init.c | 3 +- gcc/cp/parse.y | 5 +-- gcc/cp/repo.c | 83 ++++++++++++++++++++++++++++++++++++++++++------ gcc/cp/typeck.c | 47 +++++++++++++++------------ 6 files changed, 140 insertions(+), 36 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1f68bf6ca993..9b417031d3bb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,37 @@ +Mon Apr 3 16:55:08 1995 Jason Merrill + + * repo.c (get_base_filename): Take filename parm, fix logic bug. + + * typeck.c (build_compound_expr): Do not warn about a compound expr + in which the first expression has no side effects. + (build_x_compound_expr): Warn here instead. + (build_conditional_expr): Don't warn about a conditional expression + between an enum and the type it promotes to. + + * init.c (build_new): Handle initialization of arrays of builtins + properly. + +Mon Apr 3 15:08:04 1995 Brendan Kehoe (brendan@lisa.cygnus.com) + + * repo.c: Include config.h to get definitions of bcopy and rindex + on systems that don't have them (e.g., SVR4). + +Mon Apr 3 14:41:55 1995 Mike Stump + + * decl2.c (finish_table): Pass NULL_TREE instead of init to + finish_decl so that it won't try and do error checking on the + initializer. + +Mon Apr 3 10:45:50 1995 Jason Merrill + + * repo.c (get_base_filename): Analyze COLLECT_GCC_OPTIONS to + determine whether this compile used -c -o. + (open_repo_file): Use get_base_filename. Remove the extension. + (finish_repo): Spit out the values of main_input_filename, + COLLECT_GCC and COLLECT_GCC_OPTIONS. + + * parse.y (structsp): Add TYPENAME_KEYWORD complex_type_name. + Sun Apr 2 23:43:51 1995 Jason Merrill * search.c (compute_access): Don't try to do access control on diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index edce58023753..2a4068f9f2ce 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2291,7 +2291,7 @@ finish_table (name, type, init, publicp) DECL_INITIAL (empty_table) = init; asmspec = build_string (IDENTIFIER_LENGTH (DECL_NAME (empty_table)), IDENTIFIER_POINTER (DECL_NAME (empty_table))); - finish_decl (empty_table, init, asmspec, 0, 0); + finish_decl (empty_table, NULL_TREE, asmspec, 0, 0); } is_empty = 1; } @@ -2329,7 +2329,7 @@ finish_table (name, type, init, publicp) IDENTIFIER_POINTER (DECL_NAME (empty_table))); } - finish_decl (decl, init, asmspec, 0, 0); + finish_decl (decl, NULL_TREE, asmspec, 0, 0); return decl; } diff --git a/gcc/cp/init.c b/gcc/cp/init.c index e9771519d1aa..ee99ba2eb56e 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3082,7 +3082,8 @@ build_new (placement, decl, init, use_global_new) if (TYPE_NEEDS_CONSTRUCTING (type) || init) { - if (! TYPE_NEEDS_CONSTRUCTING (type) && ! IS_AGGR_TYPE (type)) + if (! TYPE_NEEDS_CONSTRUCTING (type) + && ! IS_AGGR_TYPE (type) && ! has_array) { /* New 2.0 interpretation: `new int (10)' means allocate an int, and initialize it with 10. */ diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index a4bbd55bdfb4..b28d9a137bdd 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -167,7 +167,7 @@ empty_parms () %nonassoc IF %nonassoc ELSE -%left IDENTIFIER TYPENAME PTYPENAME SCSPEC TYPESPEC TYPE_QUAL ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME +%left IDENTIFIER TYPENAME PTYPENAME SCSPEC TYPESPEC TYPE_QUAL ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD %left '{' ',' ';' @@ -2185,7 +2185,8 @@ structsp: { $$ = xref_tag (enum_type_node, $2, NULL_TREE, 1); } | ENUM complex_type_name { $$ = xref_tag (enum_type_node, $2, NULL_TREE, 1); } - + | TYPENAME_KEYWORD complex_type_name + { $$ = $2; } /* C++ extensions, merged with C to avoid shift/reduce conflicts */ | class_head left_curly opt.component_decl_list '}' { diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c index 78c8dddb20dc..9052eb89f9e0 100644 --- a/gcc/cp/repo.c +++ b/gcc/cp/repo.c @@ -22,18 +22,16 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ Everything should be emitted in a translation unit where it is used. The results of the automatic process should be easily reproducible with - explicit code. - - I'm thinking of compiling with -frepo, running a Perl script to update - files, and then being able to rebuild everything with -fno-implicit. - Full automation can come later. */ + explicit code. */ #include +#include "config.h" #include "tree.h" #include "cp-tree.h" #include "input.h" extern char * rindex (); +extern char * getenv (); static tree pending_repo; static char repo_name[1024]; @@ -157,12 +155,61 @@ repo_tinfo_used (ti) { } +static char * +save_string (s, len) + char *s; + int len; +{ + register char *result = xmalloc (len + 1); + + bcopy (s, result, len); + result[len] = 0; + return result; +} + +static char * +get_base_filename (filename) + char *filename; +{ + char *p = getenv ("COLLECT_GCC_OPTIONS"); + char *output = 0; + int compiling = 0; + + if (p) + while (*p) + { + char *q = p; + while (*q && *q != ' ') q++; + if (*p == '-' && p[1] == 'o') + { + p += 2; + if (p == q) + { + p++; q++; + if (*q) + while (*q && *q != ' ') q++; + } + + output = save_string (p, q - p); + } + else if (*p == '-' && p[1] == 'c') + compiling = 1; + if (*q) q++; + p = q; + } + + if (compiling && output) + return output; + + return save_string (filename, strlen (filename)); +} + static void open_repo_file (filename) char *filename; { register char *p, *q; - char *file = filename; + char *file = get_base_filename (filename); char *s = rindex (file, '/'); if (s == NULL) s = file; @@ -172,10 +219,15 @@ open_repo_file (filename) for (p = repo_name, q = file; q < s; ) *p++ = *q++; *p++ = '.'; - strcpy (p, q); + if ((s = rindex (q, '.')) == NULL) + strcpy (p, q); + else + for (; q < s;) + *p++ = *q++; strcat (p, ".repo"); repo_file = fopen (repo_name, "r"); + free (file); } void @@ -187,7 +239,7 @@ init_repo (filename) if (! flag_use_repository) return; - open_repo_file (filename); + open_repo_file (); if (repo_file == 0) return; @@ -202,6 +254,7 @@ init_repo (filename) switch (buf[0]) { case 'A': + case 'G': case 'M': break; case 'C': @@ -228,7 +281,7 @@ reopen_repo_file_for_write () if (repo_file == 0) { - error ("man't create repository information file `%s'", repo_name); + error ("can't create repository information file `%s'", repo_name); flag_use_repository = 0; } } @@ -239,7 +292,7 @@ void finish_repo () { tree t; - int changed = 0; + char *p; if (! flag_use_repository) return; @@ -254,6 +307,16 @@ finish_repo () if (repo_file == 0) goto out; + fprintf (repo_file, "M %s\n", main_input_filename); + + p = getenv ("COLLECT_GCC"); + if (p != 0) + fprintf (repo_file, "G %s\n", p); + + p = getenv ("COLLECT_GCC_OPTIONS"); + if (p != 0) + fprintf (repo_file, "A %s\n", p); + for (t = pending_repo; t; t = TREE_CHAIN (t)) { tree val = TREE_VALUE (t); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d83c3cba52e4..6f261e9338a2 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3483,6 +3483,9 @@ build_binary_op_nodefault (code, orig_op0, orig_op1, error_code) all the values of the unsigned type. */ if (! TREE_UNSIGNED (result_type)) /* OK */; + /* Do not warn if both operands are unsigned. */ + else if (op0_signed == op1_signed) + /* OK */; /* Do not warn if the signed quantity is an unsuffixed integer literal (or some static constant expression involving such literals) and it is non-negative. */ @@ -4592,11 +4595,13 @@ build_conditional_expr (ifexp, op1, op2) cp_error ("enumeral mismatch in conditional expression: `%T' vs `%T'", type1, type2); return error_mark_node; } - else if (extra_warnings && ! IS_AGGR_TYPE_CODE (code2)) + else if (extra_warnings && ! IS_AGGR_TYPE_CODE (code2) + && type2 != type_promotes_to (type1)) warning ("enumeral and non-enumeral type in conditional expression"); } else if (extra_warnings - && code2 == ENUMERAL_TYPE && ! IS_AGGR_TYPE_CODE (code1)) + && code2 == ENUMERAL_TYPE && ! IS_AGGR_TYPE_CODE (code1) + && type1 != type_promotes_to (type2)) warning ("enumeral and non-enumeral type in conditional expression"); if (code1 != VOID_TYPE) @@ -4828,6 +4833,22 @@ build_x_compound_expr (list) TREE_VALUE (list), TREE_VALUE (rest), NULL_TREE); if (result) return build_x_compound_expr (tree_cons (NULL_TREE, result, TREE_CHAIN (rest))); + + if (! TREE_SIDE_EFFECTS (TREE_VALUE (list))) + { + /* the left-hand operand of a comma expression is like an expression + statement: we should warn if it doesn't have any side-effects, + unless it was explicitly cast to (void). */ + if ((extra_warnings || warn_unused) + && !(TREE_CODE (TREE_VALUE(list)) == CONVERT_EXPR + && TREE_TYPE (TREE_VALUE(list)) == void_type_node)) + warning("left-hand operand of comma expression has no effect"); + } +#if 0 /* this requires a gcc backend patch to export warn_if_unused_value */ + else if (warn_unused) + warn_if_unused_value (TREE_VALUE(list)); +#endif + return build_compound_expr (tree_cons (NULL_TREE, TREE_VALUE (list), build_tree_list (NULL_TREE, build_x_compound_expr (rest)))); } @@ -4861,25 +4882,9 @@ build_compound_expr (list) rest = build_compound_expr (TREE_CHAIN (list)); - if (! TREE_SIDE_EFFECTS (TREE_VALUE (list))) - { - /* the left-hand operand of a comma expression is like an expression - statement: we should warn if it doesn't have any side-effects, - unless it was explicitly cast to (void). */ - if ((extra_warnings || warn_unused) - && !(TREE_CODE (TREE_VALUE(list)) == CONVERT_EXPR - && TREE_TYPE (TREE_VALUE(list)) == void_type_node)) - warning("left-hand operand of comma expression has no effect"); - - /* When pedantic, a compound expression can be neither an lvalue - nor an integer constant expression. */ - if (! pedantic) - return rest; - } -#if 0 /* this requires a gcc backend patch to export warn_if_unused_value */ - else if (warn_unused) - warn_if_unused_value (TREE_VALUE(list)); -#endif + /* When pedantic, a compound expression cannot be a constant expression. */ + if (! TREE_SIDE_EFFECTS (TREE_VALUE (list)) && ! pedantic) + return rest; return build (COMPOUND_EXPR, TREE_TYPE (rest), break_out_cleanups (TREE_VALUE (list)), rest); -- 2.43.5