From: Marek Polacek Date: Wed, 3 Jan 2018 13:30:00 +0000 (+0000) Subject: re PR c++/83592 (Annoying -Wparentheses warnings) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e164534f16c838373ab888e0b36ab5e103d32e25;p=gcc.git re PR c++/83592 (Annoying -Wparentheses warnings) PR c++/83592 * decl.c (grokdeclarator): Don't warn about MVP in typename context. * g++.dg/warn/mvp2.C: New test. From-SVN: r256176 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2fe42b2bb92..506684aeb47 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-01-03 Marek Polacek + + PR c++/83592 + * decl.c (grokdeclarator): Don't warn about MVP in typename context. + 2018-01-03 Jakub Jelinek PR preprocessor/83602 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f7b03e13303..b1c50961169 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10866,10 +10866,11 @@ grokdeclarator (const cp_declarator *declarator, inner_declarator = declarator->declarator; - /* We don't want to warn in parmeter context because we don't + /* We don't want to warn in parameter context because we don't yet know if the parse will succeed, and this might turn out to be a constructor call. */ if (decl_context != PARM + && decl_context != TYPENAME && declarator->parenthesized != UNKNOWN_LOCATION /* If the type is class-like and the inner name used a global namespace qualifier, we need the parens. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2c1c96ccdb..d4d380447ec 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-03 Marek Polacek + + PR c++/83592 + * g++.dg/warn/mvp2.C: New test. + 2018-01-03 Jakub Jelinek PR preprocessor/83602 diff --git a/gcc/testsuite/g++.dg/warn/mvp2.C b/gcc/testsuite/g++.dg/warn/mvp2.C new file mode 100644 index 00000000000..6e1ffb5db12 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/mvp2.C @@ -0,0 +1,24 @@ +// PR c++/83592 +// { dg-do compile } +// { dg-options "-Wparentheses" } + +// Test that -Wparentheses does not give bogus warnings in +// typename context. + +int * +foo (long &a) +{ + return reinterpret_cast (&a); +} + +int * +bar (long &a) +{ + return (int (*)) &a; +} + +int * +baz (int &a) +{ + return static_cast (&a); +}