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
747747
748748 ch = file->buf_ptr[0];
749749 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;
751751 if (do_preprocess)
752752 parse_flags |= PARSE_FLAG_PREPROCESS;
753753 next();
tccpp.c+11−7
@@ -2313,9 +2313,11 @@ maybe_newline: · 2312 unmodified lines
23132313 }
23142314 break;
23152315
2316− /* treat $ as allowed char in indentifier */
2317− case '$': if (!tcc_state->dollars_in_identifiers) goto parse_simple;
2318−
2316+ /* dollar is allowed to start identifiers when not parsing asm */
2317+ case '$':
2318+ if (!tcc_state->dollars_in_identifiers
2319+ || (parse_flags & PARSE_FLAG_ASM_FILE)) goto parse_simple;
2320+
23192321 case 'a': case 'b': case 'c': case 'd':
23202322 case 'e': case 'f': case 'g': case 'h':
23212323 case 'i': case 'j': case 'k': case 'l':
@@ -2338,7 +2340,8 @@ maybe_newline: · 16 unmodified lines
23382340 p++;
23392341 for(;;) {
23402342 c = *p;
2341− if (!isidnum_table[c-CH_EOF])
2343+ if (!isidnum_table[c-CH_EOF]
2344+ && (tcc_state->dollars_in_identifiers ? (c != '$') : 1))
23422345 break;
23432346 h = TOK_HASH_FUNC(h, c);
23442347 p++;
@@ -2373,7 +2376,8 @@ maybe_newline: · 28 unmodified lines
23732376 p--;
23742377 PEEKC(c, p);
23752378 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)) {
23772381 cstr_ccat(&tokcstr, c);
23782382 PEEKC(c, p);
23792383 }
@@ -3202,9 +3206,9 @@ ST_FUNC void preprocess_new(void) · 822 unmodified lines
32023206 const char *p, *r;
32033207
32043208 /* init isid table */
3209+
32053210 for(i=CH_EOF;i<256;i++)
3206− isidnum_table[i-CH_EOF] = (isid(i) || isnum(i) ||
3207− (tcc_state->dollars_in_identifiers ? i == '$' : 0));
3211+ isidnum_table[i-CH_EOF] = isid(i) || isnum(i);
32083212
32093213 /* add all tokens */
32103214 if (table_ident) {
tests/Makefile+1−1
@@ -199,7 +199,7 @@ ex%: $(top_srcdir)/examples/ex%.c · 198 unmodified lines
199199
200200 # tiny assembler testing
201201 asmtest.ref: asmtest.S
202− $(CC) -Wa,-W -o asmtest.ref.o -c asmtest.S
202+ $(CC) -m32 -Wa,-W -o asmtest.ref.o -c asmtest.S
203203 objdump -D asmtest.ref.o > asmtest.ref
204204
205205 asmtest: asmtest.ref
tests/tests2/Makefile+8−4
@@ -94,8 +94,8 @@ TESTS = \ · 93 unmodified lines
9494 72_long_long_constant.test \
9595 73_arm64.test \
9696 74_nocode_wanted.test \
97− 75_array_in_struct_init.test
98−
97+ 75_array_in_struct_init.test \
98+ 76_dollars_in_identifiers.test
9999
100100 # 34_array_assignment.test -- array assignment is not in C standard
101101
@@ -121,15 +121,19 @@ ARGS = · 19 unmodified lines
121121 31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
122122 46_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' 46_grep.c
123123
124+# Some tests might need different flags
125+FLAGS =
126+76_dollars_in_identifiers.test : FLAGS = -fdollars-in-identifiers
127+
124128 all test: $(filter-out $(SKIP),$(TESTS))
125129
126130 %.test: %.c
127131 @echo Test: $*...
128132
129− @$(TCC) -run $< $(ARGS) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output || true
133+ @$(TCC) -run $(FLAGS) $< $(ARGS) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output || true
130134 @diff -Nbu $*.expect $*.output && rm -f $*.output
131135
132− @($(TCC) $< -o $*.exe && ./$*.exe $(ARGS)) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output2 || true
136+ @($(TCC) $(FLAGS) $< -o $*.exe && ./$*.exe $(ARGS)) 2>&1 | grep -v 'warning: soft float ABI currently not supported: default to softfp' >$*.output2 || true
133137 @diff -Nbu $*.expect $*.output2 && rm -f $*.output2 $*.exe
134138
135139 clean:

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