From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id D62A93876898 for ; Tue, 7 Nov 2023 09:22:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D62A93876898 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D62A93876898 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1035 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699348934; cv=none; b=s+6nnppZNQn1hULnwPB4JYo/IEbyme4O4lh4gdqbNIBqp5DzeXpXatu9lKzCSP1zotTF6mF8N3Cf7iazUNBU1bcIop90wPOoTNZBGZRG86qkn9mKRXQjxjgL6NNUTpZTu8JX59B9287vooTsLPDy/Tesb2K2IxqZgWEVqMDAexs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699348934; c=relaxed/simple; bh=+E4j2FNujyqM0eb6ZZajSmpMpOpvBYcENOObm/7UMj8=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=bT806JFIt92IYW0pYxoSmfskEkF1nqOPL20vt5f6UKI4Hv7BSEQeG1YUaOe3iw+sA2QURdrrppNT9NIo1YQ2OrTyVFUKzBv4xj9FH9QMc3OWb/Ow2SC1YAZSeKYpNKk8PLsrRtzUX42O8snv+R5S6Sc7a4cmQRR7txETbZJb/k0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-280260db156so5035540a91.2 for ; Tue, 07 Nov 2023 01:22:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1699348930; x=1699953730; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=RJ+WJtO9F69ovIw7jAz1basu7bZw7L0MKqEAiAQo79k=; b=LU/mGSbSx5p5lUdz9q9Cmd7aUvy6Ec+N2eS+MdTznb/TL2jjN59v9kFEBlaJRjzzYd V3uDVb+3rPoJidprvlHElg4dJNOKc/4ciNeAHJHLQ5vwVU4Efsj91LynIvj/enPsouLi Cf4PBsKsd5r24GgB/0epku/IBW8VzpAZ+vfA1Ae7zBKs1Wm3rBIvceSa4NYhau5VKNda HZiOjRAOfmEFULiPXbkLArQ3vSGL7b1/8p0iKPupkQHH5DiCcnCEXnlojtC8EmYgNap/ paxq+SGFIkodwh64PP0NoPD6is74hw11l/5cp6JTizl1On27OZ8KAa/y6nqhDXcBepHx sQCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699348930; x=1699953730; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RJ+WJtO9F69ovIw7jAz1basu7bZw7L0MKqEAiAQo79k=; b=fWzgOpZ8aUP1VG+Dfe+MarW9m93AUAK+go/xyZQ9pvoZ8L8llMVHTGH5245kKkVz5s doRpfjUe0eGVRGOZhVTIt33VVX48PgzojAB8af9vVEzcpMGdrCFEMXi06PW6ox1m9O7c DgXpu76l2QwJhITrOJUy2o6zoJhkRhDKAju5cSt2cf5u/lBSWuliIiLKGOd7MtYkVXUx LCYA3QNBzy4qzw9bm1TlBizxLo8x0w/XjK/v2MphryKjfrOw6EEJxxxldVxMNLO3X8xm 0r//kzzvxo2KCxG5uoPUjmkYMcH0y2GmslzDVXaoSgVerCoeT/uWAdtgwAQeWJsV2Cjj rejA== X-Gm-Message-State: AOJu0YwsocyKRdvWKrclUSPtAtktDBcisOMtDLmU4t42KRTzUIx3m0PR PQFah8nhiwa9UY4oZEJA7vvlktVOkYAaJ8sreeUfQA== X-Google-Smtp-Source: AGHT+IHfs/YbmotUL76dAFNBjA2S0AsLaJipxNAPoXN2XzYO26saGkWhFrmuEH3FJpET4R2JHTQ+CSE+JxCiNwzAoxg= X-Received: by 2002:a17:90a:1948:b0:280:2613:c378 with SMTP id 8-20020a17090a194800b002802613c378mr24035713pjh.40.1699348929555; Tue, 07 Nov 2023 01:22:09 -0800 (PST) MIME-Version: 1.0 References: <20231106222959.2707741-1-dmalcolm@redhat.com> <20231106222959.2707741-4-dmalcolm@redhat.com> In-Reply-To: <20231106222959.2707741-4-dmalcolm@redhat.com> From: =?UTF-8?Q?Cl=C3=A9ment_Chigot?= Date: Tue, 7 Nov 2023 10:21:58 +0100 Message-ID: Subject: Re: [PATCH] binutils: experimental use of libdiagnostics in gas To: David Malcolm Cc: gcc-patches@gcc.gnu.org, binutils@sourceware.org, Nick Clifton , Simon Sobisch Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi David, Thanks for that interesting RFC ! I'm fully in favor of such improvements, having uniformed error messages across gcc, gas and later ld, would greatly help integration of these tools, let alone the SARIF format output. However, I'm not sure how you're planning to make the transition. But currently, it looks like libdiagnostics is either enabled and thus the new format being produced, either it's not and we do have the legacy format. I think the transition should be smoother than that, there are probably thousands of tests, scripts, whatever out in the wild expecting this legacy format. Allowing both formats within the same executable, basically chosen by a flag, would probably ease the transition. Apart from that, just a few remarks on the implementation details, see belo= w. Thanks, Cl=C3=A9ment On Mon, Nov 6, 2023 at 11:30=E2=80=AFPM David Malcolm = wrote: > > Here's a patch for gas in binutils that makes it use libdiagnostics > (with some nasty hardcoded paths to specific places on my hard drive > to make it easier to develop the API). > > For now this hardcodes adding two sinks: a text sink on stderr, and > also a SARIF output to stderr (which happens after all regular output). > > For example, without this patch: > > gas testsuite/gas/all/warn-1.s > > emits: > VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV= VVV > testsuite/gas/all/warn-1.s: Assembler messages: > testsuite/gas/all/warn-1.s:3: Warning: a warning message > testsuite/gas/all/warn-1.s:4: Error: .warning argument must be a string > testsuite/gas/all/warn-1.s:5: Warning: .warning directive invoked in sour= ce file > testsuite/gas/all/warn-1.s:6: Warning: .warning directive invoked in sour= ce file > testsuite/gas/all/warn-1.s:7: Warning: > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^= ^^^ > > whereas with this patch: > LD_LIBRARY_PATH=3D/home/david/coding-3/gcc-newgit-canvas-2023/build/gcc= ./as-new testsuite/gas/all/warn-1.s > emits: > > VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV= VVV > testsuite/gas/all/warn-1.s:3: warning: a warning message > 3 | .warning "a warning message" ;# { dg-warning "Warning: a warni= ng message" } > | > testsuite/gas/all/warn-1.s:4: error: .warning argument must be a string > 4 | .warning a warning message ;# { dg-error "Error: .warning ar= gument must be a string" } > | > testsuite/gas/all/warn-1.s:5: warning: .warning directive invoked in sour= ce file > 5 | .warning ;# { dg-warning "Warning: .warnin= g directive invoked in source file" } > | > testsuite/gas/all/warn-1.s:6: warning: .warning directive invoked in sour= ce file > 6 | .warning ".warning directive invoked in source file" ;# { dg-w= arning "Warning: .warning directive invoked in source file" } > | > testsuite/gas/all/warn-1.s:7: warning: > 7 | .warning "" ;# { dg-warning "Warning: " } > | > {"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-sp= ec/master/Schemata/sarif-schema-2.1.0.json", "version": "2.1.0", "runs": [{= "tool": {"driver": {"rules": []}}, "invocations": [{"executionSuccessful": = true, "toolExecutionNotifications": []}], "originalUriBaseIds": {"PWD": {"u= ri": "file:///home/david/coding-3/binutils-gdb/gas/"}}, "artifacts": [{"loc= ation": {"uri": "testsuite/gas/all/warn-1.s", "uriBaseId": "PWD"}, "content= s": {"text": ";# Test .warning directive.\n;# { dg-do assemble }\n .warning= \"a warning message\"\t;# { dg-warning \"Warning: a warning message\" }\n = .warning a warning message\t;# { dg-error \"Error: .warning argument must b= e a string\" }\n .warning\t\t\t;# { dg-warning \"Warning: .warning directiv= e invoked in source file\" }\n .warning \".warning directive invoked in sou= rce file\"\t;# { dg-warning \"Warning: .warning directive invoked in source= file\" }\n .warning \"\"\t\t\t;# { dg-warning \"Warning: \" }\n"}}], "resu= lts": [{"ruleId": "warning", "level": "warning", "message": {"text": "a war= ning message"}, "locations": [{"physicalLocation": {"artifactLocation": {"u= ri": "testsuite/gas/all/warn-1.s", "uriBaseId": "PWD"}, "region": {"startLi= ne": 3, "startColumn": 0, "endColumn": 1}, "contextRegion": {"startLine": 3= , "snippet": {"text": " .warning \"a warning message\"\t;# { dg-warning \"W= arning: a warning message\" }\n"}}}}], "relatedLocations": [{"physicalLocat= ion": {"artifactLocation": {"uri": "testsuite/gas/all/warn-1.s", "uriBaseId= ": "PWD"}, "region": {"startLine": 4, "startColumn": 0, "endColumn": 1}, "c= ontextRegion": {"startLine": 4, "snippet": {"text": " .warning a warning me= ssage\t;# { dg-error \"Error: .warning argument must be a string\" }\n"}}},= "message": {"text": ".warning argument must be a string"}}, {"physicalLoca= tion": {"artifactLocation": {"uri": "testsuite/gas/all/warn-1.s", "uriBaseI= d": "PWD"}, "region": {"startLine": 5, "startColumn": 0, "endColumn": 1}, "= contextRegion": {"startLine": 5, "snippet": {"text": " .warning\t\t\t;# { d= g-warning \"Warning: .warning directive invoked in source file\" }\n"}}}, "= message": {"text": ".warning directive invoked in source file"}}, {"physica= lLocation": {"artifactLocation": {"uri": "testsuite/gas/all/warn-1.s", "uri= BaseId": "PWD"}, "region": {"startLine": 6, "startColumn": 0, "endColumn": = 1}, "contextRegion": {"startLine": 6, "snippet": {"text": " .warning \".war= ning directive invoked in source file\"\t;# { dg-warning \"Warning: .warnin= g directive invoked in source file\" }\n"}}}, "message": {"text": ".warning= directive invoked in source file"}}, {"physicalLocation": {"artifactLocati= on": {"uri": "testsuite/gas/all/warn-1.s", "uriBaseId": "PWD"}, "region": {= "startLine": 7, "startColumn": 0, "endColumn": 1}, "contextRegion": {"start= Line": 7, "snippet": {"text": " .warning \"\"\t\t\t;# { dg-warning \"Warnin= g: \" }\n"}}}, "message": {"text": ""}}]}]}]} > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^= ^^^ > > which I see: > - drops the leading "Assembler messages" warning, > - changes the capitalization of the "Warning" -> "warning" etc > - quotes the pertinent line in the .s file > > All of the locations are just lines; does gas do column numbers at all? > (or ranges?) > > For reference, running the above SARIF through "python -m json.tool" to > prettyify it gives: > > VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV= VVV > { > "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/ma= ster/Schemata/sarif-schema-2.1.0.json", > "version": "2.1.0", > "runs": [ > { > "tool": { > "driver": { > "rules": [] > } > }, > "invocations": [ > { > "executionSuccessful": true, > "toolExecutionNotifications": [] > } > ], > "originalUriBaseIds": { > "PWD": { > "uri": "file:///home/david/coding-3/binutils-gdb/gas/= " > } > }, > "artifacts": [ > { > "location": { > "uri": "testsuite/gas/all/warn-1.s", > "uriBaseId": "PWD" > }, > "contents": { > "text": ";# Test .warning directive.\n;# { dg-do = assemble }\n .warning \"a warning message\"\t;# { dg-warning \"Warning: a w= arning message\" }\n .warning a warning message\t;# { dg-error \"Error: .wa= rning argument must be a string\" }\n .warning\t\t\t;# { dg-warning \"Warni= ng: .warning directive invoked in source file\" }\n .warning \".warning dir= ective invoked in source file\"\t;# { dg-warning \"Warning: .warning direct= ive invoked in source file\" }\n .warning \"\"\t\t\t;# { dg-warning \"Warni= ng: \" }\n" > } > } > ], > "results": [ > { > "ruleId": "warning", > "level": "warning", > "message": { > "text": "a warning message" > }, > "locations": [ > { > "physicalLocation": { > "artifactLocation": { > "uri": "testsuite/gas/all/warn-1.s", > "uriBaseId": "PWD" > }, > "region": { > "startLine": 3, > "startColumn": 0, > "endColumn": 1 > }, > "contextRegion": { > "startLine": 3, > "snippet": { > "text": " .warning \"a warning me= ssage\"\t;# { dg-warning \"Warning: a warning message\" }\n" > } > } > } > } > ], > "relatedLocations": [ > { > "physicalLocation": { > "artifactLocation": { > "uri": "testsuite/gas/all/warn-1.s", > "uriBaseId": "PWD" > }, > "region": { > "startLine": 4, > "startColumn": 0, > "endColumn": 1 > }, > "contextRegion": { > "startLine": 4, > "snippet": { > "text": " .warning a warning mess= age\t;# { dg-error \"Error: .warning argument must be a string\" }\n" > } > } > }, > "message": { > "text": ".warning argument must be a stri= ng" > } > }, > { > "physicalLocation": { > "artifactLocation": { > "uri": "testsuite/gas/all/warn-1.s", > "uriBaseId": "PWD" > }, > "region": { > "startLine": 5, > "startColumn": 0, > "endColumn": 1 > }, > "contextRegion": { > "startLine": 5, > "snippet": { > "text": " .warning\t\t\t;# { dg-w= arning \"Warning: .warning directive invoked in source file\" }\n" > } > } > }, > "message": { > "text": ".warning directive invoked in so= urce file" > } > }, > { > "physicalLocation": { > "artifactLocation": { > "uri": "testsuite/gas/all/warn-1.s", > "uriBaseId": "PWD" > }, > "region": { > "startLine": 6, > "startColumn": 0, > "endColumn": 1 > }, > "contextRegion": { > "startLine": 6, > "snippet": { > "text": " .warning \".warning dir= ective invoked in source file\"\t;# { dg-warning \"Warning: .warning direct= ive invoked in source file\" }\n" > } > } > }, > "message": { > "text": ".warning directive invoked in so= urce file" > } > }, > { > "physicalLocation": { > "artifactLocation": { > "uri": "testsuite/gas/all/warn-1.s", > "uriBaseId": "PWD" > }, > "region": { > "startLine": 7, > "startColumn": 0, > "endColumn": 1 > }, > "contextRegion": { > "startLine": 7, > "snippet": { > "text": " .warning \"\"\t\t\t;# {= dg-warning \"Warning: \" }\n" > } > } > }, > "message": { > "text": "" > } > } > ] > } > ] > } > ] > } > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^= ^^^ > > Thoughts? > > gas/ChangeLog: > * Makefile.am (GASLIBS): Add nasty hack with hardcoded path > on my hard drive. > * Makefile.in (GASLIBS): Likewise. > * as.c (gas_init): Call messages_init. > (main): Call messages_end. > * as.h (messages_init): New decl. > (messages_end): New decl. > * messages.c (USE_LIBDIAGNOSTICS): New define. > Add #include with nasty hardcoded path. > (diag_mgr): New. > (messages_init): New. > (messages_end): New. > (as_warn_internal): Add support for libdiagnostics. > (as_bad_internal): Likewise. > --- > gas/Makefile.am | 3 ++- > gas/Makefile.in | 4 ++- > gas/as.c | 3 +++ > gas/as.h | 3 +++ > gas/messages.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ > 5 files changed, 79 insertions(+), 2 deletions(-) > > diff --git a/gas/Makefile.am b/gas/Makefile.am > index 0e98ca3ec85..fe92997129c 100644 > --- a/gas/Makefile.am > +++ b/gas/Makefile.am > @@ -408,7 +408,8 @@ AM_CPPFLAGS =3D -I. -I$(srcdir) -I../bfd -I$(srcdir)/= config \ > # How to link with both our special library facilities > # and the system's installed libraries. > > -GASLIBS =3D @OPCODES_LIB@ ../bfd/libbfd.la ../libiberty/libiberty.a > +# FIXME: > +GASLIBS =3D @OPCODES_LIB@ ../bfd/libbfd.la ../libiberty/libiberty.a /hom= e/david/coding-3/gcc-newgit-canvas-2023/build/gcc/libdiagnostics.so > > # Files to be copied away after each stage in building. > STAGESTUFF =3D *.@OBJEXT@ $(noinst_PROGRAMS) > diff --git a/gas/Makefile.in b/gas/Makefile.in > index fae3a47c144..2161d68f9c7 100644 > --- a/gas/Makefile.in > +++ b/gas/Makefile.in > @@ -885,7 +885,9 @@ AM_CPPFLAGS =3D -I. -I$(srcdir) -I../bfd -I$(srcdir)/= config \ > > # How to link with both our special library facilities > # and the system's installed libraries. > -GASLIBS =3D @OPCODES_LIB@ ../bfd/libbfd.la ../libiberty/libiberty.a > + > +# FIXME: > +GASLIBS =3D @OPCODES_LIB@ ../bfd/libbfd.la ../libiberty/libiberty.a /hom= e/david/coding-3/gcc-newgit-canvas-2023/build/gcc/libdiagnostics.so > > # Files to be copied away after each stage in building. > STAGESTUFF =3D *.@OBJEXT@ $(noinst_PROGRAMS) > diff --git a/gas/as.c b/gas/as.c > index 6839c841588..2a8ce3734a0 100644 > --- a/gas/as.c > +++ b/gas/as.c > @@ -1300,6 +1300,7 @@ gas_early_init (int *argcp, char ***argvp) > static void > gas_init (void) > { > + messages_init (); > symbol_begin (); > frag_init (); > subsegs_begin (); > @@ -1486,6 +1487,8 @@ main (int argc, char ** argv) > > input_scrub_end (); > > + messages_end (); > + > /* Use xexit instead of return, because under VMS environments they > may not place the same interpretation on the value given. */ > if (had_errors () !=3D 0) > diff --git a/gas/as.h b/gas/as.h > index 99ffe77afd2..9d878a87df5 100644 > --- a/gas/as.h > +++ b/gas/as.h > @@ -474,6 +474,9 @@ void as_bad_value_out_of_range (const char *, offse= tT, offsetT, offsetT, > void print_version_id (void); > char * app_push (void); > > +void messages_init (void); > +void messages_end (void); > + > /* Number of littlenums required to hold an extended precision number. *= / > #define MAX_LITTLENUMS 6 > > diff --git a/gas/messages.c b/gas/messages.c > index 7c018acf69f..3cb8525fad9 100644 > --- a/gas/messages.c > +++ b/gas/messages.c > @@ -21,6 +21,14 @@ > #include > #include > > +// FIXME: do some configury thing for this > +#define USE_LIBDIAGNOSTICS 1 > + > +#if USE_LIBDIAGNOSTICS > +// FIXME: need to fix this path, obviously > +#include "/home/david/coding-3/gcc-newgit-canvas-2023/src/gcc/libdiagnos= tics.h" > +#endif > + > /* If the system doesn't provide strsignal, we get it defined in > libiberty but no declaration is supplied. Because, reasons. */ > #if !defined (HAVE_STRSIGNAL) && !defined (strsignal) > @@ -101,6 +109,29 @@ had_warnings (void) > return warning_count; > } > > +#if USE_LIBDIAGNOSTICS > +static diagnostic_manager *diag_mgr; Would it make sense for an application to have several "diagnostic_manager" ? If no, I'm wondering if this variable shouldn't be hidden inside libdiagnostics itself, avoiding every calls to have this diag_mgr argument. > +#endif > + > +void messages_init (void) > +{ > +#if USE_LIBDIAGNOSTICS > + diag_mgr =3D diagnostic_manager_new (); > + diagnostic_manager_add_text_sink (diag_mgr, stderr, > + DIAGNOSTIC_COLORIZE_IF_TTY); > + diagnostic_manager_add_sarif_sink (diag_mgr, stderr, > + DIAGNOSTIC_SARIF_VERSION_2_1_0); > +#endif > +} > + > +void messages_end (void) > +{ > +#if USE_LIBDIAGNOSTICS > + diagnostic_manager_release (diag_mgr); IIUC, diagnostic_manager_release must be called to produce any output. However, nothing prevents the application to exit earlier see "as_fatal". Thus, this probably need to be called using atexit to ensure that whatever happens the messages are being outputted. > + diag_mgr =3D NULL; > +#endif > +} > + > /* Nonzero if we've hit a 'bad error', and should not write an obj file, > and exit with a nonzero error code. */ > > @@ -172,16 +203,34 @@ as_tsktsk (const char *format, ...) > static void > as_warn_internal (const char *file, unsigned int line, char *buffer) > { > +#if !USE_LIBDIAGNOSTICS > bool context =3D false; > +#endif > > ++warning_count; > > if (file =3D=3D NULL) > { > file =3D as_where_top (&line); > +#if !USE_LIBDIAGNOSTICS > context =3D true; > +#endif > } > > +#if USE_LIBDIAGNOSTICS > + const diagnostic_file *file_obj > + =3D diagnostic_manager_new_file (diag_mgr, file, NULL); > + > + diagnostic_location_t loc > + =3D diagnostic_manager_new_location_from_file_and_line (diag_mgr, > + file_obj, > + line); > + > + diagnostic *d =3D diagnostic_begin (diag_mgr, > + DIAGNOSTIC_LEVEL_WARNING); > + diagnostic_set_location (d, loc); > + diagnostic_finish (d, "%s", buffer); > +#else > identify (file); > if (file) > { > @@ -199,6 +248,7 @@ as_warn_internal (const char *file, unsigned int line= , char *buffer) > #ifndef NO_LISTING > listing_warning (buffer); > #endif > +#endif /* #else clause of #if USE_LIBDIAGNOSTICS */ > } > > /* Send to stderr a string as a warning, and locate warning > @@ -246,16 +296,33 @@ as_warn_where (const char *file, unsigned int line,= const char *format, ...) > static void > as_bad_internal (const char *file, unsigned int line, char *buffer) > { > +#if !USE_LIBDIAGNOSTICS > bool context =3D false; > +#endif > > ++error_count; > > if (file =3D=3D NULL) > { > file =3D as_where_top (&line); > +#if !USE_LIBDIAGNOSTICS > context =3D true; > +#endif > } > > +#if USE_LIBDIAGNOSTICS > + const diagnostic_file *file_obj > + =3D diagnostic_manager_new_file (diag_mgr, file, NULL); > + diagnostic_location_t loc > + =3D diagnostic_manager_new_location_from_file_and_line (diag_mgr, > + file_obj, > + line); > + > + diagnostic *d =3D diagnostic_begin (diag_mgr, > + DIAGNOSTIC_LEVEL_ERROR); > + diagnostic_set_location (d, loc); > + diagnostic_finish (d, "%s", buffer); > +#else > identify (file); > if (file) > { > @@ -269,6 +336,7 @@ as_bad_internal (const char *file, unsigned int line,= char *buffer) > > if (context) > as_report_context (); > +#endif /* #else clause of #if USE_LIBDIAGNOSTICS */ > > #ifndef NO_LISTING > listing_error (buffer); > -- > 2.26.3 >