diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/main-4.C | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.bugs/900227_01.C | 6 |
5 files changed, 24 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9d425ab..c2765da 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2009-02-03 Jason Merrill <jason@redhat.com> + + * typeck.c (cp_build_unary_op): Only complain about taking address + of main if pedantic. + 2009-02-03 Jakub Jelinek <jakub@redhat.com> PR inline-asm/39059 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 1c7df31..c58d40b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4473,12 +4473,15 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, arg = build1 (CONVERT_EXPR, type, arg); return arg; } - else if (DECL_MAIN_P (arg)) + else if (pedantic && DECL_MAIN_P (arg)) { /* ARM $3.4 */ - if (complain & tf_error) - permerror (input_location, "ISO C++ forbids taking address of function %<::main%>"); - else + /* Apparently a lot of autoconf scripts for C++ packages do this, + so only complain if -pedantic. */ + if (complain & (flag_pedantic_errors ? tf_error : tf_warning)) + pedwarn (input_location, OPT_pedantic, + "ISO C++ forbids taking address of function %<::main%>"); + else if (flag_pedantic_errors) return error_mark_node; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9d50d7f..67369d9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-02-03 Jason Merrill <jason@redhat.com> + + * g++.dg/warn/main-4.C: New test. + * g++.old-deja/g++.bugs/900227_01.C: Remove &main warnings. + 2009-02-03 Andrew Pinski <andrew_pinski@playstation.sony.com> PR C++/36607 diff --git a/gcc/testsuite/g++.dg/warn/main-4.C b/gcc/testsuite/g++.dg/warn/main-4.C new file mode 100644 index 0000000..ad2dd70 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/main-4.C @@ -0,0 +1,5 @@ +// This pattern is used by a lot of autoconf scripts, so don't +// complain about it unless -pedantic. +// { dg-options "" } + +int main () { main (); return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900227_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900227_01.C index 2bd4f3d..b441eff 100644 --- a/gcc/testsuite/g++.old-deja/g++.bugs/900227_01.C +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900227_01.C @@ -33,9 +33,7 @@ int main (); -short s = (short) &main; // { dg-error "taking address" "addr" { xfail h8*-*-* xstormy16-*-* } } -// { dg-error "loses precision" "lose" { xfail h8*-*-* xstormy16-*-* } 36 } -char c = (char) &main; // { dg-error "taking address" } -// { dg-error "loses precision" "lose" { target *-*-* } 38 } +short s = (short) &main; // { dg-error "loses precision" "lose" { xfail h8*-*-* xstormy16-*-* } } +char c = (char) &main; // { dg-error "loses precision" "lose" } int main () { return 0; } |