Skip to content

Commit 797a0d1

Browse files
authored
Merge pull request #26840 from davezarzycki/pr26840
[Testing] Fix some build warnings
2 parents 0c0a984 + db0fea4 commit 797a0d1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

stdlib/tools/swift-reflection-test/swift-reflection-test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#include <fcntl.h>
3535
#endif
3636

37+
#if defined(__clang__) || defined(__GNUC__)
38+
#define NORETURN __attribute__((noreturn))
39+
#endif
40+
3741
typedef struct PipeMemoryReader {
3842
int to_child[2];
3943
int from_child[2];
@@ -56,11 +60,13 @@ typedef struct RemoteReflectionInfo {
5660
size_t TotalSize;
5761
} RemoteReflectionInfo;
5862

63+
NORETURN
5964
static void errorAndExit(const char *message) {
6065
fprintf(stderr, "%s\n", message);
6166
abort();
6267
}
6368

69+
NORETURN
6470
static void errnoAndExit(const char *message) {
6571
fprintf(stderr, "%s: %s\n", message, strerror(errno));
6672
abort();

tools/swift-ast-script/swift-ast-script.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class Observer : public FrontendObserver {
6262

6363
}
6464

65-
int main(int argc, const char *argv[]) {
65+
// ISO C++ does not allow 'main' to be used by a program [-Wmain]
66+
int main2(int argc, const char *argv[]) {
6667
PROGRAM_START(argc, argv);
6768

6869
// Look for the first "--" in the arguments.
@@ -87,7 +88,11 @@ int main(int argc, const char *argv[]) {
8788
frontendArgs.push_back("-typecheck");
8889

8990
int frontendResult =
90-
performFrontend(frontendArgs, argv[0], (void*) &main, &observer);
91+
performFrontend(frontendArgs, argv[0], (void*) &main2, &observer);
9192

9293
return (observer.hadError() ? 1 : frontendResult);
9394
}
95+
96+
int main(int argc, const char *argv[]) {
97+
return main2(argc, argv);
98+
}

0 commit comments

Comments
 (0)