Commit Graph

2073 Commits

Author SHA1 Message Date
f40b82295e __getmainargs compatibility checking success 2014-11-22 19:00:49 -03:00
1e07ea71d3 win32: fix implicit function warning
This includes windows.h to fix a warning about
an implicit function usage of ExitProcess().
2014-11-03 16:17:15 -06:00
26b26f355f Filter-out warning about softfloat in tests2 2014-10-17 16:37:54 -04:00
9d7fb33360 tccgen: use lvalue as result from bitfield assignment
test case:

    #include <stdio.h>
    int main(int argc, char **argv)
    {
        struct _s { unsigned a:9, b:5, c:7; } _s, *s = &_s;
        int n = 250;
        s->a = s->b = s->c = n + 4;
        printf("--> %d / %d / %d\n", s->a, s->b, s->c);
        return 0;
    }

before:
--> 254 / 30 / 126
now:
--> 30 / 30 / 126
2014-09-23 12:30:08 +02:00
87d879aa7b Accept CPPFLAGS from the environment
Don't override CPPFLAGS so that it can be passed through the
environment.

(This is a patch Thomas Preud'homme wrote for Debian in February 2013.)
2014-09-07 12:07:04 -04:00
63376d7712 tccelf: layout_sections: add missing param strsec
This fixes compilation on (k)FreeBSD.
2014-09-07 12:04:53 -04:00
b84cdf6214 Clear CFLAGS & LDFLAGS in tests
Clear CFLAGS and LDFLAGS to build the tests, in case the main Makefile
passes some flags that aren't handled by tcc (we are not compiling tcc
here, we are using tcc to compile the tests).
2014-09-07 11:15:31 -04:00
178275dc0c Don't build libtcc1 with -fstack-protector-strong
Prevent libtcc1.a to be compiled with -fstack-protector-strong, so that
linking with tcc doesn't fail because symbol '__stack_chk_fail_local' is
not present in libtcc1.a. This is useful only if the CFLAGS passed from
the main Makefile contain this flag.
2014-09-07 10:56:03 -04:00
14745bdeb7 tccgen: nocode_wanted: do not output constants
This for example suppresses string constants such as with

    int main()
    {
        return sizeof "foo";
    }

Actually, setting

    nocode_wanted = 1;

in libtcc.c for the initial global level seemed wrong, since
obviously "nocode_wanted" means code as any side effects, also
such as string constants.

This reverts a part of 2de1b2d14c
(documented as "Some in-between fixes" in Changelog)
2014-08-01 10:59:38 +02:00
12f43953ed win64: fix resource file support 2014-08-01 10:51:28 +02:00
73a7dd79af Removed the error message and minor changes. 2014-07-17 01:08:47 -04:00
7c474b4da3 __getmainargs return int, not void, and on error, it return -1 and let argv untouched, also argc. Added a if checking the result of it. 2014-07-16 22:22:05 -04:00
f2ee6b1759 Fix mistake. Change jb by jbe. tiny c round (INT_MAX = 0x7FFFFFFF) to a DWORD boundary and it becomes 0x80000000. Jle treats as -214783648, but Jbe treats as 214783648. Thanks to Jason Hood for explain me this. 2014-07-10 20:41:51 -04:00
8257829623 Fix problem using alloca function, executable crashed even with a exception handler function, when try to allocate INT_MAX. Patch provided by Jason Hood in private e-mail, when I ask to him for help. He say: Feel free to pass it on to the mailing list. 2014-07-10 00:37:20 -04:00
89000c18dc Rename:
68_macro_concat.c -> 68_macro_param_list_err_1.c
69_macro_concat.c -> 69_macro_param_list_err_2.c
and Remove spaces
2014-07-01 23:54:49 +08:00
b31e80a43a Specify license of lib/armeabi.c 2014-07-01 22:01:49 +08:00
a3fc543459 bug:
----------------------------------------------------------------------
#define hexCh(c (c >= 10 ? 'a' + c - 10 : '0' + c)
  hexCh(c);

out:
jiang@jiang:~/test$ ./tcc -E c4.c
# 1 "c4.c"

(c >= 10 ? 'a' + c - 10 : '0' + c);
---------------------------------------------------------------

#define hexCh(c/3) (c >= 10 ? 'a' + c - 10 : '0' + c)
hexCh(c);

out:
jiang@jiang:~/test$ ./tcc -E c4.c
# 1 "c4.c"

/3) (c >= 10 ? 'a' + c - 10 : '0' + c);
jiang@jiang:~/test$

after patch:

# 1 "c4.c"
c4.c:1: error: may not appear in macro parameter list: "("
jiang@jiang:~/test$

jiang@jiang:~/test$ ./tcc -E c4.c
# 1 "c4.c"
c4.c:1: error: may not appear in macro parameter list: "/"
jiang@jiang:~/test$
2014-06-29 20:35:57 +08:00
799512388c Revert the many un-reviewed commits starting from early April
Starting early April, a number of commits were pushed to the mob branch
that did not reflect the interest, wishes, or code quality of the tcc
community. This commit reverts those commits, while cherry-picking
grishka's commit for win64 linkage issues.
2014-06-24 22:42:57 -04:00
6e0a658e96 win64: try to fix linkage
- revert to R_X86_64_PC32 for near calls on PE
- revert to s1->section_align set to zero by default

Untested. Compared to release_0_9_26 the pe-image looks back to
normal.  There are some differences in dissassembly (r10/r11 usage)
but maybe that's ok.
2014-06-24 22:09:12 -04:00
f26fdaefd8 revert vstore() 2014-06-23 01:08:54 +08:00
1fa0fe2786 Revert "Win: Enable use "*.def + *.c" files as library instead of *.a by "-l" option"
This reverts commit 7a3f6d4941.
2014-06-20 13:26:29 +01:00
7a3f6d4941 Win: Enable use "*.def + *.c" files as library instead of *.a by "-l" option
example: "-lshell32" will try "shell32.def + shell32.c"

Add lib type "%s/%s.c" for tcc_add_library() ('-l' option parse)

So tcc can use all files as scripts.
2014-06-16 16:00:46 +08:00
d316836008 Let init_putz one-time generation.
At the same time, increase the GCC style warning
---------------------------------------------------------------------------
int main()
{
	int a[10] = {[5]=5};
	return 0;
}

Disassembly of section .text:

0000000000000000 <main>:
   0:	55                   	push   %rbp
   1:	48 89 e5             	mov    %rsp,%rbp
   4:	48 81 ec 30 00 00 00 	sub    $0x30,%rsp
   b:	b8 05 00 00 00       	mov    $0x5,%eax
  10:	89 45 ec             	mov    %eax,-0x14(%rbp)
  13:	48 b8 14 00 00 00 00 	movabs $0x14,%rax
  1a:	00 00 00
  1d:	49 89 c2             	mov    %rax,%r10
  20:	b8 00 00 00 00       	mov    $0x0,%eax
  25:	48 89 c6             	mov    %rax,%rsi
  28:	48 8d 45 d8          	lea    -0x28(%rbp),%rax
  2c:	48 89 c7             	mov    %rax,%rdi
  2f:	4c 89 d2             	mov    %r10,%rdx
  32:	b8 00 00 00 00       	mov    $0x0,%eax
  37:	e8 fc ff ff ff       	callq  38 <main+0x38>
  3c:	48 b8 10 00 00 00 00 	movabs $0x10,%rax
  43:	00 00 00
  46:	49 89 c2             	mov    %rax,%r10
  49:	b8 00 00 00 00       	mov    $0x0,%eax
  4e:	48 89 c6             	mov    %rax,%rsi
  51:	48 8d 45 f0          	lea    -0x10(%rbp),%rax
  55:	48 89 c7             	mov    %rax,%rdi
  58:	4c 89 d2             	mov    %r10,%rdx
  5b:	b8 00 00 00 00       	mov    $0x0,%eax
  60:	e8 fc ff ff ff       	callq  61 <main+0x61>
  65:	b8 00 00 00 00       	mov    $0x0,%eax
  6a:	e9 00 00 00 00       	jmpq   6f <main+0x6f>
  6f:	c9                   	leaveq
  70:	c3                   	retq

After the patch

0000000000000000 <main>:
   0:	55                   	push   %rbp
   1:	48 89 e5             	mov    %rsp,%rbp
   4:	48 81 ec 30 00 00 00 	sub    $0x30,%rsp
   b:	48 b8 28 00 00 00 00 	movabs $0x28,%rax
  12:	00 00 00
  15:	49 89 c2             	mov    %rax,%r10
  18:	b8 00 00 00 00       	mov    $0x0,%eax
  1d:	48 89 c6             	mov    %rax,%rsi
  20:	48 8d 45 d8          	lea    -0x28(%rbp),%rax
  24:	48 89 c7             	mov    %rax,%rdi
  27:	4c 89 d2             	mov    %r10,%rdx
  2a:	b8 00 00 00 00       	mov    $0x0,%eax
  2f:	e8 fc ff ff ff       	callq  30 <main+0x30>
  34:	b8 05 00 00 00       	mov    $0x5,%eax
  39:	89 45 ec             	mov    %eax,-0x14(%rbp)
  3c:	b8 00 00 00 00       	mov    $0x0,%eax
  41:	e9 00 00 00 00       	jmpq   46 <main+0x46>
  46:	c9                   	leaveq
  47:	c3                   	retq
 -----------------------------------------------------------------------------------
"c5.c"
int main()
{
  // union st
   struct st
   {
    char c;
    short s;
   // char cc[];
    };
   // union st
  struct st
    ss = { 1, 2, 3};
   // int a = ss;
    char cb[1] = {1,2,3};
    return 0;
}

c5.c:12: warning: excess elements in struct initializer
c5.c:14: warning: excess elements in array initializer
c5.c:14: warning: excess elements in array initializer
2014-05-28 22:09:49 +08:00
89134dd7b0 Considering the effect of CH_EOF on line_num 2014-05-28 21:51:50 +08:00
698b16960a Modify the 66_macro_concat_end.expect
I was busy recently, forget test. Thank Austin
2014-05-28 10:38:26 +08:00
bcf60562e0 The number of rows to display warning is wrong
For example:
#define TOK_ASM_weak TOK_WEAK1
#define TOK_ASM_weak TOK_WEAK
Output:
C8.c:3: warning: TOK_ASM_weak redefined
2014-05-23 15:46:08 +08:00
9c78da8a32 forget Delete __va_ld_reg 2014-05-21 12:50:12 +08:00
3d608d4b54 Delete a = (a > = 0)? A: -a; \ 2014-05-20 15:23:55 +08:00
0199123dd7 clean '\t' 2014-05-20 15:18:59 +08:00
f8b4f59f8b In the local use of local stack, use a global stack in the global time 2014-05-20 14:59:37 +08:00
e5e7f488e2 int main()
{
	struct st {
		int aa:16;
		int bb:16;
	} s;
	s.aa = 1;
	s.bb = 2;
	return 0;
}
objdump -d:
elf64-x86-64
Disassembly of section .text:

0000000000000000 <main>:
   0:	55                   	push   %rbp
   1:	48 89 e5             	mov    %rsp,%rbp
   4:	48 81 ec 10 00 00 00 	sub    $0x10,%rsp
   b:	b8 01 00 00 00       	mov    $0x1,%eax
  10:	48 89 c1             	mov    %rax,%rcx
  13:	81 e1 ff ff 00 00    	and    $0xffff,%ecx
  19:	8b 55 fc             	mov    -0x4(%rbp),%edx
  1c:	81 e2 00 00 ff ff    	and    $0xffff0000,%edx
  22:	09 d1                	or     %edx,%ecx
  24:	89 4d fc             	mov    %ecx,-0x4(%rbp)
  27:	b8 02 00 00 00       	mov    $0x2,%eax
  2c:	48 89 c1             	mov    %rax,%rcx
  2f:	81 e1 ff ff 00 00    	and    $0xffff,%ecx
  35:	c1 e1 10             	shl    $0x10,%ecx
  38:	8b 55 fc             	mov    -0x4(%rbp),%edx
  3b:	81 e2 ff ff 00 00    	and    $0xffff,%edx
  41:	09 d1                	or     %edx,%ecx
  43:	89 4d fc             	mov    %ecx,-0x4(%rbp)
  46:	b8 00 00 00 00       	mov    $0x0,%eax
  4b:	e9 00 00 00 00       	jmpq   50 <main+0x50>
  50:	c9                   	leaveq
  51:	c3                   	retq

After the patch

Disassembly of section .text:

0000000000000000 <main>:
   0:	55                   	push   %rbp
   1:	48 89 e5             	mov    %rsp,%rbp
   4:	48 81 ec 10 00 00 00 	sub    $0x10,%rsp
   b:	8b 45 fc             	mov    -0x4(%rbp),%eax
   e:	81 e0 00 00 ff ff    	and    $0xffff0000,%eax
  14:	83 c8 01             	or     $0x1,%eax
  17:	89 45 fc             	mov    %eax,-0x4(%rbp)
  1a:	8b 45 fc             	mov    -0x4(%rbp),%eax
  1d:	81 e0 ff ff 00 00    	and    $0xffff,%eax
  23:	81 c8 00 00 02 00    	or     $0x20000,%eax
  29:	89 45 fc             	mov    %eax,-0x4(%rbp)
  2c:	b8 00 00 00 00       	mov    $0x0,%eax
  31:	e9 00 00 00 00       	jmpq   36 <main+0x36>
  36:	c9                   	leaveq
  37:	c3                   	retq
2014-05-17 12:32:00 +08:00
a94ed43094 Improved '\ n' output effect (# pragma pack (push, 8), # pragma pack (pop)) 2014-05-17 12:06:18 +08:00
196c999515 1 macro_push and macro_pop work I made a mistake, no matter the definition does not define can be macro_push.
And the modified tcctest.c test
2, pack: in the compiler under the mode of s1->ppfp, I have no clear ideas1->ppfp
Some advice thank you Roy to me.This patch, I hope I can pass the Roy test
2014-05-17 00:55:02 +08:00
276553c6b2 add push_macro test again 2014-05-16 15:44:51 +08:00
52891b6ff6 fix push_macro, asked Tom to help me testfix push_macro 2014-05-16 12:15:00 +08:00
5a514107c4 When tcc.exe update, abitest-tcc.exe not updated. For security, you must first clean up 2014-05-15 12:09:43 +08:00
5d0785d0e1 Add warning 4
num en{a1,a2,a3};
enum en ee;
ee = 0xffffffffff;
    char a;
    a = 0xffff;
2014-05-14 21:01:00 +08:00
fcb3772a34 Add warning 3
struct st {int a;} ss;
int b;
b = ss;
2014-05-14 20:44:53 +08:00
07614b5e22 clean '\t' 2014-05-14 12:45:58 +08:00
c6345b5a8a restore 2dd8587c2f32d17a2cd0443a60a614a3fa9bbe29 2014-05-13 22:05:38 +08:00
72f466c24c Modify tcc_error ("invalid type",); 2014-05-13 22:00:42 +08:00
8d5e0cf083 fix 14d0aa450f 2014-05-13 21:57:35 +08:00
03687729ec Add warning 2
For example:
struct A {
int b: 16;
int c: 16
};
sizeof (struct A);
2014-05-09 22:41:45 +08:00
14d0aa450f Add warning
For example:
struct A {
int b [];
};
2014-05-09 22:35:19 +08:00
0f51ccd4e4 win64: try to fix linkage
- revert to R_X86_64_PC32 for near calls on PE
- revert to s1->section_align set to zero by default

Untested. Compared to release_0_9_26 the pe-image looks back to
normal.  There are some differences in dissassembly (r10/r11 usage)
but maybe that's ok.
2014-05-08 17:32:29 +02:00
ad787abea6 fix bug if (seen_reg_num + reg_count <= 8) 2014-05-08 15:39:50 +08:00
899d26605c Revert "update static void parse_number()"
because:
- Constructing fp numbers isn't quite trivial
- 3 additional calls to strchr per number is noticeable slow

Also: exclude abitest.c:ret_longdouble_test2 on _WIN32
for mixed gcc/tcc scenario

test case:
- make -k test (on win32):
  -2.120000 0.500000 23000000000.000000
  +2.120000 0.500000 22999999999.999996
  ...
  ret_longdouble_test2... failure

This reverts 857f7dbfa6
and deaee6c249
2014-05-06 18:24:41 +02:00
5e56fb635a Return to: e20c1eb99e
1: The new patch for the other machines still have the problem.
2: libcrt Rename (what if gcc had libcrt as well)
3: parse_number exact problem
4: VT_VLS is to allow tcc
     Compile the following
     int b = 9;
     struct st {
     int a;
     int b [b]
     };
     struct st st1;
     st1.b [8] = 9;
     printf ("% d \ n", st1.b [8]);

     tcc a problem. Due to problems in front, and now can not be improved
5: they commit much, bug difficult to lock, you can not let other people help develop.
6: ('\ t') too

Thanks to Michael and Ray
Their criticism I have benefited!
2014-05-04 13:18:31 +08:00
089dea355a tcc on i386 are still having problems at work.Thank Roy report again. Struck on several variables can be connected to commit in the register. I am worried whether tcc can run the os. Since my machine is ubuntu 64 bits I can test my machine. 2014-05-03 23:51:09 +08:00
a0d45c1bcd forget commit tccge.c for i386 2014-05-03 00:39:40 +08:00