Commit a93ee058 by Nathan Sidwell Committed by Nathan Sidwell

[PR c++/82710] false positive paren warning

https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00186.html
	PR c++/82710
	* decl.c (grokdeclarator): Protect MAYBE_CLASS things from paren
	warning too.

	PR c++/82710
	* g++.dg/warn/pr82710.C: More cases.

From-SVN: r254371
parent 97695d99
2017-11-03 Nathan Sidwell <nathan@acm.org>
PR c++/82710
* decl.c (grokdeclarator): Protect MAYBE_CLASS things from paren
warning too.
2017-11-02 Paolo Carlini <paolo.carlini@oracle.com> 2017-11-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/81957 PR c++/81957
......
...@@ -10795,13 +10795,15 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -10795,13 +10795,15 @@ grokdeclarator (const cp_declarator *declarator,
to be a constructor call. */ to be a constructor call. */
if (decl_context != PARM if (decl_context != PARM
&& declarator->parenthesized != UNKNOWN_LOCATION && declarator->parenthesized != UNKNOWN_LOCATION
/* If the type is a class and the inner name used a global /* If the type is class-like and the inner name used a
namespace qualifier, we need the parens. Unfortunately global namespace qualifier, we need the parens.
all we can tell is that a qualified name was used. */ Unfortunately all we can tell is whether a qualified name
&& !(CLASS_TYPE_P (type) was used or not. */
&& inner_declarator && !(inner_declarator
&& inner_declarator->kind == cdk_id && inner_declarator->kind == cdk_id
&& inner_declarator->u.id.qualifying_scope)) && inner_declarator->u.id.qualifying_scope
&& (MAYBE_CLASS_TYPE_P (type)
|| TREE_CODE (type) == ENUMERAL_TYPE)))
warning_at (declarator->parenthesized, OPT_Wparentheses, warning_at (declarator->parenthesized, OPT_Wparentheses,
"unnecessary parentheses in declaration of %qs", name); "unnecessary parentheses in declaration of %qs", name);
if (declarator->kind == cdk_id || declarator->kind == cdk_decomp) if (declarator->kind == cdk_id || declarator->kind == cdk_decomp)
......
2017-11-03 Nathan Sidwell <nathan@acm.org>
PR c++/82710
* g++.dg/warn/pr82710.C: More cases.
2017-11-03 Richard Sandiford <richard.sandiford@linaro.org> 2017-11-03 Richard Sandiford <richard.sandiford@linaro.org>
* gcc.dg/pr82809.c: New test. * gcc.dg/pr82809.c: New test.
......
// { dg-additional-options -Wparentheses } // { dg-do compile { target c++11 } }
// { dg-additional-options "-Wparentheses -Wno-non-template-friend" }
// the MVP warning triggered on a friend decl. */ // the MVP warning triggered on a friend decl. */
class X; class X;
enum class Q {}; // C++ 11ness
enum R {};
namespace here namespace here
{ {
...@@ -9,6 +12,9 @@ namespace here ...@@ -9,6 +12,9 @@ namespace here
X friendFunc1(); X friendFunc1();
X *friendFunc2 (); X *friendFunc2 ();
int friendFunc3 (); int friendFunc3 ();
int bob ();
Q bill ();
R ben ();
} }
namespace nm namespace nm
...@@ -19,6 +25,9 @@ namespace nm ...@@ -19,6 +25,9 @@ namespace nm
void friendFunc1 (); void friendFunc1 ();
void friendFunc2 (); void friendFunc2 ();
void friendFunc3 (); void friendFunc3 ();
int bob ();
Q bill ();
R ben ();
} }
class TestClass class TestClass
...@@ -28,5 +37,12 @@ namespace nm ...@@ -28,5 +37,12 @@ namespace nm
friend X *::here::friendFunc2 (); friend X *::here::friendFunc2 ();
friend int (::here::friendFunc3 ()); // { dg-warning "" } friend int (::here::friendFunc3 ()); // { dg-warning "" }
}; };
template <typename T> class X
{
friend typename T::frob (::here::bob ());
friend Q (::here::bill ());
friend R (::here::ben ());
};
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment