Bug 63413 - cpp trying to expand "vector" word in commented line in fortran file on power8
Summary: cpp trying to expand "vector" word in commented line in fortran file on power8
Status: RESOLVED DUPLICATE of bug 28662
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.9.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-30 06:52 UTC by Valery Weber
Modified: 2015-08-30 14:37 UTC (History)
1 user (show)

See Also:
Host:
Target: powerpc*-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-12-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Valery Weber 2014-09-30 06:52:39 UTC
Hi All

The following code produces a wrong error while cpp (4.9.1 power8 ppc64le).
This gets cpp correctly on different archs.

v


cat tmp.F90 
program test
  ! vector
end program test

cpp --version
cpp (Ubuntu 4.9.1-15ubuntu1) 4.9.1
Copyright (C) 2014 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.

cpp -traditional -P tmp.F90













tmp.F90:2:0: error: detected recursion whilst expanding macro "vector"
   ! vector
 ^
program test
  ! vector
end program test
Comment 1 Dominique d'Humieres 2014-12-09 20:04:44 UTC
I don't see it on x86_64-apple-darwin14 (4.8.3, 4.9.2, 5.0).

This should reported to Ubuntu. Note that cpp is not part of Fortran, so the component is probably wrong.
Comment 2 Dominique d'Humieres 2014-12-09 20:05:20 UTC
s/This should reported/This should be reported/
Comment 3 Tobias Burnus 2014-12-10 08:58:42 UTC
By the way,
  cpp -dM </dev/null
shows all predefined macros - there should be also a definition for 'vector', I presume. (On my system, there isn't.)

You could try processing the file with "-undef", which should drastically reduce the number of defines.

OR, looking at the code below, you could try: -std= (such as "c90", cf. "man cpp"), which seems to disable the "vector" expansion.



What's missing is a proper Fortran support in libcpp, which is able to handle Fortran comments etc. That's tracked, e.g., in PR 28662.

* * *

Code wise, it comes from the following code in gcc/config/spu/spu-c.c:

  if (!flag_iso)
    {
      /* Define this when supporting context-sensitive keywords.  */
      cpp_define (pfile, "__VECTOR_KEYWORD_SUPPORTED__");
      cpp_define (pfile, "vector=vector");

      /* Initialize vector keywords.  */
      __vector_keyword = get_identifier ("__vector");
      C_CPP_HASHNODE (__vector_keyword)->flags |= NODE_CONDITIONAL;
      vector_keyword = get_identifier ("vector");
      C_CPP_HASHNODE (vector_keyword)->flags |= NODE_CONDITIONAL;

      /* Enable context-sensitive macros.  */
      cpp_get_callbacks (pfile)->macro_to_expand = spu_macro_to_expand;
    }
Comment 4 Dominique d'Humieres 2015-08-30 14:37:17 UTC
> What's missing is a proper Fortran support in libcpp, which is able
> to handle Fortran comments etc. That's tracked, e.g., in PR 28662.

Thus marked as duplicate.

*** This bug has been marked as a duplicate of bug 28662 ***