Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/glibcxx_ubuntu64b_log_expected_warnings
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
../../gcc/rust/typecheck/rust-coercion.cc:310:15: warning: too many arguments for format [-Wformat-extra-args]
../../gcc/rust/typecheck/rust-coercion.cc:310:15: warning: unknown conversion type character ‘z’ in format [-Wformat=]
../../gcc/rust/typecheck/rust-unify.cc:155:23: warning: too many arguments for format [-Wformat-extra-args]
../../gcc/rust/typecheck/rust-unify.cc:155:23: warning: unknown conversion type character ‘z’ in format [-Wformat=]
4 changes: 4 additions & 0 deletions .github/log_expected_warnings
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
../../gcc/rust/typecheck/rust-coercion.cc:310:15: warning: too many arguments for format [-Wformat-extra-args]
../../gcc/rust/typecheck/rust-coercion.cc:310:15: warning: unknown conversion type character ‘z’ in format [-Wformat=]
../../gcc/rust/typecheck/rust-unify.cc:155:23: warning: too many arguments for format [-Wformat-extra-args]
../../gcc/rust/typecheck/rust-unify.cc:155:23: warning: unknown conversion type character ‘z’ in format [-Wformat=]
3 changes: 3 additions & 0 deletions gcc/rust/ast/rust-ast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ along with GCC; see the file COPYING3. If not see
#include "rust-attribute-values.h"
#include "rust-macro-invoc-lexer.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

/* Compilation unit used for various AST-related functions that would make
* the headers too long if they were defined inline and don't receive any
* benefits from being defined inline because they are virtual. Also used
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/backend/rust-compile-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
// rust-name-resolution-2.0
#include "options.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Compile {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/backend/rust-compile-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#include "rust-tyty.h"
#include "tree-core.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Compile {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/backend/rust-compile-stmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "rust-compile-type.h"
#include "rust-compile-var-decl.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Compile {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/backend/rust-mangle-v0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "rust-punycode.h"
#include "rust-compile-type.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Compile {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/checks/errors/borrowck/rust-bir-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "rust-bir-builder-pattern.h"
#include "rust-bir-builder-expr-stmt.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace BIR {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include "rust-bir-place.h"
#include "polonius/rust-polonius.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace BIR {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/checks/errors/rust-hir-pattern-analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include "rust-tyty.h"
#include "rust-finalized-name-resolution-context.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Analysis {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/expand/rust-cfg-strip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include "rust-attribute-values.h"
#include "rust-macro-expand.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {

/**
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/expand/rust-macro-builtins-asm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include "rust-stmt.h"
#include "rust-parse.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
std::set<std::string> potentially_nonpromoted_keywords
= {"in", "out", "lateout", "inout", "inlateout", "const", "sym", "label"};
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/expand/rust-macro-builtins-log-debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "optional.h"
#include "rust-ast-collector.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
tl::optional<AST::Fragment>
MacroBuiltin::assert_handler (location_t invoc_locus,
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/hir/tree/rust-hir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "rust-hir-visitor.h"
#include "rust-diagnostics.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

/* Compilation unit used for various HIR-related functions that would make
* the headers too long if they were defined inline and don't receive any
* benefits from being defined inline because they are virtual. Also used
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/lex/rust-lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "cpplib.h"
#include "rust-keyword-values.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
// TODO: move to separate compilation unit?
// overload += for uint32_t to allow 32-bit encoded utf-8 to be added
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/parse/rust-parse-impl-lexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
// along with GCC; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

#include "rust-parse-impl.hxx"

namespace Rust {
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/parse/rust-parse-impl-macro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
// along with GCC; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

#include "rust-parse-impl.hxx"
#include "rust-macro-invoc-lexer.h"

Expand Down
7 changes: 7 additions & 0 deletions gcc/rust/resolve/rust-forever-stack.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ ForeverStack<N>::push (Rib::Kind rib_kind, NodeId id,
push_inner (rib_kind, Link (id, path));
}

// TODO: fix warnings and remove
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-diag"

template <Namespace N>
void
ForeverStack<N>::push_inner (Rib::Kind rib_kind, Link link)
Expand Down Expand Up @@ -117,6 +121,9 @@ ForeverStack<N>::pop ()
update_cursor (cursor ().parent.value ());
}

// TODO: fix warnings and remove
#pragma GCC diagnostic pop

static tl::expected<NodeId, DuplicateNameError>
insert_inner (Rib &rib, std::string name, Rib::Definition definition)
{
Expand Down
12 changes: 1 addition & 11 deletions gcc/rust/rust-diagnostics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,8 @@ rust_debug_loc (const location_t location, const char *fmt, ...)
va_list ap;

va_start (ap, fmt);
char *mbuf = NULL;
int nwr = vasprintf (&mbuf, fmt, ap);
rust_be_inform (location, expand_message (fmt, ap));
va_end (ap);
if (nwr == -1)
{
rust_be_error_at (UNKNOWN_LOCATION,
"memory allocation failed in vasprintf");
rust_assert (0);
}
std::string rval = std::string (mbuf);
free (mbuf);
rust_be_inform (location, rval);
}

namespace Rust {
Expand Down
5 changes: 2 additions & 3 deletions gcc/rust/rust-diagnostics.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,11 @@ struct Error
};
} // namespace Rust

// rust_debug uses normal printf formatting, not GCC diagnostic formatting.
#define rust_debug(...) rust_debug_loc (UNDEF_LOCATION, __VA_ARGS__)

#define rust_sorry_at(location, ...) sorry_at (location, __VA_ARGS__)

void rust_debug_loc (const location_t location, const char *fmt,
...) ATTRIBUTE_PRINTF_2;
void rust_debug_loc (const location_t location, const char *fmt, ...)
RUST_ATTRIBUTE_GCC_DIAG (2, 3);

#endif // !defined(RUST_DIAGNOSTICS_H)
2 changes: 1 addition & 1 deletion gcc/rust/rust-lang.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ grs_langhook_init_options_struct (struct gcc_options *opts)
static void
grs_langhook_parse_file (void)
{
rust_debug ("Preparing to parse files. ");
rust_debug ("preparing to parse files");

Rust::Session::get_instance ().handle_input_files (num_in_fnames, in_fnames);
}
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/rust-session-manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
#include "rust-target.h"
#include "rust-system.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats going on with all the #pragma GCC diagnostic ignored "-Wformat-diag"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the change from printf to GCC diagnostic formatting, GCC starts warning about diagnostic quality (excess punctuation, unquoted identifiers, etc).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure what to review here whats the improvement maybe i cant see it with all the diff

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It switches from printf style formatting (no %qs, %<, %>, %m, %r, %R, etc) to our implementation of GCC diagnostic style formatting (backwards compatible and with support for %qs, %<, %>, and %m, but not everything supported by GCC's main diagnostics system) for debug printing. #4784 is a follow up that switches us over to using GCC diagnostic formatting proper.


extern bool saw_errors (void);

extern Linemap *rust_get_linemap ();
Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-autoderef.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "rust-type-util.h"
#include "rust-substitution-mapper.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Resolver {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-casts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include "rust-casts.h"
#include "rust-tyty-util.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Resolver {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-coercion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include "rust-type-util.h"
#include "rust-tyty.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Resolver {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-hir-dot-operator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "rust-type-util.h"
#include "rust-coercion.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Resolver {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-hir-type-check-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#include "rust-tyty-util.h"
#include "rust-tyty.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Resolver {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-hir-type-check-path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include "rust-session-manager.h"
#include "rust-finalized-name-resolution-context.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Resolver {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-hir-type-check-type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include "rust-compile-base.h"
#include "rust-resolve-builtins.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Resolver {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-type-util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include "rust-substitution-mapper.h"
#include "rust-finalized-name-resolution-context.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Resolver {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-tyty-bounds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "rust-hir-trait-resolve.h"
#include "rust-type-util.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Resolver {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-tyty-subst.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include "rust-type-util.h"
#include "tree.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace TyTy {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-tyty-variance-analysis.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "rust-tyty-variance-analysis-private.h"
#include "rust-hir-type-check.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace TyTy {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-tyty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#include "tree.h"
#include "fold-const.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace TyTy {

Expand Down
3 changes: 3 additions & 0 deletions gcc/rust/typecheck/rust-unify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "rust-tyty.h"
#include "rust-type-util.h"

// TODO: fix warnings and remove
#pragma GCC diagnostic ignored "-Wformat-diag"

namespace Rust {
namespace Resolver {

Expand Down
Loading