Created
April 30, 2020 22:53
-
-
Save EricWF/71170c173bdca4825065817992507ce7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RUN: $CXX -c %s -o /tmp/first.o -std=c++17 -g | |
// RUN: $CXX -c %s -o /tmp/second.o -std=c++17 -g -DWITH_MAIN | |
// RUN: $CXX -o /tmp/test.out /tmp/first.o /tmp/second.o | |
// RUN: /tmp/test.out | |
#include <cassert> | |
namespace { | |
__attribute__((noinline)) | |
int bar() asm(".my-name"); | |
__attribute__((noinline)) | |
int bar() { | |
#ifdef WITH_MAIN | |
return 42; | |
#else | |
return 101; | |
#endif | |
} | |
} | |
int t1(); | |
int t2(); | |
#ifdef WITH_MAIN | |
int t1() { return bar(); } | |
#else | |
int t2() { return bar(); } | |
#endif | |
#ifdef WITH_MAIN | |
int main() { | |
assert(t1() != t2()); | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment