public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/37023]  New: Macro replacement not working if file is preprocessed then compiler
@ 2008-08-04 20:38 geir at cray dot com
  2008-08-04 20:43 ` [Bug c/37023] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: geir at cray dot com @ 2008-08-04 20:38 UTC (permalink / raw)
  To: gcc-bugs

The following program shows two cases where macro replacement works if the
program is compiled, but does NOT work if the program is preprocessed and then
compiled.  Either the preprocessed program should be able to be compiled, or
gcc should return an error when the non-preprocessed code is compiled.


$ cat ISU3006.c

/*  derived from ISU's RTED_OpenMP/C/Col7_Imp_Dep_Errs/c_G_1_1_a.c  */
/*  Trying c99 _Pragma possibility  */
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#define NT 4
#define N 17

#ifdef TEST3
#define NTM(x) #x
#define PRAGMA(x) NTM(omp parallel default(none) shared(vara,
actual_num_threads) num_threads(x) )
#define LISTING(x) _Pragma(x)
#endif

int actual_num_threads;

int main(){
    int vara=0;

#ifdef TEST3
  LISTING(PRAGMA(NT))
#elif TEST2
  _Pragma ( "omp parallel default(none) shared(vara, actual_num_threads)
num_threads(NT)" )
#else /*TEST1*/
 #pragma omp parallel default(none) shared(vara, actual_num_threads)
num_threads(NT)
#endif
    {
        #pragma omp master
        {
            actual_num_threads = omp_get_num_threads();
            vara = 10 + actual_num_threads;
        }
    }
    printf("calculate vara: %d\n",vara);
    return 0;
}

$ gcc --version
gcc (GCC) 4.3.1 20080606 (rpm:5)
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -fopenmp ISU3006.c
$ gcc -DTEST2 -fopenmp ISU3006.c
$ gcc -E -fopenmp ISU3006.c >i1.i
$ gcc -fopenmp i1.i
ISU3006.c: In function 'main':
ISU3006.c:26: error: 'NT' undeclared (first use in this function)
ISU3006.c:26: error: (Each undeclared identifier is reported only once
ISU3006.c:26: error: for each function it appears in.)
ISU3006.c:26: error: expected integer expression before end of line
$ grep parallel i1.i
extern int omp_in_parallel (void) __attribute__((__nothrow__));
#pragma omp parallel default(none) shared(vara, actual_num_threads)
num_threads(NT)
$ gcc -DTEST2 -E -fopenmp ISU3006.c >i2.i
$ gcc -fopenmp i2.i
ISU3006.c: In function 'main':
ISU3006.c:24: error: 'NT' undeclared (first use in this function)
ISU3006.c:24: error: (Each undeclared identifier is reported only once
ISU3006.c:24: error: for each function it appears in.)
ISU3006.c:24: error: expected integer expression before end of line
$ grep parallel i2.i
extern int omp_in_parallel (void) __attribute__((__nothrow__));
#pragma omp parallel default(none) shared(vara, actual_num_threads)
num_threads(NT)
$

   Here is code that allows the program to be compiled when first running it
through the preprocessor:

$ gcc -DTEST3 -fopenmp ISU3006.c
$ gcc -DTEST3 -E -fopenmp ISU3006.c >i3.i
$ gcc -fopenmp i3.i
$ grep parallel i3.i
extern int omp_in_parallel (void) __attribute__((__nothrow__));
#pragma omp parallel default(none) shared(vara, actual_num_threads)
num_threads(4)
$


-- 
           Summary: Macro replacement not working if file is preprocessed
                    then compiler
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: geir at cray dot com


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


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

* [Bug c/37023] Macro replacement not working if file is preprocessed then compiler
  2008-08-04 20:38 [Bug c/37023] New: Macro replacement not working if file is preprocessed then compiler geir at cray dot com
@ 2008-08-04 20:43 ` pinskia at gcc dot gnu dot org
  2008-08-04 20:47 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-04 20:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-08-04 20:41 -------
This works for me on the trunk ...


-- 


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


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

* [Bug c/37023] Macro replacement not working if file is preprocessed then compiler
  2008-08-04 20:38 [Bug c/37023] New: Macro replacement not working if file is preprocessed then compiler geir at cray dot com
  2008-08-04 20:43 ` [Bug c/37023] " pinskia at gcc dot gnu dot org
@ 2008-08-04 20:47 ` pinskia at gcc dot gnu dot org
  2008-08-10 20:02 ` [Bug c/37023] Macro replacement for openmp " pinskia at gcc dot gnu dot org
  2008-10-07 22:53 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-04 20:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-08-04 20:46 -------
This was fixed by:
http://gcc.gnu.org/ml/gcc-patches/2008-01/msg01145.html


-- 


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


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

* [Bug c/37023] Macro replacement for openmp not working if file is preprocessed then compiler
  2008-08-04 20:38 [Bug c/37023] New: Macro replacement not working if file is preprocessed then compiler geir at cray dot com
  2008-08-04 20:43 ` [Bug c/37023] " pinskia at gcc dot gnu dot org
  2008-08-04 20:47 ` pinskia at gcc dot gnu dot org
@ 2008-08-10 20:02 ` pinskia at gcc dot gnu dot org
  2008-10-07 22:53 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-10 20:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2008-08-10 20:01 -------
As mentioned this was fixed on the trunk for 4.4.0 so closing.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.4.0


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


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

* [Bug c/37023] Macro replacement for openmp not working if file is preprocessed then compiler
  2008-08-04 20:38 [Bug c/37023] New: Macro replacement not working if file is preprocessed then compiler geir at cray dot com
                   ` (2 preceding siblings ...)
  2008-08-10 20:02 ` [Bug c/37023] Macro replacement for openmp " pinskia at gcc dot gnu dot org
@ 2008-10-07 22:53 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-10-07 22:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2008-10-07 22:51 -------
*** Bug 37764 has been marked as a duplicate of this bug. ***


-- 


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


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

end of thread, other threads:[~2008-10-07 22:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-04 20:38 [Bug c/37023] New: Macro replacement not working if file is preprocessed then compiler geir at cray dot com
2008-08-04 20:43 ` [Bug c/37023] " pinskia at gcc dot gnu dot org
2008-08-04 20:47 ` pinskia at gcc dot gnu dot org
2008-08-10 20:02 ` [Bug c/37023] Macro replacement for openmp " pinskia at gcc dot gnu dot org
2008-10-07 22:53 ` pinskia 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).