[Bug c++/24449] Unable to declare friend main() from class template
--- Comment #2 from machata at post dot cz 2005-11-10 14:21 --- Created an attachment (id=10202) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10202&action=view) Patch against gcc/cp/decl.c, and a testcase This is rather straightforward solution for this PR. It allows parsing of the code like this: template< class > class { friend int ::main(); }; But unfortunately also this: class { template< class > friend int ::main(); }; I'm going to investigate the latter case now, but I don't yet have enough knowledge to propose a solution. IMHO this should fail, but maybe a warning is enough? The patch contains also a testcase. I tried to prepare the patch with all rules in mind, but I could have overlooked something. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24449
[Bug c++/24449] Unable to declare friend main() from class template
--- Comment #3 from machata at post dot cz 2005-11-16 15:25 --- Created an attachment (id=10251) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10251&action=view) Check if we are really declaring template ::main. I believe that this patch does the right thing. I've done bootstrap on i686-pc-linux-gnu, but I won't be able to run testsuite before friday. -- machata at post dot cz changed: What|Removed |Added Attachment #10202|0 |1 is obsolete|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24449
[Bug c++/24449] Unable to declare friend main() from class template
--- Comment #4 from machata at post dot cz 2005-11-18 14:27 --- > I believe that this patch does the right thing. I've done bootstrap on > i686-pc-linux-gnu, but I won't be able to run testsuite before friday. Which just passed on i686-pc-linux-gnu. -- machata at post dot cz changed: What|Removed |Added Status|NEW |WAITING http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24449
[Bug c++/24907] [3.4/4.0/4.1/4.2 Regression] "int x, ;" accepted
--- Comment #3 from machata at post dot cz 2005-11-21 15:31 --- Created an attachment (id=10311) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10311&action=view) Allow comma only on second and further passes of declarator processing loop. The patch addresses the problem by eating comma at the beginning of loop which processes declarators, and only eating it when it's second or later pass. Testcase is in patch, make check-g++ passed on i686-pc-linux-gnu. I'll do bootstrap and more thorough test tomorrow, and send the patch to gcc-patches then. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24907
[Bug c++/24907] [3.4/4.0/4.1/4.2 Regression] "int x, ;" accepted
--- Comment #4 from machata at post dot cz 2005-11-23 10:26 --- (In reply to comment #3) > Testcase is in patch, make check-g++ passed on i686-pc-linux-gnu. > I'll do bootstrap and more thorough test tomorrow, and send the patch to > gcc-patches then. Ok, done today. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24907
[Bug c++/21494] condensed nested namespaces
--- Comment #4 from machata at post dot cz 2005-12-09 12:54 --- Created an attachment (id=10444) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10444&action=view) Implementation of condensed nested namespaces definition, includes testcase. I sent an email with some comments to gcc-patches: http://gcc.gnu.org/ml/gcc-patches/2005-12/msg00666.html -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21494
[Bug c/53532] New: function call ignored when called with argument of incompatible, undefined structure
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53532 Bug #: 53532 Summary: function call ignored when called with argument of incompatible, undefined structure Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: mach...@post.cz The following code... struct aaa {}; extern int xxx(struct aaa e); int main() { xxx((struct bbb) {}); return 0; } ... compiles without warnings and the call to xxx is ignored: # gcc -Wall -Wextra -c foo.c # objdump -x foo.o [...] Disassembly of section .text: : 0:55 push %rbp 1:48 89 e5 mov%rsp,%rbp 4:b8 00 00 00 00 mov$0x0,%eax 9:5d pop%rbp a:c3 retq [...] The code above seems invalid, and I think that gcc should reject it. The definition of struct aaa is somehow important. When dropped, GCC realizes things are wrong, and complains abundantly. # LANG=C gcc -Wall -Wextra -x c /dev/stdin extern int xxx(struct aaa e); int main() { xxx((struct bbb) {}); return 0; } /dev/stdin:1:23: warning: 'struct aaa' declared inside parameter list [enabled by default] /dev/stdin:1:23: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] /dev/stdin: In function 'main': /dev/stdin:3:15: error: type of formal parameter 1 is incomplete It also complains about struct bbb being incomplete, which it didn't mind at all while aaa was there.
[Bug c++/24449] New: Unable to declare friend main() from class template
Compiler won't let me declare ::main() a friend from inside template class. It's not a problem in practice (who would want to do such thing?), however I don't see a reason for such a behavior. If I change the name to something else, it works correctly. gcc 3.3.2 and gcc 2.95.3 are also behaving this way. Preprocessed main.cc: # 1 "main.cc" # 1 "" # 1 "" # 1 "main.cc" template< class X > class Foo { private: int i; friend int main(); }; int main() { int i = Foo().i; } Command line: gcc-4.0 -v -save-temps -Wall main.cc Compiler output: Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc-4.0.2/configure --prefix=/opt/gcc-4.0/ --program-suffix=-4.0 --enable-threads Thread model: posix gcc version 4.0.2 /opt/gcc-4.0/bin/../libexec/gcc/i686-pc-linux-gnu/4.0.2/cc1plus -E -quiet -v -iprefix /opt/gcc-4.0/bin/../lib/gcc/i686-pc-linux-gnu/4.0.2/ -D_GNU_SOURCE main.cc -mtune=pentiumpro -Wall -fpch-preprocess -o main.ii ignoring nonexistent directory "/opt/gcc-4.0/bin/../lib/gcc/i686-pc-linux-gnu/4.0.2/../../../../i686-pc-linux-gnu/include" ignoring duplicate directory "/opt/gcc-4.0//lib/gcc/i686-pc-linux-gnu/4.0.2/../../../../include/c++/4.0.2" ignoring duplicate directory "/opt/gcc-4.0//lib/gcc/i686-pc-linux-gnu/4.0.2/../../../../include/c++/4.0.2/i686-pc-linux-gnu" ignoring duplicate directory "/opt/gcc-4.0//lib/gcc/i686-pc-linux-gnu/4.0.2/../../../../include/c++/4.0.2/backward" ignoring duplicate directory "/opt/gcc-4.0//lib/gcc/i686-pc-linux-gnu/4.0.2/include" ignoring nonexistent directory "/opt/gcc-4.0//lib/gcc/i686-pc-linux-gnu/4.0.2/../../../../i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /opt/gcc-4.0/bin/../lib/gcc/i686-pc-linux-gnu/4.0.2/../../../../include/c++/4.0.2 /opt/gcc-4.0/bin/../lib/gcc/i686-pc-linux-gnu/4.0.2/../../../../include/c++/4.0.2/i686-pc-linux-gnu /opt/gcc-4.0/bin/../lib/gcc/i686-pc-linux-gnu/4.0.2/../../../../include/c++/4.0.2/backward /opt/gcc-4.0/bin/../lib/gcc/i686-pc-linux-gnu/4.0.2/include /usr/local/include /opt/gcc-4.0//include /usr/include End of search list. /opt/gcc-4.0/bin/../libexec/gcc/i686-pc-linux-gnu/4.0.2/cc1plus -fpreprocessed main.ii -quiet -dumpbase main.cc -mtune=pentiumpro -auxbase main -Wall -version -o main.s GNU C++ version 4.0.2 (i686-pc-linux-gnu) compiled by GNU C version 4.0.2. GGC heuristics: --param ggc-min-expand=81 --param ggc-min-heapsize=96807 main.cc:6: error: cannot declare '::main' to be a template main.cc: In function 'int main()': main.cc:11: warning: unused variable 'i' -- Summary: Unable to declare friend main() from class template Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: minor Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: machata at post dot cz GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24449