[PATCH] D150966: [clang] Don't define predefined macros multiple times
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 24 09:13:52 PDT 2023
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM
================
Comment at: clang/test/Preprocessor/predefined-macros-no-warnings.c:5
+// warnings suppressed by default.
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arc
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple xcore
----------------
john.brawn wrote:
> aaron.ballman wrote:
> > So the expectation is that any warnings that are emitted would be upgraded to an error and the test would be flagged as a failure because %clang_cc1 would return nonzero in that case?
> >
> > (I was thrown for a loop by not using `-verify` and `// expected-no-diagnostics`)
> >
> > Pretty sure `-Eonly` is equivalent (it runs the preprocessor without emitting output, so no extra overhead from piping to /dev/null).
> Yes the intent is for the test to fail on any warning. Using `-Werror` and not `-verify` means that on failure you get which macro caused the error:
> ```
> Exit Code: 1
>
> Command Output (stderr):
> --
> <built-in>:351:9: error: redefining builtin macro [-Werror,-Wbuiltin-macro-redefined]
> #define __LITTLE_ENDIAN__ 1
> ^
> 1 error generated.
>
> --
> ```
> whereas `-verify` just outputs
> ```
> Exit Code: 1
>
> Command Output (stderr):
> --
> error: 'error' diagnostics seen but not expected:
> Line 351: redefining builtin macro
> 1 error generated.
>
> --
> ```
>
> Using `-Eonly` makes sense, I'll do that.
Oh, that's a handy failure mechanism, thank you for pointing that out!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150966/new/
https://reviews.llvm.org/D150966
More information about the cfe-commits
mailing list