public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/43027]  New: #pragma rejected inside enum defn
@ 2010-02-11  1:51 PHHargrove at lbl dot gov
  2010-02-11 20:15 ` [Bug c/43027] " tromey at gcc dot gnu dot org
  0 siblings, 1 reply; 3+ messages in thread
From: PHHargrove at lbl dot gov @ 2010-02-11  1:51 UTC (permalink / raw)
  To: gcc-bugs

Given the 3-line C file below, compilation with gcc-4.4.2 produces the output
that follows the code ("gcc -v" output provided as well).  I am not providing
the corresponding .i file under bug reporting guidelines "excuse ii": small
file that doesn't include any other file.

==begin code==
    enum {
    #pragma message "Hello from enum"
    VALUE1, VALUE2 };
==end code==

$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/usr/local/pkg/gcc-4.4.2
--with-gmp=/usr/local/pkg/gmp-4.2.4 --with-mpfr=/usr/local/pkg/mpfr-2.3.2
--disable-nls --disable-bootstrap --enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.4.2 (GCC)

$ gcc -c bug.c
bug.c:2: error: expected identifier before '#pragma'

I have tried a few other gcc versions (on both 32- and 64-bit targets) and any
I can find that are new enough to support "#pragma message" produce similar
results.  It is my suspicion that any supported (non-ignored) pragma is going
to trigger the same error.

While the utility of the #pragma inside the enum definition is questionable, I
am not aware of anything that would prohibit its placement there (but am
willing to be enlightened).  In fact, the struct and union definitions below
appear to work just fine:
   struct S {
      #pragma message "Hello from struct"
      int i;
      float f;
    };
    union U {
      #pragma message "Hello from union"
      int i;
      float f;
    };

$ gcc -c notbug.c
notbug.c:2: note: #pragma message: Hello from struct
notbug.c:7: note: #pragma message: Hello from union


-- 
           Summary: #pragma rejected inside enum defn
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: PHHargrove at lbl dot gov


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


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

end of thread, other threads:[~2021-09-19 23:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-43027-4@http.gcc.gnu.org/bugzilla/>
2013-11-05  6:43 ` [Bug c/43027] #pragma rejected inside enum defn PHHargrove at lbl dot gov
2021-09-19 23:55 ` pinskia at gcc dot gnu.org
2010-02-11  1:51 [Bug preprocessor/43027] New: " PHHargrove at lbl dot gov
2010-02-11 20:15 ` [Bug c/43027] " tromey at gcc dot gnu dot 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).