History

-fdollar-in-identifiers addon

* disable a -fdollar-in-identifiers option in assembler files * a test is added This is a patch addon from Daniel Holden.

seyko committed 11 years ago

Commit 5ce21541 parent 9336fa74 files · +21 −13Browse files

Unified · Split

4 files
  1. tccasm.c +1 −1
  2. tccpp.c +11 −7
  3. tests/Makefile +1 −1
  4. tests/tests2/Makefile +8 −4
tccasm.c+1−1
@@ -747,7 +747,7 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess) · 746 unmodified lines
747 747
748 ch = file->buf_ptr[0];748 ch = file->buf_ptr[0];
749 tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;749 tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
750 parse_flags = PARSE_FLAG_ASM_COMMENTS;750 parse_flags = PARSE_FLAG_ASM_COMMENTS | PARSE_FLAG_ASM_FILE;
751 if (do_preprocess)751 if (do_preprocess)
752 parse_flags |= PARSE_FLAG_PREPROCESS;752 parse_flags |= PARSE_FLAG_PREPROCESS;
753 next();753 next();
tccpp.c+11−7
@@ -2313,9 +2313,11 @@ maybe_newline: · 2312 unmodified lines
2313 }2313 }
2314 break;2314 break;
2315 2315
2316 /* treat $ as allowed char in indentifier */2316 /* dollar is allowed to start identifiers when not parsing asm */
2317 case '$': if (!tcc_state->dollars_in_identifiers) goto parse_simple; 2317 case '$':
2318 2318 if (!tcc_state->dollars_in_identifiers
2319 || (parse_flags & PARSE_FLAG_ASM_FILE)) goto parse_simple;
2320
2319 case 'a': case 'b': case 'c': case 'd':2321 case 'a': case 'b': case 'c': case 'd':
2320 case 'e': case 'f': case 'g': case 'h':2322 case 'e': case 'f': case 'g': case 'h':
2321 case 'i': case 'j': case 'k': case 'l':2323 case 'i': case 'j': case 'k': case 'l':
@@ -2338,7 +2340,8 @@ maybe_newline: · 16 unmodified lines
2338 p++;2340 p++;
2339 for(;;) {2341 for(;;) {
2340 c = *p;2342 c = *p;
2341 if (!isidnum_table[c-CH_EOF])2343 if (!isidnum_table[c-CH_EOF]
2344 && (tcc_state->dollars_in_identifiers ? (c != '$') : 1))
2342 break;2345 break;
2343 h = TOK_HASH_FUNC(h, c);2346 h = TOK_HASH_FUNC(h, c);
2344 p++;2347 p++;
@@ -2373,7 +2376,8 @@ maybe_newline: · 28 unmodified lines
2373 p--;2376 p--;
2374 PEEKC(c, p);2377 PEEKC(c, p);
2375 parse_ident_slow:2378 parse_ident_slow:
2376 while (isidnum_table[c-CH_EOF]) {2379 while (isidnum_table[c-CH_EOF]
2380 || (tcc_state->dollars_in_identifiers ? (c == '$') : 0)) {
2377 cstr_ccat(&tokcstr, c);2381 cstr_ccat(&tokcstr, c);
2378 PEEKC(c, p);2382 PEEKC(c, p);
2379 }2383 }
@@ -3202,9 +3206,9 @@ ST_FUNC void preprocess_new(void) · 822 unmodified lines
3202 const char *p, *r;3206 const char *p, *r;
3203 3207
3204 /* init isid table */3208 /* init isid table */
3209
3205 for(i=CH_EOF;i<256;i++)3210 for(i=CH_EOF;i<256;i++)
3206 isidnum_table[i-CH_EOF] = (isid(i) || isnum(i) ||3211 isidnum_table[i-CH_EOF] = isid(i) || isnum(i);
3207 (tcc_state->dollars_in_identifiers ? i == '$' : 0));
3208 3212
3209 /* add all tokens */3213 /* add all tokens */
3210 if (table_ident) {3214 if (table_ident) {
tests/Makefile+1−1
@@ -199,7 +199,7 @@ ex%: $(top_srcdir)/examples/ex%.c · 198 unmodified lines
199 199
200# tiny assembler testing200# tiny assembler testing
201asmtest.ref: asmtest.S201asmtest.ref: asmtest.S
202 $(CC) -Wa,-W -o asmtest.ref.o -c asmtest.S202 $(CC) -m32 -Wa,-W -o asmtest.ref.o -c asmtest.S
203 objdump -D asmtest.ref.o > asmtest.ref203 objdump -D asmtest.ref.o > asmtest.ref
204 204
205asmtest: asmtest.ref205asmtest: asmtest.ref
tests/tests2/Makefile+8−4
@@ -94,8 +94,8 @@ TESTS = \ · 93 unmodified lines
94 72_long_long_constant.test \94 72_long_long_constant.test \
95 73_arm64.test \95 73_arm64.test \
96 74_nocode_wanted.test \96 74_nocode_wanted.test \
97 75_array_in_struct_init.test97 75_array_in_struct_init.test \
98 98 76_dollars_in_identifiers.test
99 99
100# 34_array_assignment.test -- array assignment is not in C standard100# 34_array_assignment.test -- array assignment is not in C standard
101 101
@@ -121,15 +121,19 @@ ARGS = · 19 unmodified lines
12131_args.test : ARGS = arg1 arg2 arg3 arg4 arg512131_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
12246_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' 46_grep.c12246_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' 46_grep.c
123 123
124# Some tests might need different flags
125FLAGS =
12676_dollars_in_identifiers.test : FLAGS = -fdollars-in-identifiers
127
124all test: $(filter-out $(SKIP),$(TESTS))128all test: $(filter-out $(SKIP),$(TESTS))
125 129
126%.test: %.c130%.test: %.c
127 @echo Test: $*...131 @echo Test: $*...
128 132
129 @$(TCC) -run $< $(ARGS) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output || true133 @$(TCC) -run $(FLAGS) $< $(ARGS) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output || true
130 @diff -Nbu $*.expect $*.output && rm -f $*.output134 @diff -Nbu $*.expect $*.output && rm -f $*.output
131 135
132 @($(TCC) $< -o $*.exe && ./$*.exe $(ARGS)) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output2 || true136 @($(TCC) $(FLAGS) $< -o $*.exe && ./$*.exe $(ARGS)) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output2 || true
133 @diff -Nbu $*.expect $*.output2 && rm -f $*.output2 $*.exe137 @diff -Nbu $*.expect $*.output2 && rm -f $*.output2 $*.exe
134 138
135clean:139clean:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t