This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Patch for a few small problems
- To: Jason Merrill <jason at cygnus dot com>
- Subject: Patch for a few small problems
- From: Mark Mitchell <mmitchell at usa dot net>
- Date: Mon, 2 Feb 1998 23:17:16 -0800
- Cc: egcs-bugs at cygnus dot com
- Reply-to: mmitchell at usa dot net
Here are patches for a few problems reported recently:
o Static inlines are sometimes incorrectly optimized away.
o Member functions named `realloc' cause crashes.
o Some expressions involving constant boolean variables are
not considered constant, but should be.
--
Mark Mitchell mmitchell@usa.net
Stanford University http://www.stanford.edu
gcc ChangeLog:
1998-02-02 Mark Mitchell <mmitchell@usa.net>
* calls.c (expand_call): Don't confuse member functions named
realloc, setjmp, and so forth with the standard library
functions of the same names.
cp ChangeLog:
Mon Feb 2 23:12:57 1998 Mark Mitchell <mmitchell@usa.net>
* cvt.c (ocp_convert): Obtain the constant values from constant
decls even if the destination type is the same as the type of the
decl.
* decl2.c (finish_file): Make sure that static inlines with
definitions are not marked DECL_EXTERNAL before returning.
Index: gcc/calls.c
===================================================================
RCS file: /home/mitchell/Repository/egcs/gcc/calls.c,v
retrieving revision 1.1.1.5
diff -c -p -r1.1.1.5 calls.c
*** calls.c 1998/01/24 03:57:59 1.1.1.5
--- calls.c 1998/02/03 04:44:36
*************** expand_call (exp, target, ignore)
*** 851,857 ****
is_longjmp = 0;
is_malloc = 0;
! if (name != 0 && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 15)
{
char *tname = name;
--- 851,861 ----
is_longjmp = 0;
is_malloc = 0;
! if (name != 0 && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 15
! /* Exclude functions not at the file scope, or not `extern',
! since they are not the magic functions we would otherwise
! think they are. */
! && DECL_CONTEXT (fndecl) == NULL_TREE && TREE_PUBLIC (fndecl))
{
char *tname = name;
Index: gcc/cp/cvt.c
===================================================================
RCS file: /home/mitchell/Repository/egcs/gcc/cp/cvt.c,v
retrieving revision 1.4
diff -c -p -r1.4 cvt.c
*** cvt.c 1998/01/28 01:32:40 1.4
--- cvt.c 1998/02/03 04:44:36
*************** ocp_convert (type, expr, convtype, flags
*** 980,985 ****
--- 980,988 ----
|| TREE_TYPE (e) == error_mark_node)
return error_mark_node;
+ if (TREE_READONLY_DECL_P (e))
+ e = decl_constant_value (e);
+
if (IS_AGGR_TYPE (type) && (convtype & CONV_FORCE_TEMP))
/* We need a new temporary; don't take this shortcut. */;
else if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e)))
*************** ocp_convert (type, expr, convtype, flags
*** 1013,1021 ****
if (TREE_CODE (e) == OFFSET_REF)
e = resolve_offset_ref (e);
- if (TREE_READONLY_DECL_P (e))
- e = decl_constant_value (e);
-
if (INTEGRAL_CODE_P (code))
{
tree intype = TREE_TYPE (e);
--- 1016,1021 ----
*************** ocp_convert (type, expr, convtype, flags
*** 1184,1190 ****
}
/* If TYPE or TREE_TYPE (E) is not on the permanent_obstack,
! then the it won't be hashed and hence compare as not equal,
even when it is. */
if (code == ARRAY_TYPE
&& TREE_TYPE (TREE_TYPE (e)) == TREE_TYPE (type)
--- 1184,1190 ----
}
/* If TYPE or TREE_TYPE (E) is not on the permanent_obstack,
! then it won't be hashed and hence compare as not equal,
even when it is. */
if (code == ARRAY_TYPE
&& TREE_TYPE (TREE_TYPE (e)) == TREE_TYPE (type)
Index: gcc/cp/decl2.c
===================================================================
RCS file: /home/mitchell/Repository/egcs/gcc/cp/decl2.c,v
retrieving revision 1.10
diff -c -p -r1.10 decl2.c
*** decl2.c 1998/01/30 00:53:47 1.10
--- decl2.c 1998/02/03 06:34:30
*************** finish_file ()
*** 3222,3227 ****
--- 3222,3228 ----
inline'. */
{
int reconsider = 1; /* More may be referenced; check again */
+ tree t;
while (reconsider)
{
*************** finish_file ()
*** 3284,3289 ****
--- 3285,3306 ----
else
p = &TREE_CHAIN (*p);
}
+ }
+
+ /* It's possible that some of the remaining inlines will still be
+ needed. For example, a static inline whose address is used in
+ the initializer for a file-scope static variable will be
+ needed. Code in compile_file will handle this, but we mustn't
+ pretend that there are no definitions for the inlines, or it
+ won't be able to. */
+ for (t = saved_inlines; t != NULL_TREE; t = TREE_CHAIN (t))
+ {
+ tree decl = TREE_VALUE (t);
+
+ if (DECL_NOT_REALLY_EXTERN (decl)
+ && !DECL_COMDAT (decl)
+ && DECL_INITIAL (decl) != NULL_TREE)
+ DECL_EXTERNAL (TREE_VALUE (t)) = 0;
}
}
Index: gcc/testsuite/g++.old-deja/g++.other/field1.C
===================================================================
RCS file: field1.C
diff -N field1.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- field1.C Mon Feb 2 22:54:18 1998
***************
*** 0 ****
--- 1,7 ----
+ // Build don't link:
+
+ struct X
+ {
+ static const bool b = true;
+ static const int i = b ? 1 : 2;
+ };
Index: gcc/testsuite/g++.old-deja/g++.other/init2.C
===================================================================
RCS file: init2.C
diff -N init2.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- init2.C Mon Feb 2 23:09:25 1998
***************
*** 0 ****
--- 1,20 ----
+ // Special g++ Options: -O3
+
+ typedef int (*fp)();
+
+ struct S
+ {
+ fp f;
+ };
+
+ static int f()
+ {
+ return 0;
+ }
+
+ static const S s = { &f };
+
+ int main()
+ {
+ return (*s.f)();
+ }
Index: gcc/testsuite/g++.old-deja/g++.other/realloc.C
===================================================================
RCS file: realloc.C
diff -N realloc.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- realloc.C Mon Feb 2 22:55:01 1998
***************
*** 0 ****
--- 1,14 ----
+ // Build don't link:
+
+ extern "C" void realloc();
+
+ class bug {
+ public:
+ void realloc(int foo,int bar);
+ };
+
+ int f() {
+ bug c;
+ c.realloc(50,50);
+ }
+