• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

修訂bf2d557b0a2a780967e68f4bf978ab35cd37564f (tree)
時間2009-08-19 09:20:08
作者Jack Palevich <jackpal@goog...>
CommiterAndroid Git Automerger

Log Message

am 29f34260: Merge change 21812 into eclair

Merge commit '29f3426016116678c122b37cf6d5d40bdfec7749'

* commit '29f3426016116678c122b37cf6d5d40bdfec7749':

Allow parenthesized expressions as the value of defines

Change Summary

差異

--- a/libacc/acc.cpp
+++ b/libacc/acc.cpp
@@ -3812,9 +3812,6 @@ class Compiler : public ErrorSink {
38123812 next();
38133813 tokenid_t name = tok;
38143814 String* pName = new String();
3815- while (isspace(ch)) {
3816- inp();
3817- }
38183815 if (ch == '(') {
38193816 delete pName;
38203817 error("Defines with arguments not supported");
--- /dev/null
+++ b/libacc/tests/data/defines.c
@@ -0,0 +1,7 @@
1+// Simple tests of the C preprocessor
2+
3+#define A (1 + 2)
4+
5+int main() {
6+ return A;
7+}
--- a/libacc/tests/test
+++ b/libacc/tests/test
@@ -2,5 +2,5 @@
22
33 SCRIPT_DIR=`dirname $BASH_SOURCE`
44 cd $SCRIPT_DIR
5-python test.py
5+python test.py "$@"
66
--- a/libacc/tests/test.py
+++ b/libacc/tests/test.py
@@ -4,9 +4,28 @@
44 import unittest
55 import subprocess
66 import os
7-import sets
7+import sys
88
99 gArmInitialized = False
10+gUseArm = True
11+gUseX86 = True
12+gRunOTCCOutput = True
13+
14+
15+def parseArgv():
16+ global gUseArm
17+ global gRunOTCCOutput
18+ for arg in sys.argv[1:]:
19+ if arg == "--noarm":
20+ print "--noarm detected, not testing on ARM"
21+ gUseArm = False
22+ elif arg == "--norunotcc":
23+ print "--norunotcc detected, not running OTCC output"
24+ gRunOTCCOutput = False
25+ else:
26+ print "Unknown parameter: ", arg
27+ raise "Unknown parameter"
28+ sys.argv = sys.argv[0:1]
1029
1130 def compile(args):
1231 proc = subprocess.Popen(["acc"] + args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
@@ -131,11 +150,13 @@ class TestACC(unittest.TestCase):
131150
132151 def compileCheck(self, args, stdErrResult, stdOutResult="",
133152 targets=['arm', 'x86']):
134- targetSet = sets.ImmutableSet(targets)
135- if False and 'x86' in targetSet:
153+ global gUseArm
154+ global gUseX86
155+ targetSet = frozenset(targets)
156+ if gUseX86 and 'x86' in targetSet:
136157 out, err = compile(args)
137158 self.checkResult(out, err, stdErrResult, stdOutResult)
138- if 'arm' in targetSet:
159+ if gUseArm and 'arm' in targetSet:
139160 out = compileArm(rewritePaths(args))
140161 self.checkResult(out, "", stdErrResult, stdOutResult)
141162
@@ -157,13 +178,17 @@ class TestACC(unittest.TestCase):
157178 "Executing compiled code:\nresult: 13\n", "Hello, world\n")
158179
159180 def testRunOTCCANSI(self):
160- self.compileCheck(["-R", "data/otcc-ansi.c", "data/returnval.c"],
161- "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\natcc-ansi.c: result: 42\nresult: 42\n", "",
162- ['x86'])
181+ global gRunOTCCOutput
182+ if gRunOTCCOutput:
183+ self.compileCheck(["-R", "data/otcc-ansi.c", "data/returnval.c"],
184+ "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\natcc-ansi.c: result: 42\nresult: 42\n", "",
185+ ['x86'])
163186
164187 def testRunOTCCANSI2(self):
165- self.compileCheck(["-R", "data/otcc-ansi.c", "data/otcc.c", "data/returnval.c"],
166- "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\notcc.c: about to execute compiled code.\natcc-ansi.c: result: 42\nresult: 42\n", "",['x86'])
188+ global gRunOTCCOutput
189+ if gRunOTCCOutput:
190+ self.compileCheck(["-R", "data/otcc-ansi.c", "data/otcc.c", "data/returnval.c"],
191+ "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\notcc.c: about to execute compiled code.\natcc-ansi.c: result: 42\nresult: 42\n", "",['x86'])
167192
168193 def testRunConstants(self):
169194 self.compileCheck(["-R", "data/constants.c"],
@@ -409,8 +434,17 @@ lmnopabcdefghijklmno
409434 result: 0
410435 ""","""""")
411436
412-if __name__ == '__main__':
437+ def testDefines(self):
438+ self.compileCheck(["-R", "data/defines.c"], """Executing compiled code:
439+result: 3
440+""","""""")
441+
442+def main():
443+ parseArgv()
413444 if not outputCanRun():
414- print "Many tests are expected to fail, because acc is not a 32-bit x86 Linux executable."
445+ print "Can't run output of acc compiler."
415446 unittest.main()
416447
448+if __name__ == '__main__':
449+ main()
450+