Skip to content

Conversation

ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Aug 22, 2025

These are now unused, their removal discourages adding new warnings to the language.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @ibuclaw!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#21761"

@thewilsonator
Copy link
Contributor

thewilsonator commented Aug 22, 2025

These are used by LDC.

driver/ldmd.cpp:        warning("command-line option '%s' not yet supported by LDC.", p);
driver/linker-gcc.cpp:    warning(Loc(), "XRay may not be fully supported on non-Linux target OS.");
driver/linker-gcc.cpp:      warning(Loc(), "Ignoring -Xcc options");
driver/linker-msvc.cpp:    warning(Loc(), "no Visual C++ installation found for linking, falling back "
driver/linker-msvc.cpp:    // Suppress linker warning LNK4217 wrt. 'importing locally defined symbol'
driver/main.cpp:    warning(Loc(), "unknown target CPU architecture: %s",
driver/main.cpp:      warning(Loc(), "FreeBSD major version not specified in target triple");
driver/main.cpp:        warning(Loc(), "unknown target OS: %s", osName.str().c_str());
driver/targetmachine.cpp:    warning(Loc(), "Unknown ABI %s - using default ABI instead",
driver/targetmachine.cpp:      // We have to specify OS version in the triple to avoid linker warnings,
driver/toobj.cpp:  if (global.errors || global.warnings) {
driver/toobj.cpp:    Logger::println("Aborting because of errors/warnings during LLVM passes");
driver/toobj.cpp:  // Note: LLVM passes can add new warnings/errors (warnings become errors with
driver/toobj.cpp:    if (global.errors || global.warnings) {
driver/toobj.cpp:          "Aborting because of errors/warnings during bitcode LLVM passes");
driver/toobj.cpp:    if (global.errors || global.warnings) {
driver/toobj.cpp:      Logger::println("Aborting because of errors/warnings during LLVM passes");
gen/abi/abi.cpp:    warning(Loc(),
gen/functions.cpp:    warning(fd->loc,
gen/ldctraits.d:            warning(e.loc, "ignoring arguments for __traits %s", e.ident.toChars());
gen/llvmhelpers.cpp:    (void)numTotalVals; (void) product; // Silence unused variable warning when assert is disabled.
gen/pgo_ASTbased.cpp:      // Don't output a compiler warning when profile data is missing for a
gen/pgo_ASTbased.cpp:      warning(fd->loc,
gen/pgo_ASTbased.cpp:      warning(fd->loc,
gen/pgo_ASTbased.cpp:      warning(fd->loc, "Error loading profile data for function `%s` (`%s`)",
gen/pragma.cpp:    warning(s->loc,
gen/target.cpp:    warning(Loc(), "unknown properties for target `real` type, relying on D "
gen/uda.cpp:    warning(sle->loc,
gen/uda.cpp:    warning(sle->loc,
gen/uda.cpp:      warning(sle->loc,
gen/uda.cpp:        warning(sle->loc,
gen/uda.cpp:        warning(sle->loc,
gen/uda.cpp:    warning(sle->loc, "ignoring unrecognized calling convention name '%s' for "
gen/uda.cpp:      warning(sle->loc,

@thewilsonator
Copy link
Contributor

also

src/dmd/link.d(1615): Error: function `extern (C++) void dmd.link.__unittest_L1561_C1.ErrorSinkTest.verror(Loc loc, const(char)* format, __va_list_tag* ap)` does not override any function, did you mean to override `nothrow void dmd.errorsink.ErrorSinkNull.verror(dmd.location.Loc loc, const(char)* format, core.internal.vararg.sysv_x64.__va_list_tag* ap)`?
        void verror(Loc loc, const(char)* format, va_list ap)
             ^
src/dmd/link.d(1622): Error: function `extern (C++) void dmd.link.__unittest_L1561_C1.ErrorSinkTest.verrorSupplemental(Loc loc, const(char)* format, __va_list_tag* ap)` does not override any function, did you mean to override `nothrow void dmd.errorsink.ErrorSinkNull.verrorSupplemental(dmd.location.Loc loc, const(char)* format, core.internal.vararg.sysv_x64.__va_list_tag* ap)`?
        void verrorSupplemental(Loc loc, const(char)* format, va_list ap)

These are now unused, their removal discourages adding new warnings to
the language.
@ibuclaw ibuclaw force-pushed the rm_toplevel_warning branch from 32167f7 to 33036df Compare August 22, 2025 13:27
@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 22, 2025

also

src/dmd/link.d(1615): Error: function `extern (C++) void dmd.link.__unittest_L1561_C1.ErrorSinkTest.verror(Loc loc, const(char)* format, __va_list_tag* ap)` does not override any function, did you mean to override `nothrow void dmd.errorsink.ErrorSinkNull.verror(dmd.location.Loc loc, const(char)* format, core.internal.vararg.sysv_x64.__va_list_tag* ap)`?
        void verror(Loc loc, const(char)* format, va_list ap)
             ^
src/dmd/link.d(1622): Error: function `extern (C++) void dmd.link.__unittest_L1561_C1.ErrorSinkTest.verrorSupplemental(Loc loc, const(char)* format, __va_list_tag* ap)` does not override any function, did you mean to override `nothrow void dmd.errorsink.ErrorSinkNull.verrorSupplemental(dmd.location.Loc loc, const(char)* format, core.internal.vararg.sysv_x64.__va_list_tag* ap)`?
        void verrorSupplemental(Loc loc, const(char)* format, va_list ap)

Unittests, not compiler. Fixed.

@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 22, 2025

These are used by LDC.

...

Surely you should be using the native diagnostic engine?

https://mlir.llvm.org/docs/Diagnostics/

GDC does, and it implements its own version of vreportDiagnostic/vsupplementalDiagnostic that is a wrap around GCC diagnostic infrastructure - not the dmd frontend.

d-attribs.cc:	  warning_at (make_location_t (attr->loc), OPT_Wattributes,
d-attribs.cc:	      warning (OPT_Wattributes,
d-attribs.cc:	    warning (OPT_Wattributes,
d-attribs.cc:	  warning (OPT_Wattributes,
d-attribs.cc:	warning (OPT_Wattributes,
d-attribs.cc:      warning (OPT_Wattributes,
d-attribs.cc:      warning (OPT_Wattributes, "empty string in attribute %<target%>");
d-attribs.cc:      warning (OPT_Wattributes, "inline function %q+D declared weak", *node);
d-attribs.cc:      warning (OPT_Wattributes, "%qE attribute has no effect", name);
d-attribs.cc:      warning (OPT_Wattributes, "%qE attribute ignored", name);
d-attribs.cc:    warning (OPT_Wattributes, "%qE attribute ignored", name);
d-attribs.cc:	  warning (OPT_Wattributes, "%qE attribute ignored on types", name);
d-builtins.cc:		  warning_at (make_location_t (fd->loc),
d-codegen.cc:    warning (OPT_Waddress,
d-convert.cc:	  warning (OPT_Waddress,
d-convert.cc:	  warning (OPT_Wcast_result,
d-convert.cc:	      warning (OPT_Wcast_result, "cast to %qs will produce null result",
decl.cc:	    warning_at (make_location_t (d->loc), OPT_Wunknown_pragmas,
intrinsics.cc:    warning_at (EXPR_LOCATION (callexp), OPT_Wbuiltin_declaration_mismatch,
intrinsics.cc:  warning_at (EXPR_LOCATION (callexp), OPT_Wbuiltin_declaration_mismatch,
toir.cc:      warning (OPT_Wunused_value,
toir.cc:	warning (OPT_Wunused_value, "value computed is not used");
types.cc:	    warning_at (make_location_t (t->sym->loc),

@thewilsonator
Copy link
Contributor

MLIR is not LLVM.

@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 23, 2025

Copy link
Contributor

@dkorpel dkorpel left a comment

Choose a reason for hiding this comment

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

Fine by me of course 👍

Copy link
Contributor

@thewilsonator thewilsonator left a comment

Choose a reason for hiding this comment

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

https://llvm.org/doxygen/classllvm_1_1LLVMContext.html#aad03ef5cfbe6e7cad076d9e45ba06592

We only use that for inline asm diagnostics, and then only by proxy https://github.com/ldc-developers/ldc/blob/master/driver/codegenerator.cpp#L150

I don't think this should be done, but I will defer to @kinke in the mean time please do not merge

@kinke
Copy link
Contributor

kinke commented Aug 24, 2025

I don't see a good reason to change these LDC warnings, the dmd-frontend API is nice and trivial to use. We most likely don't need the pragma(printf) annotation though, as we're most likely only using them from C++. And we also don't use warningSupplemental (I've checked). So all LDC needs is one pragma-less dmd.errors.warning() function. If upstream here cannot live with that top-level function, I'll simply restore it in LDC. But I think the argument that it discourages future warnings is pretty weak, it's just removing the free-standing function, plus there's code review for a reason - and I don't buy the argument that the compiler should never ever use warnings, the real world is too complicated to do without them.

@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 24, 2025

But I think the argument that it discourages future warnings is pretty weak, it's just removing the free-standing function, plus there's code review for a reason

The remaining uses of errorsink.warning are:

  • Ddoc generation warnings.
  • DtoH generation warnings.
  • (DMD-only?) cannot inline function complaints (but not when warnings are treated as errors)
  • ImportC #pragma pack(show) - probably to copy what msvc does.

I'm half minded then just to rename the errorsink method to pedantic (or maybe inform), as none of the remaining frontend uses are a detriment to the language.

and I don't buy the argument that the compiler should never ever use warnings, the real world is too complicated to do without them.

GDC code generator has a lot to warn about.

https://compiler-explorer.com/z/h9Ev7Pq3W

Just do it with your native diagnostics engine. :-)

@kinke
Copy link
Contributor

kinke commented Aug 24, 2025

Just do it with your native diagnostics engine. :-)

The few things I've seen in LLVM are all for the LLVM backends. LLVM != gcc. :)

@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 25, 2025

Can still continue with the dismantling of everything else around warnings in dmd though. ;-)

#21777

@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 25, 2025

Just do it with your native diagnostics engine. :-)

The few things I've seen in LLVM are all for the LLVM backends. LLVM != gcc. :)

It doesn't look backend specific though.

https://llvm.org/doxygen/classllvm_1_1DiagnosticInfo.html

https://llvm.org/doxygen/classllvm_1_1LLVMContext.html#aad03ef5cfbe6e7cad076d9e45ba06592

We only use that for inline asm diagnostics, and then only by proxy https://github.com/ldc-developers/ldc/blob/master/driver/codegenerator.cpp#L150

You should be doing that for all diagnostics.

https://github.com/gcc-mirror/gcc/blob/1b6b27536311afefaebf57ff77ed20a8bb41eadd/gcc/d/d-diagnostic.cc#L223-L227

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants