User account creation filtered due to spam.

Bug 12344 - [3.3/3.4 Regression] stdcall attribute ignored if function returns a pointer (bug+fix)
Summary: [3.3/3.4 Regression] stdcall attribute ignored if function returns a pointer ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3
: P2 normal
Target Milestone: 3.3.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 8656 12236
  Show dependency treegraph
 
Reported: 2003-09-19 19:57 UTC by zap
Modified: 2004-01-17 04:22 UTC (History)
1 user (show)

See Also:
Host: i386-redhat-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-09-28 21:04:59


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zap 2003-09-19 19:57:23 UTC
Actually the bug is actual for all platforms and all attributes (not just linux and 
stdcall). Also it is not 3.3-specific, I've tested many versions up to 3.3 and all have 
the same bug present. I've encountered it while woring on the OS/2 port of gcc 
which has its own specific attributes.

Here's a sample (test.cpp):

void __attribute__((stdcall)) test1 (int) {}
void *__attribute__((stdcall)) test2 (int) {}

Compiled .s file (gcc -S -s -fno-exceptions -fomit-frame-pointer -O test.cpp, 
optimization options used only for cleaner assembler code):

[... skipped ...]
_Z5test1i:
	ret	$4
[... skipped ...]
_Z5test2i:
	ret

The same file compiled as a plain C file works fine.

I've tracked the bug down to gcc/cp/decl.c. Here is the patch that fixes the bug:
--- decl.c	16 Apr 2003 10:10:35 -0000	1.1
+++ decl.c	9 Sep 2003 18:37:40 -0000	1.3
@@ -13613,7 +13613,7 @@
     }
   else
     {
-      decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, NULL);
+      decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs);
       /* If the declarator is not suitable for a function definition,
 	 cause a syntax error.  */
       if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL)
Comment 1 Danny Smith 2003-09-19 22:43:18 UTC
Confirmed on trunk with

Reading specs from D:/MINGW/BIN/../lib/gcc/mingw32/3.4/specs
Configured with: '../gcc/configure' '--with-gcc '--with-gnu-ld '--with-gnu-as '-
-host=mingw32 '--build=mingw32 '--target=mingw32 '--prefix=/mingw '--enable-
threads '--disable-nls '--enable-languages=c,c++,ada,f77,objc '--disable-win32-
registry '--disable-shared '--enable-sjlj-exceptions '--disable-libstdcxx-pch  
Thread model: win32
gcc version 3.4 20030918 (experimental)


This bug is related to PR c++/8656, and the patch proposed here also fixes that 
bug.

Danny
Comment 2 Andrew Pinski 2003-09-28 21:04:59 UTC
Danny already confirmed this.
Comment 3 CVS Commits 2003-10-07 05:57:13 UTC
Subject: Bug 12344

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	mmitchel@gcc.gnu.org	2003-10-07 05:57:07

Modified files:
	gcc/cp         : ChangeLog call.c decl.c init.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/ext: attrib8.C 
	gcc/testsuite/g++.dg/init: new9.C 

Log message:
	PR c++/10174
	* call.c (initialize_reference): Tweak error message.
	
	PR c++/12337
	* init.c (build_new_1): Make sure that the expression returned is
	not an lvalue.
	
	PR c++/12344, c++/12236, c++/8656
	* decl.c (start_function): Do not ignore attributes embedded in a
	function declarator.
	
	PR c++/12337
	* g++.dg/init/new9.C: New test.
	
	PR c++/12334, c++/12236, c++/8656
	* g++.dg/ext/attrib8.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.212&r2=1.3076.2.213
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.341.2.33&r2=1.341.2.34
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.62&r2=1.965.2.63
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.299.2.9&r2=1.299.2.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.299&r2=1.2261.2.300
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib8.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/new9.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1

Comment 4 CVS Commits 2003-10-07 07:07:14 UTC
Subject: Bug 12344

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-10-07 07:07:08

Modified files:
	gcc/cp         : ChangeLog call.c cxx-pretty-print.c 
	                 cxx-pretty-print.h decl.c init.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/g++.dg/other: error4.C 
	gcc/testsuite/g++.dg/template: ptrmem4.C 
Added files:
	gcc/testsuite/g++.dg/ext: attrib8.C 
	gcc/testsuite/g++.dg/init: new9.C 

Log message:
	PR c++/10147
	* call.c (initialize_reference): Tweak error message.
	
	PR c++/12337
	* init.c (build_new_1): Make sure that the expression returned is
	not an lvalue.
	
	PR c++/12344, c++/12236, c++/8656
	* decl.c (start_function): Do not ignore attributes embedded in a
	function declarator.
	
	PR c++/12337
	* g++.dg/init/new9.C: New test.
	
	PR c++/12334, c++/12236, c++/8656
	* g++.dg/ext/attrib8.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3717&r2=1.3718
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.437&r2=1.438
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cxx-pretty-print.c.diff?cvsroot=gcc&r1=1.7&r2=1.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cxx-pretty-print.h.diff?cvsroot=gcc&r1=1.4&r2=1.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1139&r2=1.1140
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.344&r2=1.345
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3099&r2=1.3100
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib8.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/new9.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/other/error4.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem4.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 5 Mark Mitchell 2003-10-07 07:09:51 UTC
Fixed in GCC 3.3.2 and GCC 3.4.