&& 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 (warning_at (declarator->parenthesized, OPT_Wparentheses,
+ "unnecessary parentheses in declaration of %qs",
+ name))
+ {
+ gcc_rich_location iloc (declarator->parenthesized);
+ iloc.add_fixit_remove (get_start (declarator->parenthesized));
+ iloc.add_fixit_remove (get_finish (declarator->parenthesized));
+ inform (&iloc, "remove parentheses");
+ }
+ }
if (declarator->kind == cdk_id || declarator->kind == cdk_decomp)
break;
open_paren = NULL;
}
if (open_paren)
- declarator->parenthesized = open_paren->location;
+ declarator->parenthesized = make_location (open_paren->location,
+ open_paren->location,
+ close_paren->location);
}
/* If we entered a scope, we must exit it now. */
--- /dev/null
+// { dg-do compile }
+// { dg-options "-Wparentheses -fdiagnostics-show-caret" }
+// Test fix-it hints for the MVP warning.
+
+void
+g ()
+{
+ int (i); // { dg-warning "7:unnecessary parentheses" }
+/* { dg-begin-multiline-output "" }
+ int (i);
+ ^~~
+ { dg-end-multiline-output "" } */
+// { dg-message "7:remove parentheses" "" { target *-*-* } 8 }
+/* { dg-begin-multiline-output "" }
+ int (i);
+ ^~~
+ - -
+ { dg-end-multiline-output "" } */
+ int (fn(void)); // { dg-warning "7:unnecessary parentheses" }
+/* { dg-begin-multiline-output "" }
+ int (fn(void));
+ ^~~~~~~~~~
+ { dg-end-multiline-output "" } */
+// { dg-message "7:remove parentheses" "" { target *-*-* } 19 }
+/* { dg-begin-multiline-output "" }
+ int (fn(void));
+ ^~~~~~~~~~
+ - -
+ { dg-end-multiline-output "" } */
+}