diff options
| author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-28 07:14:26 +0000 |
|---|---|---|
| committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-28 07:14:26 +0000 |
| commit | c05aabd94bcbc839719454fae1158dd4f129ffb6 (patch) | |
| tree | 33b46f58435734419c1a15c485d745d9839d668d | |
| parent | fcf302403cf7449a2393de179944eccad8b1420d (diff) | |
| download | ppe42-gcc-c05aabd94bcbc839719454fae1158dd4f129ffb6.tar.gz ppe42-gcc-c05aabd94bcbc839719454fae1158dd4f129ffb6.zip | |
PR optimization/5079
* call.c (build_conditional_expr): Use decl_constant_value to
simplify the arguments.
PR optimization/5079
* g++.dg/opt/static3.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70881 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
| -rw-r--r-- | gcc/cp/call.c | 2 | ||||
| -rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
| -rw-r--r-- | gcc/testsuite/g++.dg/opt/static3.C | 35 |
4 files changed, 48 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a779d62b402..87857b249a7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-08-28 Mark Mitchell <mark@codesourcery.com> + + PR optimization/5079 + * call.c (build_conditional_expr): Use decl_constant_value to + simplify the arguments. + 2003-08-26 Dan Nicolaescu <dann@ics.uci.edu> * parser.c (struct cp_token): Use enum bitfields. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index a74fd63d556..739ce71f590 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3358,6 +3358,8 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3) } valid_operands: + arg2 = decl_constant_value (arg2); + arg3 = decl_constant_value (arg3); result = fold (build (COND_EXPR, result_type, arg1, arg2, arg3)); /* We can't use result_type below, as fold might have returned a throw_expr. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0877585bc0a..e0c5d5b3b63 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-08-28 Mark Mitchell <mark@codesourcery.com> + + PR optimization/5079 + * g++.dg/opt/static3.C: New test. + 2003-08-27 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> * gcc.misc-tests/gcov-10b.c: New test. diff --git a/gcc/testsuite/g++.dg/opt/static3.C b/gcc/testsuite/g++.dg/opt/static3.C new file mode 100644 index 00000000000..00c72651be3 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/static3.C @@ -0,0 +1,35 @@ +// { dg-do link } + +class Foo { +public: + // No out-of-class definition is provided for these class members. + // That's technically a violation of the standard, but no diagnostic + // is required, and, as a QOI issue, we should optimize away all + // references. + static const int erf = 0; + static const int foo = 1; +}; + +int one() +{ + return Foo::foo; +} + +int two() +{ + return Foo::foo + Foo::erf; +} + +int three(int x) +{ + return x ? Foo::erf : Foo::foo; +} + +int i; + +int main () +{ + one (); + two (); + three (i); +} |

