public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12288] New: "expected function-definition" error compiling constructor
@ 2003-09-15 17:41 redi at gcc dot gnu dot org
  2003-09-15 19:45 ` [Bug c++/12288] unintelligible error message for constructor declaration with misspelled type bangerth at dealii dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: redi at gcc dot gnu dot org @ 2003-09-15 17:41 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12288

           Summary: "expected function-definition" error compiling
                    constructor
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: redi at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i386-unknown-freebsd4.8

The code below fails to compile with CVS g++ from 20030826 (I would have used a
more recent build but I can't bootstrap right now). This code compiles without
error on Comeau. The GCC config info, code and error follow:


$ g++3 -v
Reading specs from
/data/development/jw/gcc3/bin/../lib/gcc/i386-unknown-freebsd4.8/3.4/specs
Configured with: /home/jw/src/cvs/gcc/configure --prefix=/home/jw/gcc3/
--enable-languages=c,c++ --enable-concept-checks --enable-libstdcxx-pch :
(reconfigured) /home/jw/src/cvs/gcc/configure --prefix=/home/jw/gcc3/
--enable-languages=c,c++ --enable-concept-checks --enable-libstdcxx-pch :
(reconfigured)
Thread model: posix
gcc version 3.4 20030826 (experimental)
$ cat gcc_bug.cc
#include <map>

struct Foo {};

typedef std::multimap<unsigned short,Foo> FooMap;

class SameFoo
{
public:
    explicit SameFoo(const FooMap::data_type& lhs) : m_arg(lhs) {}
private:
    const Foo& m_arg;
};

$ g++3 gcc_bug.cc
gcc_bug.cc:10: error: ISO C++ forbids declaration of `SameFoo' with no type
gcc_bug.cc:10: error: only declarations of constructors can be `explicit'
gcc_bug.cc:10: error: expected function-definition


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/12288] unintelligible error message for constructor declaration with misspelled type
  2003-09-15 17:41 [Bug c++/12288] New: "expected function-definition" error compiling constructor redi at gcc dot gnu dot org
@ 2003-09-15 19:45 ` bangerth at dealii dot org
  2003-09-16 11:04 ` redi at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2003-09-15 19:45 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12288


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gdr at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2003-09-15 18:18:23
               date|                            |
            Summary|"expected function-         |unintelligible error message
                   |definition" error compiling |for constructor declaration
                   |constructor                 |with misspelled type


------- Additional Comments From bangerth at dealii dot org  2003-09-15 18:18 -------
If this code compiles with Comeau, then only because their standard
library is non-conforming: there is no type data_type in multimap. Thus,
the whole thing boils down to a snippet like this:
----------------------
class X {};

struct S {
    explicit S (const X::T&) {}
};
----------------------
for which we get this error message:
g/x> /home/bangerth/bin/gcc-3.4*/bin/c++ -c y.cc
y.cc:4: error: ISO C++ forbids declaration of `S' with no type
y.cc:4: error: only declarations of constructors can be `explicit'
y.cc:4: error: expected function-definition

That's totally unintelligible if one doesn't already know the cause
of the problem. Previous versions of gcc gave

g/x> /home/bangerth/bin/gcc-3.3*/bin/c++ -c y.cc
y.cc:4: error: parse error before `&' token
y.cc:4: error: missing ';' before right brace

which is not better either.
W.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/12288] unintelligible error message for constructor declaration with misspelled type
  2003-09-15 17:41 [Bug c++/12288] New: "expected function-definition" error compiling constructor redi at gcc dot gnu dot org
  2003-09-15 19:45 ` [Bug c++/12288] unintelligible error message for constructor declaration with misspelled type bangerth at dealii dot org
@ 2003-09-16 11:04 ` redi at gcc dot gnu dot org
  2003-12-29  0:31 ` pinskia at gcc dot gnu dot org
  2004-10-28  2:08 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu dot org @ 2003-09-16 11:04 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12288



------- Additional Comments From redi at gcc dot gnu dot org  2003-09-16 08:43 -------
Ah yes, I was a bit hasty filing this, should have checked a better reference. I
blame the unintelligible diagnostic for the fact I didn't spot that ;-)

When not in a constructor the same construct causes a different, but almost as
unintelligible message:

-----------------
class X {};

typedef X::T xt;
------------------

$ g++3 -c 12288-2.cc
map2.cc:3: error: expected init-declarator
map2.cc:3: error: expected `,' or `;'

This is a bit closer to the message in previous versions (which I don't think is
as bad as the current one) but still not much help for the average user trying
to work out what's wrong.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/12288] unintelligible error message for constructor declaration with misspelled type
  2003-09-15 17:41 [Bug c++/12288] New: "expected function-definition" error compiling constructor redi at gcc dot gnu dot org
  2003-09-15 19:45 ` [Bug c++/12288] unintelligible error message for constructor declaration with misspelled type bangerth at dealii dot org
  2003-09-16 11:04 ` redi at gcc dot gnu dot org
@ 2003-12-29  0:31 ` pinskia at gcc dot gnu dot org
  2004-10-28  2:08 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-29  0:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-28 23:11 -------
Better error message now on the mainline (not good enough though)
pr12288.2.cc:5: error: expected unqualified-id before '&' token
pr12288.2.cc:5: error: expected `,' or `...' before '&' token
pr12288.2.cc:5: error: ISO C++ forbids declaration of `parameter' with no type

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2003-12-06 08:28:01         |2003-12-28 23:11:16
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12288


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/12288] unintelligible error message for constructor declaration with misspelled type
  2003-09-15 17:41 [Bug c++/12288] New: "expected function-definition" error compiling constructor redi at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2003-12-29  0:31 ` pinskia at gcc dot gnu dot org
@ 2004-10-28  2:08 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-28  2:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-28 02:08 -------
The example in comment#2 is fixed on the mainline (the q part is a different problem, I will file it soon):
pr12288.cc:3: error: qT1 in class 'X' does not name a type

But other than that we still have problem.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2004-07-29 04:59:21         |2004-10-28 02:08:36
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12288


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/12288] unintelligible error message for constructor declaration with misspelled type
       [not found] <bug-12288-4@http.gcc.gnu.org/bugzilla/>
  2013-05-20 14:38 ` paolo.carlini at oracle dot com
  2013-05-20 17:15 ` paolo.carlini at oracle dot com
@ 2013-05-20 17:17 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2013-05-20 17:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12288

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Excellent, thanks!


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/12288] unintelligible error message for constructor declaration with misspelled type
       [not found] <bug-12288-4@http.gcc.gnu.org/bugzilla/>
  2013-05-20 14:38 ` paolo.carlini at oracle dot com
@ 2013-05-20 17:15 ` paolo.carlini at oracle dot com
  2013-05-20 17:17 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-20 17:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12288

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to work|                            |4.8.0, 4.9.0
         Resolution|---                         |FIXED

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Spurious error message avoided for 4.9.0.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/12288] unintelligible error message for constructor declaration with misspelled type
       [not found] <bug-12288-4@http.gcc.gnu.org/bugzilla/>
@ 2013-05-20 14:38 ` paolo.carlini at oracle dot com
  2013-05-20 17:15 ` paolo.carlini at oracle dot com
  2013-05-20 17:17 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-20 14:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12288

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|gcc-bugs at gcc dot gnu.org        |
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Given that Comment#2 is now fine, I think that the only remaining issue here is
that for Comment#1 we also give (additionally to the sane error message)

12288_1.C:4:27: error: ISO C++ forbids declaration of ‘parameter’ with no type
[-fpermissive]
     explicit S (const X::T&) {}

Should be easy to avoid, because there is already a mechanism for that in
grokdeclarator (type_was_error_mark_node)
>From gcc-bugs-return-422650-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon May 20 14:40:18 2013
Return-Path: <gcc-bugs-return-422650-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 9125 invoked by alias); 20 May 2013 14:40:18 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 9059 invoked by uid 48); 20 May 2013 14:40:09 -0000
From: "olegendo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/57339] New: [SH] Wrong ISR FPU register save/restore
Date: Mon, 20 May 2013 14:40:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.8.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: olegendo at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc cf_gcctarget
Message-ID: <bug-57339-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-05/txt/msg01323.txt.bz2
Content-length: 6051

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW339

            Bug ID: 57339
           Summary: [SH] Wrong ISR FPU register save/restore
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olegendo at gcc dot gnu.org
                CC: kkojima at gcc dot gnu.org
            Target: sh*-*-*

The following test case

extern void foo (void);

#pragma interrupt
#pragma nosave_low_regs
void
isr (void)
{
  foo ();
}

with -O2 -m4 -ml compiles to:

isr:
        fmov.s    fr0,@-r15
        fmov.s    fr1,@-r15
        fmov.s    fr2,@-r15
        fmov.s    fr3,@-r15
        fmov.s    fr4,@-r15
        fmov.s    fr5,@-r15
        fmov.s    fr6,@-r15
        fmov.s    fr7,@-r15
        fmov.s    fr8,@-r15
        fmov.s    fr9,@-r15
        fmov.s    fr10,@-r15
        fmov.s    fr11,@-r15
        sts.l    mach,@-r15
        sts.l    macl,@-r15
        sts.l    fpul,@-r15
        sts.l    fpscr,@-r15
        sts.l    pr,@-r15
        mov.l    .L3,r1
        lds.l    @r1+,fpscr      ! 57    fpu_switch/2    [length = 2]
        mov.l    .L4,r1
        jsr    @r1
        nop
    lds.l    @r15+,pr
        lds.l    @r15+,fpscr     ! 38    fpu_switch/2    [length = 2]
        lds.l    @r15+,fpul
        lds.l    @r15+,macl
        lds.l    @r15+,mach
        fmov.s    @r15+,fr11
        fmov.s    @r15+,fr10
        fmov.s    @r15+,fr9
        fmov.s    @r15+,fr8
        fmov.s    @r15+,fr7
        fmov.s    @r15+,fr6
        fmov.s    @r15+,fr5
        fmov.s    @r15+,fr4
        fmov.s    @r15+,fr3
        fmov.s    @r15+,fr2
        fmov.s    @r15+,fr1
        rte
        fmov.s    @r15+,fr0


The FPU register save/restore insns in the ISR epilogue and prologue are wrong
since they refer to the FPSCR setting at the point of the interruption, but the
FPSCR setting is not known at ISR function entry.

For example, if the interrupted context's FPSCR has FPSCR.SZ = 1 (64 bit fmov)
the code above will not work properly and is most likely going to result in an
address error.

A better way would be to do something like...

isr:
                                ! FPSCR.SZ, FPSCR.PR, FPSCR.FR of interrupted
                                ! context is not known.
        mov     r15,r0
        or      #7,r0
        xor     #7,r0
        mov     r0,r15          ! r15 = 64 bit aligned stack ptr
        mova   .Lvariables,r0

        sts.l   fpscr,@-r15     ! push FPSCR of interrupted context
        add     #-4,r15         ! keep r15 64 bit aligned

        lds.l   @r0+,fpscr      ! FPSCR.SZ = 1, FPSCR.PR = 0, FPSCR.FR = 0
                                ! if FPSCR.FR was 1 we have now switched the
                                ! FP reg banks and will be saving XF regs.
                                ! that's OK if the ISR code does not switch
                                ! FPSCR.FR.
        fmov.d  dr0,@-r15
        fmov.d  dr2,@-r15
        fmov.d  dr4,@-r15
        fmov.d  dr6,@-r15
        fmov.d  dr8,@-r15
        fmov.d  dr10,@-r15

        sts.l    fpscr,@-r15     ! push FPSCR setting for restoring FP regs
                                ! before ISR returns.

        lds.l   @r0+,fpscr      ! default FPSCR setting for ISRs
                                ! FPSCR.PR must be kept = 0
        sts.l   fpul,@-r15
        sts.l   mach,@-r15
        sts.l   macl,@-r15
        sts.l   pr,@-r15

        ...
        < ISR code >
        ...

        lds.l   @r15+,pr
        lds.l   @r15+,macl
        lds.l   @r15+,mach
        lds.l   @r15+,fpul
        lds.l   @r15+,fpscr     ! pop FPSCR setting for FP reg restore
                                ! FPSCR.SZ = 1, FPSCR.PR = 0, FPSCR.FR = 0
        fmov.d  @r15+,dr10
        fmov.d  @r15+,dr8
        fmov.d  @r15+,dr6
        fmov.d  @r15+,dr4
        fmov.d  @r15+,dr2
        fmov.d  @r15+,dr0
        add     #4,r15
        rte
        lds.l   @r15+,fpscr     ! restore FPSCR of interrupted context
                                ! this potentially switches FPSCR.FR

        .align 2
.Lvariables:
        .long   1 << 20         ! FPSCR.SZ = 1, FPSCR.PR = 0, FPSCR.FR = 0
        .long   <default FPSCR value for ISR>  ! FPSCR.FR must be = 0


Some remarks:

---------
This insn:
        add     #-4,r15         ! keep r15 64 bit aligned

can be replaced with one of the push insns that follow the fmov.d pushes.

---------
The above won't work for SH2E and SH3E.  Those need their own sequence.

---------
The stack alignment can be omitted if it has been aligned already somehow else,
e.g. by specifying 'sp_switch' function attribute.  On SH3* and SH4* the ISR
vectors are grouped, so there is always some common code that is executed
before it invokes the actual ISR.  That code might as well align the stack.

---------
An alternative stack alignment sequence could be:

        mova   .Lvariables,r0
        mov.l   @r0+,r1
        and     r1,r15

        ...

        .align 2
.Lvariables:
        .long   0xFFFFFFF8
        .long   1 << 20         ! FPSCR.SZ = 1, FPSCR.PR = 0, FPSCR.FR = 0
        .long   <default FPSCR value for ISR>  ! FPSCR.FR must be = 0

However, this is probably a bit slower.


---------
On SH4, if the ISR code path changes the FPSCR.FR setting, the FP regs will get
scrambled.  ISR code must not modify the FPSCR.FR setting.  This restriction
could be removed by also pushing/popping XF regs (additional 8 push + 8 pop
insns).

---------
On SH2A and SH2E R0 is not a banked register and must be pushed before dealing
with the FP regs.


I'm not sure how this should be implemented in the compiler, since currently
there are some issues with FP mode switching and fmov.d support, which probably
would need to be fixed first.
One idea for now would be to emit fixed ISR prologue / epilogue asm blocks that
deal with the FP regs, if FP regs need to be saved/restored for an ISR.

Kaz, do you happen to have any suggestions/advices/opinions?


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-05-20 17:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-15 17:41 [Bug c++/12288] New: "expected function-definition" error compiling constructor redi at gcc dot gnu dot org
2003-09-15 19:45 ` [Bug c++/12288] unintelligible error message for constructor declaration with misspelled type bangerth at dealii dot org
2003-09-16 11:04 ` redi at gcc dot gnu dot org
2003-12-29  0:31 ` pinskia at gcc dot gnu dot org
2004-10-28  2:08 ` pinskia at gcc dot gnu dot org
     [not found] <bug-12288-4@http.gcc.gnu.org/bugzilla/>
2013-05-20 14:38 ` paolo.carlini at oracle dot com
2013-05-20 17:15 ` paolo.carlini at oracle dot com
2013-05-20 17:17 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).