diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-11-03 13:16:06 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-11-03 13:16:06 +0000 |
commit | a93ee058fa3f2b0569e43b425293f28858eebfaf (patch) | |
tree | 6fb5fdaa2630816d3d1b7476197b123d4463dacf /gcc/cp | |
parent | 97695d99b0caa475df0a7b569fee6d3bef35b4d7 (diff) | |
download | gcc-a93ee058fa3f2b0569e43b425293f28858eebfaf.zip gcc-a93ee058fa3f2b0569e43b425293f28858eebfaf.tar.gz gcc-a93ee058fa3f2b0569e43b425293f28858eebfaf.tar.bz2 |
[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
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 14 |
2 files changed, 14 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e7ea5da..590e322 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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> PR c++/81957 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7c6f857..0ce8f2d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10795,13 +10795,15 @@ grokdeclarator (const cp_declarator *declarator, to be a constructor call. */ if (decl_context != PARM && declarator->parenthesized != UNKNOWN_LOCATION - /* If the type is a class and the inner name used a global - namespace qualifier, we need the parens. Unfortunately - all we can tell is that a qualified name was used. */ - && !(CLASS_TYPE_P (type) - && inner_declarator + /* If the type is class-like and the inner name used a + global namespace qualifier, we need the parens. + Unfortunately all we can tell is whether a qualified name + was used or not. */ + && !(inner_declarator && 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, "unnecessary parentheses in declaration of %qs", name); if (declarator->kind == cdk_id || declarator->kind == cdk_decomp) |