This commit is contained in:
Jakub Jelinek 2007-12-02 19:05:44 +00:00
parent d8d9cbe2d6
commit 6d24351ab8
5 changed files with 345 additions and 1 deletions

68
gcc41-pr34213.patch Normal file
View File

@ -0,0 +1,68 @@
2007-11-27 Jakub Jelinek <jakub@redhat.com>
PR c++/34213
* tree.c (decl_linkage): Static data members and static member
functions in anonymous ns classes are lk_external.
* g++.dg/ext/visibility/anon8.C: New test.
--- gcc/cp/tree.c (revision 130462)
+++ gcc/cp/tree.c (revision 130463)
@@ -2526,10 +2526,18 @@ decl_linkage (tree decl)
/* Members of the anonymous namespace also have TREE_PUBLIC unset, but
are considered to have external linkage for language purposes. DECLs
really meant to have internal linkage have DECL_THIS_STATIC set. */
- if (TREE_CODE (decl) == TYPE_DECL
- || ((TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
- && !DECL_THIS_STATIC (decl)))
+ if (TREE_CODE (decl) == TYPE_DECL)
return lk_external;
+ if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ if (!DECL_THIS_STATIC (decl))
+ return lk_external;
+
+ /* Static data members and static member functions from classes
+ in anonymous namespace also don't have TREE_PUBLIC set. */
+ if (DECL_CLASS_CONTEXT (decl))
+ return lk_external;
+ }
/* Everything else has internal linkage. */
return lk_internal;
--- gcc/testsuite/g++.dg/ext/visibility/anon8.C (revision 0)
+++ gcc/testsuite/g++.dg/ext/visibility/anon8.C (revision 130463)
@@ -0,0 +1,33 @@
+// PR c++/34213
+// { dg-do compile }
+
+template <void (*fn) ()>
+void call ()
+{
+ fn ();
+}
+
+namespace
+{
+ struct B1
+ {
+ static void fn1 () {}
+ static void fn4 ();
+ };
+ void fn3 () {}
+ void B1::fn4 () {}
+ static void fn5 () {}
+}
+
+int main ()
+{
+ struct B2
+ {
+ static void fn2 () {}
+ };
+ call<&B1::fn1> ();
+ call<&B2::fn2> (); // { dg-error "not external linkage|no matching" }
+ call<&fn3> ();
+ call<&B1::fn4> ();
+ call<&fn5> (); // { dg-error "not external linkage|no matching" }
+}

34
gcc41-pr34238.patch Normal file
View File

@ -0,0 +1,34 @@
2007-11-26 Jakub Jelinek <jakub@redhat.com>
PR c++/34238
* decl2.c (cp_write_global_declarations): Test
!DECL_INITIALIZED_IN_CLASS_P instead of checking NULL
DECL_INITIAL.
* g++.dg/ext/visibility/anon9.C: New test.
--- gcc/cp/decl2.c.jj 2007-11-22 15:03:54.000000000 +0100
+++ gcc/cp/decl2.c 2007-11-26 21:04:38.000000000 +0100
@@ -3375,7 +3375,7 @@ cp_write_global_declarations (void)
namespace { struct A { static const int i = 4; } };
decl_needed_p won't reliably detect whether it was
really needed. */
- if (DECL_IN_AGGR_P (decl) && DECL_INITIAL (decl) == NULL_TREE)
+ if (DECL_IN_AGGR_P (decl) && !DECL_INITIALIZED_IN_CLASS_P (decl))
error ("%Jstatic data member %qD used, but not defined",
decl, decl);
DECL_EXTERNAL (decl) = 0;
--- gcc/testsuite/g++.dg/ext/visibility/anon9.C.jj 2007-11-26 21:37:34.000000000 +0100
+++ gcc/testsuite/g++.dg/ext/visibility/anon9.C 2007-11-26 21:38:01.000000000 +0100
@@ -0,0 +1,11 @@
+// PR c++/34238
+// { dg-do compile }
+
+namespace
+{
+ template <typename T = int> struct A
+ {
+ static const bool a = true;
+ };
+}
+struct A<> a;

35
gcc41-pr34275.patch Normal file
View File

@ -0,0 +1,35 @@
2007-11-30 Jakub Jelinek <jakub@redhat.com>
PR c++/34275
* error.c (dump_expr): Handle OBJ_TYPE_REF.
* g++.dg/other/error20.C: New test.
--- gcc/cp/error.c (revision 130532)
+++ gcc/cp/error.c (revision 130533)
@@ -2056,6 +2056,10 @@ dump_expr (tree t, int flags)
pp_expression (cxx_pp, t);
break;
+ case OBJ_TYPE_REF:
+ dump_expr (resolve_virtual_fun_from_obj_type_ref (t), flags);
+ break;
+
/* This list is incomplete, but should suffice for now.
It is very important that `sorry' does not call
`report_error_function'. That could cause an infinite loop. */
--- gcc/testsuite/g++.dg/other/error20.C (revision 0)
+++ gcc/testsuite/g++.dg/other/error20.C (revision 130533)
@@ -0,0 +1,12 @@
+// PR c++/34275
+// { dg-do compile }
+
+struct A
+{ // { dg-error "candidates" }
+ virtual A foo ();
+};
+
+void bar (A& a)
+{
+ a.foo () = 0; // { dg-error "A::foo\\(\\) = 0" }
+}

190
gcc41-rh407281.patch Normal file
View File

@ -0,0 +1,190 @@
2007-12-02 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/execute/20071202-1.c: New test.
2007-02-19 Eric Botcazou <ebotcazou@adacore.com>
* gimplify.c (gimplify_init_ctor_preeval_1): Detect potential overlap
due to calls to functions taking pointers as parameters.
* gnat.dg/self_aggregate_with_call.adb: New test.
2006-08-21 Olivier Hainque <hainque@adacore.com>
* gimplify.c (gimplify_init_constructor) <RECORD,UNION,ARRAY types>:
Arrange for the temporary captures of components overlapping the lhs
to happen before the lhs is possibly cleared.
* gnat.dg/self_aggregate_with_zeros.adb: New test.
* gnat.dg/self_aggregate_with_array.adb: New test.
--- gcc/gimplify.c (revision 116299)
+++ gcc/gimplify.c (revision 116300)
@@ -2638,6 +2638,21 @@ gimplify_init_ctor_preeval_1 (tree *tp,
&& alias_sets_conflict_p (data->lhs_alias_set, get_alias_set (t)))
return t;
+ /* If the constructor component is a call, determine if it can hide a
+ potential overlap with the lhs through an INDIRECT_REF like above. */
+ if (TREE_CODE (t) == CALL_EXPR)
+ {
+ tree type, fntype = TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0)));
+
+ for (type = TYPE_ARG_TYPES (fntype); type; type = TREE_CHAIN (type))
+ if (POINTER_TYPE_P (TREE_VALUE (type))
+ && (!data->lhs_base_decl || TREE_ADDRESSABLE (data->lhs_base_decl))
+ && alias_sets_conflict_p (data->lhs_alias_set,
+ get_alias_set
+ (TREE_TYPE (TREE_VALUE (type)))))
+ return t;
+ }
+
if (IS_TYPE_OR_DECL_P (t))
*walk_subtrees = 0;
return NULL;
@@ -3061,6 +3061,20 @@ gimplify_init_constructor (tree *expr_p,
}
}
+ /* If there are nonzero elements, pre-evaluate to capture elements
+ overlapping with the lhs into temporaries. We must do this before
+ clearing to fetch the values before they are zeroed-out. */
+ if (num_nonzero_elements > 0)
+ {
+ preeval_data.lhs_base_decl = get_base_address (object);
+ if (!DECL_P (preeval_data.lhs_base_decl))
+ preeval_data.lhs_base_decl = NULL;
+ preeval_data.lhs_alias_set = get_alias_set (object);
+
+ gimplify_init_ctor_preeval (&TREE_OPERAND (*expr_p, 1),
+ pre_p, post_p, &preeval_data);
+ }
+
if (cleared)
{
/* Zap the CONSTRUCTOR element list, which simplifies this case.
@@ -3076,16 +3090,7 @@ gimplify_init_constructor (tree *expr_p,
elements in the constructor, add assignments to the individual
scalar fields of the object. */
if (!cleared || num_nonzero_elements > 0)
- {
- preeval_data.lhs_base_decl = get_base_address (object);
- if (!DECL_P (preeval_data.lhs_base_decl))
- preeval_data.lhs_base_decl = NULL;
- preeval_data.lhs_alias_set = get_alias_set (object);
-
- gimplify_init_ctor_preeval (&TREE_OPERAND (*expr_p, 1),
- pre_p, post_p, &preeval_data);
- gimplify_init_ctor_eval (object, elts, pre_p, cleared);
- }
+ gimplify_init_ctor_eval (object, elts, pre_p, cleared);
*expr_p = NULL_TREE;
}
--- gcc/testsuite/gcc.c-torture/execute/20071202-1.c.jj 2007-12-02 19:26:19.000000000 +0100
+++ gcc/testsuite/gcc.c-torture/execute/20071202-1.c 2007-12-02 19:24:28.000000000 +0100
@@ -0,0 +1,25 @@
+extern void abort (void);
+struct T { int t; int r[8]; };
+struct S { int a; int b; int c[6]; struct T d; };
+
+__attribute__((noinline)) void
+foo (struct S *s)
+{
+ *s = (struct S) { s->b, s->a, { 0, 0, 0, 0, 0, 0 }, s->d };
+}
+
+int
+main (void)
+{
+ struct S s = { 6, 12, { 1, 2, 3, 4, 5, 6 },
+ { 7, { 8, 9, 10, 11, 12, 13, 14, 15 } } };
+ foo (&s);
+ if (s.a != 12 || s.b != 6
+ || s.c[0] || s.c[1] || s.c[2] || s.c[3] || s.c[4] || s.c[5])
+ abort ();
+ if (s.d.t != 7 || s.d.r[0] != 8 || s.d.r[1] != 9 || s.d.r[2] != 10
+ || s.d.r[3] != 11 || s.d.r[4] != 12 || s.d.r[5] != 13
+ || s.d.r[6] != 14 || s.d.r[7] != 15)
+ abort ();
+ return 0;
+}
--- gcc/testsuite/gnat.dg/self_aggregate_with_zeros.adb (revision 0)
+++ gcc/testsuite/gnat.dg/self_aggregate_with_zeros.adb (revision 116300)
@@ -0,0 +1,19 @@
+-- { dg-do run }
+
+procedure self_aggregate_with_zeros is
+
+ type Sensor is record
+ Value : Natural;
+ A, B, C, D, E, F, G, H, I, J, K, L, M : Natural;
+ end record;
+
+ Pressure : Sensor;
+
+begin
+ Pressure.Value := 256;
+ Pressure := (Pressure.Value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+
+ if Pressure.Value /= 256 then
+ raise Program_Error;
+ end if;
+end;
--- gcc/testsuite/gnat.dg/self_aggregate_with_array.adb (revision 0)
+++ gcc/testsuite/gnat.dg/self_aggregate_with_array.adb (revision 116300)
@@ -0,0 +1,21 @@
+-- { dg-do run }
+
+procedure self_aggregate_with_array is
+
+ type Value_Bounds is array (1 .. 2) of Natural;
+
+ type Sensor is record
+ Value : Natural;
+ Bounds : Value_Bounds;
+ end record;
+
+ Pressure : Sensor;
+
+begin
+ Pressure.Value := 256;
+ Pressure := (Value => Pressure.Value, Bounds => (1, 2));
+
+ if Pressure.Value /= 256 then
+ raise Program_Error;
+ end if;
+end;
--- gcc/testsuite/gnat.dg/self_aggregate_with_call.adb (revision 0)
+++ gcc/testsuite/gnat.dg/self_aggregate_with_call.adb (revision 122134)
@@ -0,0 +1,30 @@
+-- { dg-do run }
+-- { dg-options "-O2" }
+
+procedure self_aggregate_with_call is
+
+ type Values is array (1 .. 8) of Natural;
+
+ type Vector is record
+ Components : Values;
+ end record;
+
+ function Clone (Components: Values) return Values is
+ begin
+ return Components;
+ end;
+
+ procedure Process (V : in out Vector) is
+ begin
+ V.Components (Values'First) := 1;
+ V := (Components => Clone (V.Components));
+
+ if V.Components (Values'First) /= 1 then
+ raise Program_Error;
+ end if;
+ end;
+
+ V : Vector;
+begin
+ Process (V);
+end;

View File

@ -1,6 +1,6 @@
%define DATE 20071124
%define gcc_version 4.1.2
%define gcc_release 34
%define gcc_release 35
%define _unpackaged_files_terminate_build 0
%define multilib_64_archs sparc64 ppc64 s390x x86_64
%define include_gappletviewer 1
@ -199,6 +199,10 @@ Patch73: gcc41-pr34094.patch
Patch74: gcc41-pr34130.patch
Patch75: gcc41-pr34146.patch
Patch76: gcc41-rh364001.patch
Patch77: gcc41-pr34213.patch
Patch78: gcc41-pr34238.patch
Patch79: gcc41-pr34275.patch
Patch80: gcc41-rh407281.patch
# On ARM EABI systems, we do want -gnueabi to be part of the
# target triple.
@ -556,6 +560,10 @@ which are required to run programs compiled with the GNAT.
%patch74 -p0 -b .pr34130~
%patch75 -p0 -b .pr34146~
%patch76 -p0 -b .rh364001~
%patch77 -p0 -b .pr34213~
%patch78 -p0 -b .pr34238~
%patch79 -p0 -b .pr34275~
%patch80 -p0 -b .rh407281~
%if %{bootstrap_java}
tar xjf %{SOURCE10}
@ -1728,6 +1736,15 @@ fi
%doc rpm.doc/changelogs/libmudflap/ChangeLog*
%changelog
* Sun Dec 2 2007 Jakub Jelinek <jakub@redhat.com> 4.1.2-35
- two ctor preevaluation fixes (Olivier Hainque,
Eric Botcazou, #407281)
- slightly weaken diagnostics for declared, but undefined static data
members in anon ns classes (#402521, PR c++/34238)
- consider static data members and static member functions in anon ns
classes to be external for C++ linkage type handling (PR c++/34213)
- handle OBJ_TYPE_REF in C++ diagnostics (PR c++/34275)
* Sat Nov 24 2007 Jakub Jelinek <jakub@redhat.com> 4.1.2-34
- update from gcc-4_1-branch (-r128736:130387)
- PRs middle-end/34030, rtl-optimization/28062, rtl-optimization/33822