Support nested macros. (Still don't support macro arguments.)
Now you can say:
#define A B
#define B C
#define C 4
int x = A;
And it will work as expected.
Print an error message rather than assert when we're expecting a
function value, but don't find one.
diff --git a/libacc/tests/data/macros.c b/libacc/tests/data/macros.c
new file mode 100644
index 0000000..50e54dc
--- /dev/null
+++ b/libacc/tests/data/macros.c
@@ -0,0 +1,10 @@
+#define A B + B
+#define B C
+
+int main() {
+ int C = 3;
+ printf("A = %d\n", A);
+#define C 5
+ printf("A = %d\n", A);
+ return 0;
+}
diff --git a/libacc/tests/main.cpp b/libacc/tests/main.cpp
index 948f4cb..e4e386f 100644
--- a/libacc/tests/main.cpp
+++ b/libacc/tests/main.cpp
@@ -38,14 +38,7 @@
}
ACCvoid* symbolLookup(ACCvoid* pContext, const ACCchar* name) {
- // Call dlerror once to clear out any preexisting error condition.
- (void) dlerror();
- ACCvoid* result = (ACCvoid*) dlsym(RTLD_DEFAULT, name);
- const char* error = dlerror();
- if (error) {
- fprintf(stderr, "%s\"%s\"\n", error, name);
- }
- return result;
+ return (ACCvoid*) dlsym(RTLD_DEFAULT, name);
}
#ifdef PROVIDE_ARM_DISASSEMBLY
diff --git a/libacc/tests/test.py b/libacc/tests/test.py
index c982d16..8f4920b 100644
--- a/libacc/tests/test.py
+++ b/libacc/tests/test.py
@@ -373,6 +373,12 @@
Total bad: 0
""")
+ def testMacros(self):
+ self.compileCheck(["-R", "data/macros.c"], """Executing compiled code:
+result: 0""", """A = 6
+A = 10
+""")
+
def testpointers2(self):
self.compileCheck(["-R", "data/pointers2.c"], """Executing compiled code:
result: 0""", """a = 0, *pa = 0