public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/114011] New: Feature request: __goto__
@ 2024-02-20 12:43 pskocik at gmail dot com
  2024-02-20 23:40 ` [Bug c/114011] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pskocik at gmail dot com @ 2024-02-20 12:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114011

            Bug ID: 114011
           Summary: Feature request: __goto__
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pskocik at gmail dot com
  Target Milestone: ---

Gcc has __volatile__.
I can only assume the rationale for it is so that inline asm macros can
do __asm __volatile__ and not have to worry about user-redefines of the
volatile keyword (which while not quite approved by the standard, is sometimes
practically useful).
While the __asm syntax also allows the goto keyword, there's currently no
__goto__ counterpart to __volatile__, which could similarly protect against
goto redefines.
Adding it is trivial and consistent with the already existing
volatile/__volatile__ pair. Would you consider it?

(
Why am I redefining goto? I'm basically doing it within the confines of a macro
framework to force a static context check on gotos to prevent gotos out of
scopes where doing it would be an error.
Something like:

enum { DISALLOW_GOTO_HERE = 0 }; //normally, goto is allowed
#define goto while(_Generic((int(*)[!DISALLOW_GOTO_HERE])0, int(*)[1]:1)) goto
//statically checked goto
int main(void){
    goto next; next:; //OK, not disallowed in this context

    #if 0 //would fail to compile
    enum {DISALLOW_GOTO_HERE=1}; //disallowed in this context
    goto next2; next2:;
    #endif
}

While this redefine does not syntactically disturb C, it does disturb `__asm
goto()`, which I, unfortunately, have one very frequently used instance of, and
since there's no way to suppress an object macro redefine, I'd like to be able
to change it to `__asm __goto__` and have it peacefully coexist with the goto
redefine.
)

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

* [Bug c/114011] Feature request: __goto__
  2024-02-20 12:43 [Bug c/114011] New: Feature request: __goto__ pskocik at gmail dot com
@ 2024-02-20 23:40 ` pinskia at gcc dot gnu.org
  2024-02-20 23:45 ` pinskia at gcc dot gnu.org
  2024-02-20 23:47 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-20 23:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114011

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

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

* [Bug c/114011] Feature request: __goto__
  2024-02-20 12:43 [Bug c/114011] New: Feature request: __goto__ pskocik at gmail dot com
  2024-02-20 23:40 ` [Bug c/114011] " pinskia at gcc dot gnu.org
@ 2024-02-20 23:45 ` pinskia at gcc dot gnu.org
  2024-02-20 23:47 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-20 23:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114011

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-02-20

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC has the following even:
  { "__asm",            RID_ASM,        0 },
  { "__asm__",          RID_ASM,        0 },

  { "__const",          RID_CONST,      0 },
  { "__const__",        RID_CONST,      0 },
  { "__inline",         RID_INLINE,     0 },
  { "__inline__",       RID_INLINE,     0 },


  { "__restrict",       RID_RESTRICT,   0 },
  { "__restrict__",     RID_RESTRICT,   0 },
  { "__signed",         RID_SIGNED,     0 },
  { "__signed__",       RID_SIGNED,     0 },


So confirmed.

I also not sure why there is no __unsigned/__unsigned__ either.

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

* [Bug c/114011] Feature request: __goto__
  2024-02-20 12:43 [Bug c/114011] New: Feature request: __goto__ pskocik at gmail dot com
  2024-02-20 23:40 ` [Bug c/114011] " pinskia at gcc dot gnu.org
  2024-02-20 23:45 ` pinskia at gcc dot gnu.org
@ 2024-02-20 23:47 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-20 23:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114011

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note a patch for this is one line added to the c_common_reswords array that is
defined in c-common.cc but would definitely need many testcases to test it.

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

end of thread, other threads:[~2024-02-20 23:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-20 12:43 [Bug c/114011] New: Feature request: __goto__ pskocik at gmail dot com
2024-02-20 23:40 ` [Bug c/114011] " pinskia at gcc dot gnu.org
2024-02-20 23:45 ` pinskia at gcc dot gnu.org
2024-02-20 23:47 ` pinskia 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).