From 6fc8fe23066bc34b68cf8d6931ecb6a5a19f7c6c Mon Sep 17 00:00:00 2001 From: manu Date: Tue, 27 Apr 2010 20:22:54 +0000 Subject: [PATCH] =?utf8?q?2010-04-27=20=20Manuel=20L=C3=B3pez-Ib=C3=A1?= =?utf8?q?=C3=B1ez=20=20=20=09=20=20=20=20Jan=20Hubicka?= =?utf8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * doc/invoke.texi (-Wsuggest-attribute=const, -Wsuggest-attribute=pure): Document. * ipa-pure-const.c: Include toplev.h, intl.h and opts.h. (function_always_visible_to_compiler_p, suggest_attribute, warn_function_pure, warn_function_const): New functions. (check_call): Improve debug info. (analyze_function): Do not check availability. (add_new_function): Check availability. (propagate): Output warnings. (skip_function_for_local_pure_const): New function. (local_pure_const): Use it; output warnings. * common.opt (Wsuggest-attribute=const, Wsuggest-attribute=pure): New. testsuite/ * gcc.dg/pure-2.c: New testcase. * gcc.dg/const-1.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158803 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 18 ++++++++++++++++++ gcc/doc/invoke.texi | 28 +++++++++++++++++++++++++++- gcc/testsuite/ChangeLog | 6 ++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 39e8fe7b317..0f376e5dd3f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,21 @@ +2010-04-27 Manuel López-Ibáñez + Jan Hubicka + + * doc/invoke.texi (-Wsuggest-attribute=const, + -Wsuggest-attribute=pure): Document. + * ipa-pure-const.c: Include toplev.h, intl.h and opts.h. + (function_always_visible_to_compiler_p, + suggest_attribute, warn_function_pure, warn_function_const): + New functions. + (check_call): Improve debug info. + (analyze_function): Do not check availability. + (add_new_function): Check availability. + (propagate): Output warnings. + (skip_function_for_local_pure_const): New function. + (local_pure_const): Use it; output warnings. + * common.opt (Wsuggest-attribute=const, + Wsuggest-attribute=pure): New. + 2010-04-27 Jakub Jelinek * dwarf2out.c (def_cfa_1): After DW_CFA_def_cfa_expression diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 23f744b9bfb..fefb0abd1d5 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -257,6 +257,7 @@ Objective-C and Objective-C++ Dialects}. -Wsign-compare -Wsign-conversion -Wstack-protector @gol -Wstrict-aliasing -Wstrict-aliasing=n @gol -Wstrict-overflow -Wstrict-overflow=@var{n} @gol +-Wsuggest-attribute=@r{[}const@r{|}pure@r{]} @gol -Wswitch -Wswitch-default -Wswitch-enum -Wsync-nand @gol -Wsystem-headers -Wtrigraphs -Wtype-limits -Wundef -Wuninitialized @gol -Wunknown-pragmas -Wno-pragmas @gol @@ -3621,11 +3622,36 @@ comparisons, so this warning level will give a very large number of false positives. @end table +@item -Wsuggest-attribute=@r{[}const@r{|}pure@r{]} +@opindex Wsuggest-attribute= +@opindex Wno-suggest-attribute= +Warn for cases where adding an attribute may be beneficial. The +attributes currently supported are listed below. + +@table @gcctabopt +@item -Wsuggest-attribute=pure +@itemx -Wsuggest-attribute=const +@opindex Wsuggest-attribute=pure +@opindex Wno-suggest-attribute=pure +@opindex Wsuggest-attribute=const +@opindex Wno-suggest-attribute=const + +Warn about functions which might be candidates for attributes +@code{pure} or @code{const}. The compiler only warns for functions +visible in other compilation units or if it cannot prove that the +function returns normally. A function returns normally if it doesn't +contain an infinite loop nor returns abnormally by throwing, calling +@code{abort()} or trapping. This analysis requires option +@option{-fipa-pure-const}, which is enabled by default at @option{-O} +and higher. Higher optimization levels improve the accuracy of the +analysis. +@end table + @item -Warray-bounds @opindex Wno-array-bounds @opindex Warray-bounds This option is only active when @option{-ftree-vrp} is active -(default for -O2 and above). It warns about subscripts to arrays +(default for @option{-O2} and above). It warns about subscripts to arrays that are always out of bounds. This warning is enabled by @option{-Wall}. @item -Wno-div-by-zero diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3a320983f65..4a8fb182f77 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2010-04-27 Manuel López-Ibáñez + Jan Hubicka + + * gcc.dg/pure-2.c: New testcase. + * gcc.dg/const-1.c: New testcase. + 2010-04-27 Jason Merrill * g++.dg/cpp0x/lambda/lambda-ice1.C: New. -- 2.11.0