I was looking for an easy task to start contributing to gcc, so I choose a "trivial" bug (69733) from this list (cited in an old message of Manuel López-Ibáñez):
https://gcc.gnu.org/bugzilla/buglist.cgi?keywords=diagnostic&limit=0&li st_id=99232&order=bug_status%2Cpriority%2Cassigned_to%2Cbug_id&query_fo rmat=advanced&resolution=--- Attached there is the patch with the bugfix and a testcase. So far so good, but what's the preferred workflow to propose a patch? A message on this list it's fine, or gcc-pacthes is better suited? Or, maybe, an attachment to the bug report is the right thing to do? --david
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 30eef5c..955867c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10010,8 +10010,18 @@ grokdeclarator (const cp_declarator *declarator, if (type_quals != TYPE_UNQUALIFIED) { if (SCALAR_TYPE_P (type) || VOID_TYPE_P (type)) - warning (OPT_Wignored_qualifiers, - "type qualifiers ignored on function return type"); + { + source_location loc = input_location; + if (type_quals & TYPE_QUAL_CONST) + loc = declspecs->locations[ds_const]; + else if (type_quals & TYPE_QUAL_VOLATILE) + loc = declspecs->locations[ds_volatile]; + else if (type_quals & TYPE_QUAL_RESTRICT) + loc = declspecs->locations[ds_restrict]; + + warning_at (loc, OPT_Wignored_qualifiers, + "type qualifiers ignored on function return type"); + } /* We now know that the TYPE_QUALS don't apply to the decl, but to its return type. */ type_quals = TYPE_UNQUALIFIED; diff --git a/gcc/testsuite/g++.dg/diagnostic/pr69733.C b/gcc/testsuite/g++.dg/diagnostic/pr69733.C new file mode 100644 index 0000000..4694356 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/pr69733.C @@ -0,0 +1,17 @@ +// PR c++/69733 +// { dg-do compile } +// { dg-options "-Wall -Wextra -fdiagnostics-show-caret" } + +class A { +private: + double val; + +public: + double const value() const { return val; } // { dg-warning "type qualifiers ignored on function return type" } + +/* { dg-begin-multiline-output "" } + double const value() const { return val; } + ^~~~~ + { dg-end-multiline-output "" } */ + +};
signature.asc
Description: This is a digitally signed message part