typeck.c (cp_build_unary_op): Only complain about taking address of main if pedantic.
* typeck.c (cp_build_unary_op): Only complain about taking address of main if pedantic. From-SVN: r143911
This commit is contained in:
parent
6175f5785a
commit
d0db89893f
5 changed files with 24 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
5
gcc/testsuite/g++.dg/warn/main-4.C
Normal file
5
gcc/testsuite/g++.dg/warn/main-4.C
Normal file
|
@ -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; }
|
|
@ -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; }
|
||||
|
|
Loading…
Add table
Reference in a new issue