From 0c918ce59cdb3039f78d82bf848a311cac7cc5a3 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Wed, 4 Apr 2001 04:45:23 +0000 Subject: cp-tree.h (OPERATOR_ASSIGN_FORMAT): Remove. * cp-tree.h (OPERATOR_ASSIGN_FORMAT): Remove. (OPERATOR_FORMAT): Likewise. (OPERATOR_TYPENAME_FORMAT): Likewise. * operators.def: Remove old name-mangling information. * decl.c (grok_op_properties): Adjust accordingly. * lex.c (init_operators): Likewise. * rtti.c (get_tinfo_decl): Issue error messages about types that have variable size. From-SVN: r41076 --- gcc/cp/ChangeLog | 11 +++ gcc/cp/cp-tree.h | 4 - gcc/cp/decl.c | 22 ++--- gcc/cp/lex.c | 6 +- gcc/cp/operators.def | 120 ++++++++++++------------- gcc/cp/rtti.c | 8 ++ gcc/testsuite/g++.old-deja/g++.other/typeid1.C | 15 ++++ 7 files changed, 108 insertions(+), 78 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/typeid1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6439776..7821a08 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,16 @@ 2001-04-03 Mark Mitchell + * cp-tree.h (OPERATOR_ASSIGN_FORMAT): Remove. + (OPERATOR_FORMAT): Likewise. + (OPERATOR_TYPENAME_FORMAT): Likewise. + * operators.def: Remove old name-mangling information. + * decl.c (grok_op_properties): Adjust accordingly. + * lex.c (init_operators): Likewise. + * rtti.c (get_tinfo_decl): Issue error messages about types that + have variable size. + +2001-04-03 Mark Mitchell + * decl2.c (import_export_decl): Don't call import_export_class when processing an inline member function. * semantics.c (expand_body): Call import_export_decl before diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 449a3bd..6a7a9ca 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3237,10 +3237,6 @@ extern varray_type local_classes; /* Here's where we control how name mangling takes place. */ -#define OPERATOR_ASSIGN_FORMAT "__a%s" -#define OPERATOR_FORMAT "__%s" -#define OPERATOR_TYPENAME_FORMAT "__op" - /* Cannot use '$' up front, because this confuses gdb (names beginning with '$' are gdb-local identifiers). diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b96545d..58844cb 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12099,17 +12099,17 @@ grok_op_properties (decl, virtualp, friendp) else do { -#define DEF_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGING, ARITY, ASSN_P) \ - if (ansi_opname (CODE) == name) \ - { \ - operator_code = CODE; \ - break; \ - } \ - else if (ansi_assopname (CODE) == name) \ - { \ - operator_code = CODE; \ - DECL_ASSIGNMENT_OPERATOR_P (decl) = 1; \ - break; \ +#define DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, ASSN_P) \ + if (ansi_opname (CODE) == name) \ + { \ + operator_code = CODE; \ + break; \ + } \ + else if (ansi_assopname (CODE) == name) \ + { \ + operator_code = CODE; \ + DECL_ASSIGNMENT_OPERATOR_P (decl) = 1; \ + break; \ } #include "operators.def" diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 97f7460..ef9314c 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -313,7 +313,7 @@ operator_name_info_t assignment_operator_name_info[(int) LAST_CPLUS_TREE_CODE]; /* Initialize data structures that keep track of operator names. */ -#define DEF_OPERATOR(NAME, C, NM, OM, AR, AP) \ +#define DEF_OPERATOR(NAME, C, M, AR, AP) \ CONSTRAINT (C, sizeof "operator " + sizeof NAME <= 256); #include "operators.def" #undef DEF_OPERATOR @@ -325,7 +325,7 @@ init_operators () char buffer[256]; struct operator_name_info_t *oni; -#define DEF_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY, ASSN_P) \ +#define DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, ASSN_P) \ sprintf (buffer, ISALPHA (NAME[0]) ? "operator %s" : "operator%s", NAME); \ identifier = get_identifier (buffer); \ IDENTIFIER_OPNAME_P (identifier) = 1; \ @@ -335,7 +335,7 @@ init_operators () : &operator_name_info[(int) CODE]); \ oni->identifier = identifier; \ oni->name = NAME; \ - oni->mangled_name = NEW_MANGLING; + oni->mangled_name = MANGLING; #include "operators.def" #undef DEF_OPERATOR diff --git a/gcc/cp/operators.def b/gcc/cp/operators.def index 2fbb421..ddae93a 100644 --- a/gcc/cp/operators.def +++ b/gcc/cp/operators.def @@ -5,7 +5,7 @@ non-overloadable operators (like the `?:' ternary operator). Writtey by Mark Mitchell - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 2001 Free Software Foundation, Inc. This file is part of GNU CC. @@ -71,84 +71,84 @@ Boston, MA 02111-1307, USA. */ arguments are as for DEF_OPERATOR, but there is no need to provide an ASSIGNMENT_P argument; it is always zero. */ -#define DEF_SIMPLE_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY) \ - DEF_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY, 0) +#define DEF_SIMPLE_OPERATOR(NAME, CODE, MANGLING, ARITY) \ + DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, 0) /* Use DEF_ASSN_OPERATOR to define an assignment operator. Its arguments are as for DEF_OPERATOR, but there is no need to provide an ASSIGNMENT_P argument; it is always one. */ -#define DEF_ASSN_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY) \ - DEF_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY, 1) +#define DEF_ASSN_OPERATOR(NAME, CODE, MANGLING, ARITY) \ + DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, 1) /* Memory allocation operators. */ -DEF_SIMPLE_OPERATOR ("new", NEW_EXPR, "nw", "__nw", -1) -DEF_SIMPLE_OPERATOR ("new []", VEC_NEW_EXPR, "na", "__vn", -1) -DEF_SIMPLE_OPERATOR ("delete", DELETE_EXPR, "dl", "__dl", -1) -DEF_SIMPLE_OPERATOR ("delete []", VEC_DELETE_EXPR, "da", "__vd", -1) +DEF_SIMPLE_OPERATOR ("new", NEW_EXPR, "nw", -1) +DEF_SIMPLE_OPERATOR ("new []", VEC_NEW_EXPR, "na", -1) +DEF_SIMPLE_OPERATOR ("delete", DELETE_EXPR, "dl", -1) +DEF_SIMPLE_OPERATOR ("delete []", VEC_DELETE_EXPR, "da", -1) /* Unary operators. */ -DEF_SIMPLE_OPERATOR ("+", CONVERT_EXPR, "ps", "__pl", 1) -DEF_SIMPLE_OPERATOR ("-", NEGATE_EXPR, "ng", "__mi", 1) -DEF_SIMPLE_OPERATOR ("&", ADDR_EXPR, "ad", "__ad", 1) -DEF_SIMPLE_OPERATOR ("*", INDIRECT_REF, "de", "__ml", 1) -DEF_SIMPLE_OPERATOR ("~", BIT_NOT_EXPR, "co", "__co", 1) -DEF_SIMPLE_OPERATOR ("!", TRUTH_NOT_EXPR, "nt", "__nt", 1) -DEF_SIMPLE_OPERATOR ("++", PREINCREMENT_EXPR, "pp", "__pp", 1) -DEF_SIMPLE_OPERATOR ("--", PREDECREMENT_EXPR, "mm", "__mm", 1) -DEF_SIMPLE_OPERATOR ("sizeof", SIZEOF_EXPR, "sz", "__sz", 1) +DEF_SIMPLE_OPERATOR ("+", CONVERT_EXPR, "ps", 1) +DEF_SIMPLE_OPERATOR ("-", NEGATE_EXPR, "ng", 1) +DEF_SIMPLE_OPERATOR ("&", ADDR_EXPR, "ad", 1) +DEF_SIMPLE_OPERATOR ("*", INDIRECT_REF, "de", 1) +DEF_SIMPLE_OPERATOR ("~", BIT_NOT_EXPR, "co", 1) +DEF_SIMPLE_OPERATOR ("!", TRUTH_NOT_EXPR, "nt", 1) +DEF_SIMPLE_OPERATOR ("++", PREINCREMENT_EXPR, "pp", 1) +DEF_SIMPLE_OPERATOR ("--", PREDECREMENT_EXPR, "mm", 1) +DEF_SIMPLE_OPERATOR ("sizeof", SIZEOF_EXPR, "sz", 1) /* This is an extension. */ -DEF_SIMPLE_OPERATOR ("alignof", ALIGNOF_EXPR, "v17alignof", "__al", 1) +DEF_SIMPLE_OPERATOR ("alignof", ALIGNOF_EXPR, "v17alignof", 1) /* The cast operator. */ -DEF_SIMPLE_OPERATOR ("", TYPE_EXPR, "cv", OPERATOR_TYPENAME_FORMAT, 1) +DEF_SIMPLE_OPERATOR ("", TYPE_EXPR, "cv", 1) /* Binary operators. */ -DEF_SIMPLE_OPERATOR ("+", PLUS_EXPR, "pl", "__pl", 2) -DEF_SIMPLE_OPERATOR ("-", MINUS_EXPR, "mi", "__mi", 2) -DEF_SIMPLE_OPERATOR ("*", MULT_EXPR, "ml", "__ml", 2) -DEF_SIMPLE_OPERATOR ("/", TRUNC_DIV_EXPR, "dv", "__dv", 2) -DEF_SIMPLE_OPERATOR ("%", TRUNC_MOD_EXPR, "rm", "__md", 2) -DEF_SIMPLE_OPERATOR ("&", BIT_AND_EXPR, "an", "__ad", 2) -DEF_SIMPLE_OPERATOR ("|", BIT_IOR_EXPR, "or", "__or", 2) -DEF_SIMPLE_OPERATOR ("^", BIT_XOR_EXPR, "eo", "__er", 2) -DEF_SIMPLE_OPERATOR ("<<", LSHIFT_EXPR, "ls", "__ls", 2) -DEF_SIMPLE_OPERATOR (">>", RSHIFT_EXPR, "rs", "__rs", 2) -DEF_SIMPLE_OPERATOR ("==", EQ_EXPR, "eq", "__eq", 2) -DEF_SIMPLE_OPERATOR ("!=", NE_EXPR, "ne", "__ne", 2) -DEF_SIMPLE_OPERATOR ("<", LT_EXPR, "lt", "__lt", 2) -DEF_SIMPLE_OPERATOR (">", GT_EXPR, "gt", "__gt", 2) -DEF_SIMPLE_OPERATOR ("<=", LE_EXPR, "le", "__le", 2) -DEF_SIMPLE_OPERATOR (">=", GE_EXPR, "ge", "__ge", 2) -DEF_SIMPLE_OPERATOR ("&&", TRUTH_ANDIF_EXPR, "aa", "__aa", 2) -DEF_SIMPLE_OPERATOR ("||", TRUTH_ORIF_EXPR, "oo", "__oo", 2) -DEF_SIMPLE_OPERATOR (",", COMPOUND_EXPR, "cm", "__cm", 2) -DEF_SIMPLE_OPERATOR ("->*", MEMBER_REF, "pm", "__rm", 2) -DEF_SIMPLE_OPERATOR ("->", COMPONENT_REF, "pt", "__rf", 2) -DEF_SIMPLE_OPERATOR ("[]", ARRAY_REF, "ix", "__vc", 2) -DEF_SIMPLE_OPERATOR ("++", POSTINCREMENT_EXPR, "pp", "__pp", 2) -DEF_SIMPLE_OPERATOR ("--", POSTDECREMENT_EXPR, "mm", "__mm", 2) +DEF_SIMPLE_OPERATOR ("+", PLUS_EXPR, "pl", 2) +DEF_SIMPLE_OPERATOR ("-", MINUS_EXPR, "mi", 2) +DEF_SIMPLE_OPERATOR ("*", MULT_EXPR, "ml", 2) +DEF_SIMPLE_OPERATOR ("/", TRUNC_DIV_EXPR, "dv", 2) +DEF_SIMPLE_OPERATOR ("%", TRUNC_MOD_EXPR, "rm", 2) +DEF_SIMPLE_OPERATOR ("&", BIT_AND_EXPR, "an", 2) +DEF_SIMPLE_OPERATOR ("|", BIT_IOR_EXPR, "or", 2) +DEF_SIMPLE_OPERATOR ("^", BIT_XOR_EXPR, "eo", 2) +DEF_SIMPLE_OPERATOR ("<<", LSHIFT_EXPR, "ls", 2) +DEF_SIMPLE_OPERATOR (">>", RSHIFT_EXPR, "rs", 2) +DEF_SIMPLE_OPERATOR ("==", EQ_EXPR, "eq", 2) +DEF_SIMPLE_OPERATOR ("!=", NE_EXPR, "ne", 2) +DEF_SIMPLE_OPERATOR ("<", LT_EXPR, "lt", 2) +DEF_SIMPLE_OPERATOR (">", GT_EXPR, "gt", 2) +DEF_SIMPLE_OPERATOR ("<=", LE_EXPR, "le", 2) +DEF_SIMPLE_OPERATOR (">=", GE_EXPR, "ge", 2) +DEF_SIMPLE_OPERATOR ("&&", TRUTH_ANDIF_EXPR, "aa", 2) +DEF_SIMPLE_OPERATOR ("||", TRUTH_ORIF_EXPR, "oo", 2) +DEF_SIMPLE_OPERATOR (",", COMPOUND_EXPR, "cm", 2) +DEF_SIMPLE_OPERATOR ("->*", MEMBER_REF, "pm", 2) +DEF_SIMPLE_OPERATOR ("->", COMPONENT_REF, "pt", 2) +DEF_SIMPLE_OPERATOR ("[]", ARRAY_REF, "ix", 2) +DEF_SIMPLE_OPERATOR ("++", POSTINCREMENT_EXPR, "pp", 2) +DEF_SIMPLE_OPERATOR ("--", POSTDECREMENT_EXPR, "mm", 2) /* These are extensions. */ -DEF_SIMPLE_OPERATOR ("?", MAX_EXPR, "v23max", "__mx", 2) +DEF_SIMPLE_OPERATOR ("?", MAX_EXPR, "v23max", 2) /* This one is needed for mangling. */ -DEF_SIMPLE_OPERATOR ("::", SCOPE_REF, "sr", NULL, 2); +DEF_SIMPLE_OPERATOR ("::", SCOPE_REF, "sr", 2); /* Assignment operators. */ -DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS", "__as", 2) -DEF_ASSN_OPERATOR ("+=", PLUS_EXPR, "pL", "__apl", 2) -DEF_ASSN_OPERATOR ("-=", MINUS_EXPR, "mI", "__ami", 2) -DEF_ASSN_OPERATOR ("*=", MULT_EXPR, "mL", "__aml", 2) -DEF_ASSN_OPERATOR ("/=", TRUNC_DIV_EXPR, "dV", "__adv", 2) -DEF_ASSN_OPERATOR ("%=", TRUNC_MOD_EXPR, "rM", "__amd", 2) -DEF_ASSN_OPERATOR ("&=", BIT_AND_EXPR, "aN", "__aad", 2) -DEF_ASSN_OPERATOR ("|=", BIT_IOR_EXPR, "oR", "__aor", 2) -DEF_ASSN_OPERATOR ("^=", BIT_XOR_EXPR, "eO", "__aer", 2) -DEF_ASSN_OPERATOR ("<<=", LSHIFT_EXPR, "lS", "__als", 2) -DEF_ASSN_OPERATOR (">>=", RSHIFT_EXPR, "rS", "__ars", 2) +DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS", 2) +DEF_ASSN_OPERATOR ("+=", PLUS_EXPR, "pL", 2) +DEF_ASSN_OPERATOR ("-=", MINUS_EXPR, "mI", 2) +DEF_ASSN_OPERATOR ("*=", MULT_EXPR, "mL", 2) +DEF_ASSN_OPERATOR ("/=", TRUNC_DIV_EXPR, "dV", 2) +DEF_ASSN_OPERATOR ("%=", TRUNC_MOD_EXPR, "rM", 2) +DEF_ASSN_OPERATOR ("&=", BIT_AND_EXPR, "aN", 2) +DEF_ASSN_OPERATOR ("|=", BIT_IOR_EXPR, "oR", 2) +DEF_ASSN_OPERATOR ("^=", BIT_XOR_EXPR, "eO", 2) +DEF_ASSN_OPERATOR ("<<=", LSHIFT_EXPR, "lS", 2) +DEF_ASSN_OPERATOR (">>=", RSHIFT_EXPR, "rS", 2) /* Ternary operators. */ -DEF_SIMPLE_OPERATOR ("?:", COND_EXPR, "qu", "__cn", 3) +DEF_SIMPLE_OPERATOR ("?:", COND_EXPR, "qu", 3) /* Miscellaneous. */ -DEF_SIMPLE_OPERATOR ("()", CALL_EXPR, "cl", "__cl", -1) +DEF_SIMPLE_OPERATOR ("()", CALL_EXPR, "cl", -1) diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 0cb3775..1550e42 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -325,6 +325,14 @@ get_tinfo_decl (type) tree name; tree d; + if (COMPLETE_TYPE_P (type) + && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) + { + cp_error ("cannot create type information for type `%T' because its size is variable", + type); + return error_mark_node; + } + if (TREE_CODE (type) == OFFSET_TYPE) type = TREE_TYPE (type); if (TREE_CODE (type) == METHOD_TYPE) diff --git a/gcc/testsuite/g++.old-deja/g++.other/typeid1.C b/gcc/testsuite/g++.old-deja/g++.other/typeid1.C new file mode 100644 index 0000000..e50f3c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typeid1.C @@ -0,0 +1,15 @@ +// Build don't link: +// Origin: sk@gluit.de +// Special g++ Options: + +#include + +int main () +{ + typeid(char*); + + int len = 1; + char carr[len]; + typeid(typeof(carr)); // ERROR - type has variable size + typeid(carr); // ERROR - type has variable size +} -- cgit v1.1