aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMagnus Granberg <zorry@gentoo.org>2010-07-15 05:46:36 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2010-07-15 05:46:36 +0000
commit8ffadef9522724304913886c7df86db26e46efc7 (patch)
treea01412ef395a7d90aeb4d60dc1ddd5779ac1fb35 /gcc
parent6b58c62f292ef249236bf6cb5f0adce974ea6d07 (diff)
downloadgcc-8ffadef9522724304913886c7df86db26e46efc7.zip
gcc-8ffadef9522724304913886c7df86db26e46efc7.tar.gz
gcc-8ffadef9522724304913886c7df86db26e46efc7.tar.bz2
builtins.c (expand_builtin_init_trampoline): If -Wtrampolines make a warning.
2010-07-15 Magnus Granberg <zorry@gentoo.org> Kevin F. Quinn <kevquinn@gentoo.org> * builtins.c (expand_builtin_init_trampoline): If -Wtrampolines make a warning. * common.opt: Add -Wtrampolines. * doc/invoke.texi: Add -Wtrampolines. testsuite/ * gcc.dg/Wtrampolines.c: New. Co-Authored-By: Kevin F. Quinn <kevquinn@gentoo.org> From-SVN: r162205
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/builtins.c4
-rw-r--r--gcc/common.opt4
-rw-r--r--gcc/doc/invoke.texi16
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/Wtrampolines.c57
6 files changed, 92 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3e96698..2c1518d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2010-07-15 Magnus Granberg <zorry@gentoo.org>
+ Kevin F. Quinn <kevquinn@gentoo.org>
+
+ * builtins.c (expand_builtin_init_trampoline): If
+ -Wtrampolines make a warning.
+ * common.opt: Add -Wtrampolines.
+ * doc/invoke.texi: Add -Wtrampolines.
+
2010-07-15 Jie Zhang <jie@codesourcery.com>
* config/arm/cortex-a8.md (cortex_a8_load_store_2): Reserve
diff --git a/gcc/builtins.c b/gcc/builtins.c
index b94e056..2bcf656 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -5250,6 +5250,10 @@ expand_builtin_init_trampoline (tree exp)
targetm.calls.trampoline_init (m_tramp, t_func, r_chain);
trampolines_created = 1;
+
+ warning_at (DECL_SOURCE_LOCATION (t_func), OPT_Wtrampolines,
+ "trampoline generated for nested function %qD", t_func);
+
return const0_rtx;
}
diff --git a/gcc/common.opt b/gcc/common.opt
index 111d7b7..41a9838 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -212,6 +212,10 @@ Wsystem-headers
Common Var(warn_system_headers) Warning
Do not suppress warnings from system headers
+Wtrampolines
+Common Var(warn_trampolines) Warning
+Warn whenever a trampoline is generated
+
Wtype-limits
Common Var(warn_type_limits) Init(-1) Warning
Warn if a comparison is always true or always false due to the limited range of the data type
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 4d6a1af..12855a4 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -260,8 +260,8 @@ Objective-C and Objective-C++ Dialects}.
-Wstrict-overflow -Wstrict-overflow=@var{n} @gol
-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{]} @gol
-Wswitch -Wswitch-default -Wswitch-enum -Wsync-nand @gol
--Wsystem-headers -Wtrigraphs -Wtype-limits -Wundef -Wuninitialized @gol
--Wunknown-pragmas -Wno-pragmas @gol
+-Wsystem-headers -Wtrampolines -Wtrigraphs -Wtype-limits -Wundef @gol
+-Wuninitialized -Wunknown-pragmas -Wno-pragmas @gol
-Wunsuffixed-float-constants -Wunused -Wunused-function @gol
-Wunused-label -Wunused-parameter -Wno-unused-result -Wunused-value -Wunused-variable @gol
-Wunused-but-set-parameter -Wunused-but-set-variable -Wvariadic-macros -Wvla @gol
@@ -3724,6 +3724,18 @@ code. However, note that using @option{-Wall} in conjunction with this
option will @emph{not} warn about unknown pragmas in system
headers---for that, @option{-Wunknown-pragmas} must also be used.
+@item -Wtrampolines
+@opindex Wtrampolines
+@opindex Wno-trampolines
+ Warn about trampolines generated for pointers to nested functions.
+
+ A trampoline is a small piece of data or code that is created at run
+ time on the stack when the address of a nested function is taken, and
+ is used to call the nested function indirectly. For some targets, it
+ is made up of data only and thus requires no special treatment. But,
+ for most targets, it is made up of code and thus requires the stack
+ to be made executable in order for the program to work properly.
+
@item -Wfloat-equal
@opindex Wfloat-equal
@opindex Wno-float-equal
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f367bbd..3e04816 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-07-15 Magnus Granberg <zorry@gentoo.org>
+ Kevin F. Quinn <kevquinn@gentoo.org>
+
+ * gcc.dg/Wtrampolines.c: New.
+
2010-07-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/44934
diff --git a/gcc/testsuite/gcc.dg/Wtrampolines.c b/gcc/testsuite/gcc.dg/Wtrampolines.c
new file mode 100644
index 0000000..dcb3681
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wtrampolines.c
@@ -0,0 +1,57 @@
+/* Origin: trampoline-1.c Waldek Hebisch <hebisch@math.uni.wroc.pl> */
+/* Ported to test -Wtrampolines Magnus Granberg <zorry@gentoo.org> */
+
+/* { dg-do compile } */
+/* { dg-require-effective-target trampolines } */
+/* { dg-options "-O2 -Wtrampolines" } */
+
+#ifndef NO_TRAMPOLINES
+
+/* This used to fail on various versions of Solaris 2 because the
+ trampoline couldn't be made executable. */
+
+extern void abort(void);
+extern double fabs(double);
+
+void foo (void)
+{
+ const int correct[1100] = {1, 0, -2, 0, 1, 0, 1, -1, -10, -30, -67};
+ int i;
+
+ double x1 (void) {return 1; }
+ double x2 (void) {return -1;}
+ double x3 (void) {return -1;}
+ double x4 (void) {return 1; }
+ double x5 (void) {return 0; }
+
+ typedef double pfun(void);
+
+ double a (int k, pfun x1, pfun x2, pfun x3, pfun x4, pfun x5)
+ {
+ double b (void) /* { dg-warning "trampoline generated for nested function 'b'" } */
+ {
+ k = k - 1;
+ return a (k, b, x1, x2, x3, x4 );
+ }
+
+ if (k <= 0)
+ return x4 () + x5 ();
+ else
+ return b ();
+ }
+
+ for (i=0; i<=10; i++)
+ {
+ if (fabs(a( i, x1, x2, x3, x4, x5 ) - correct [i]) > 0.1)
+ abort();
+ }
+}
+#endif
+
+int main (void)
+{
+#ifndef NO_TRAMPOLINES
+ foo ();
+#endif
+ return 0;
+}