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  1:54 ` [Bug preprocessor/43027] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ 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] 4+ messages in thread

* [Bug preprocessor/43027] #pragma rejected inside enum defn
  2010-02-11  1:51 [Bug preprocessor/43027] New: #pragma rejected inside enum defn PHHargrove at lbl dot gov
@ 2010-02-11  1:54 ` pinskia at gcc dot gnu dot org
  2010-02-11  2:09 ` PHHargrove at lbl dot gov
  2010-02-11 20:15 ` [Bug c/43027] " tromey at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-02-11  1:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2010-02-11 01:54 -------
Looks related to PR 37267 but that talks about #pragma inside struct.  Hmm.


-- 


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


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

* [Bug preprocessor/43027] #pragma rejected inside enum defn
  2010-02-11  1:51 [Bug preprocessor/43027] New: #pragma rejected inside enum defn PHHargrove at lbl dot gov
  2010-02-11  1:54 ` [Bug preprocessor/43027] " pinskia at gcc dot gnu dot org
@ 2010-02-11  2:09 ` PHHargrove at lbl dot gov
  2010-02-11 20:15 ` [Bug c/43027] " tromey at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: PHHargrove at lbl dot gov @ 2010-02-11  2:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from PHHargrove at lbl dot gov  2010-02-11 02:09 -------
(In reply to comment #1)
> Looks related to PR 37267 but that talks about #pragma inside struct.  Hmm.

Indeed this shares w/ PR 37267 the fact that the original code looks roughly
like:
   enum {
     #include "enum_body.h"
   };
and in my case the #pragma was inserted by a program that processes a .i file
and inserts #pragmas following #line directives that match certain criteria.

If, as with PR 37267, it is decided to resolve this as INVALID, I'd appreciate
a reference to the rules for what constitutes legal placement of #pragmas in
general (i.e. I don't need all the pragma-specific rules for placement).  Then
I can (hopefully) modify my .i-munging code to conform.


-- 


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


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

* [Bug c/43027] #pragma rejected inside enum defn
  2010-02-11  1:51 [Bug preprocessor/43027] New: #pragma rejected inside enum defn PHHargrove at lbl dot gov
  2010-02-11  1:54 ` [Bug preprocessor/43027] " pinskia at gcc dot gnu dot org
  2010-02-11  2:09 ` PHHargrove at lbl dot gov
@ 2010-02-11 20:15 ` tromey at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at gcc dot gnu dot org @ 2010-02-11 20:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from tromey at gcc dot gnu dot org  2010-02-11 20:15 -------
This is a C bug, not a preprocessor bug, so I'm reassigning.

I suppose that it is really a documentation bug, but I didn't see a
category for that.


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at gcc dot gnu dot
                   |                            |org
          Component|preprocessor                |c


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


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

end of thread, other threads:[~2010-02-11 20:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-11  1:51 [Bug preprocessor/43027] New: #pragma rejected inside enum defn PHHargrove at lbl dot gov
2010-02-11  1:54 ` [Bug preprocessor/43027] " pinskia at gcc dot gnu dot org
2010-02-11  2:09 ` 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).