From d7d42cf51aff31bd67cb9f4f6539f7addbcebf1b Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Mon, 23 Oct 2006 13:43:04 +0000 Subject: [PATCH] predicates.md ("bras_sym_operand"): Do not accept nonlocal function symbols if flag_pic. ChangeLog: * config/s390/predicates.md ("bras_sym_operand"): Do not accept nonlocal function symbols if flag_pic. testsuite/ChangeLog: * g++.dg/other/s390-1.C: New testcase. From-SVN: r117974 --- gcc/ChangeLog | 5 +++++ gcc/config/s390/predicates.md | 3 ++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/other/s390-1.C | 32 +++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/other/s390-1.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 435a2887e771..6db83dfa2bc4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2006-10-23 Ulrich Weigand + + * config/s390/predicates.md ("bras_sym_operand"): Do not accept + nonlocal function symbols if flag_pic. + 2006-10-22 Richard Sandiford * config/mips/mips.c (mips_split_const): Don't accept bare PLUS diff --git a/gcc/config/s390/predicates.md b/gcc/config/s390/predicates.md index de6e796318dc..5f9e8d438920 100644 --- a/gcc/config/s390/predicates.md +++ b/gcc/config/s390/predicates.md @@ -62,7 +62,8 @@ ;; Allow SYMBOL_REFs and @PLT stubs. (define_special_predicate "bras_sym_operand" - (ior (match_code "symbol_ref") + (ior (and (match_code "symbol_ref") + (match_test "!flag_pic || SYMBOL_REF_LOCAL_P (op)")) (and (match_code "const") (and (match_test "GET_CODE (XEXP (op, 0)) == UNSPEC") (match_test "XINT (XEXP (op, 0), 1) == UNSPEC_PLT"))))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8634b8e41ec3..d2b05bcb0415 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2006-10-23 Ulrich Weigand + + * g++.dg/other/s390-1.C: New testcase. + 2006-10-20 Lee Millward PR c++/28053 diff --git a/gcc/testsuite/g++.dg/other/s390-1.C b/gcc/testsuite/g++.dg/other/s390-1.C new file mode 100644 index 000000000000..bf37ca449e34 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/s390-1.C @@ -0,0 +1,32 @@ +// { dg-do compile { target s390x-*-* } } +// { dg-options "-O3 -fPIC" } + +class A +{ +public: + void f (void) { _M_a = 0; } + void g (void) { _M_a = 1; } + void h (void); + +private: + int _M_a; +}; + +class B : virtual public A +{ +}; + +void +test (B& x) +{ + for (int i = 0; i < 17; i++) + { + x.f (); + (x.*&A::g) (); + x.h (); + } +} + +// Check that every call to A::g goes via the PLT. +// { dg-final { scan-assembler-not "brasl\[^@\]*\n" } } +