Ticket #2968 (new task)

Opened 4 years ago

Last modified 9 months ago

add test for C trigraphs

Reported by: duncan Owned by: kchugalinskiy
Priority: lowest Milestone: 7.6.2
Component: Compiler Version: 6.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

main = print "??)"

If we compile the above -fvia-C then some gcc versions report:

/tmp/ghc6084_0/ghc6084_0.hc:99:30:
     warning: trigraph ??) ignored, use -trigraphs to enable

This should make us nervous.

According to the GCC manual if we were ever to use -std=c89 or any of the official C standard compliance modes (ie non-GNU) then we would get standard C (cpp) trigraph behavior.

We should therefore add a codeGen/should_run test to make sure that the above program does always print "??)" and never "]". This test only needs to be run for the -fvia-C 'ways', optc etc.

It's not an immediate priority but it may trip someone up in future when porting or if we make unregisterised C code more standards compliant and start using one of the official -std= modes. It is unlikely to hit us but if it ever did it'd be a real pain to debug.

Change History

  Changed 4 years ago by duncan

For info on gcc's treatment of trigraphs see  http://gcc.gnu.org/onlinedocs/cpp/Initial-processing.html

  Changed 4 years ago by igloo

  • owner set to igloo
  • difficulty set to Unknown

follow-up: ↓ 4   Changed 4 years ago by igloo

  • owner igloo deleted
  • milestone set to 6.12 branch

Good point; I've added a test cg063. It would make sense to avoid generating them too.

Based on what gcc -Wall says, "??)" is a trigraph but "?" "?)" isn't.

in reply to: ↑ 3   Changed 4 years ago by duncan

Replying to igloo:

Based on what gcc -Wall says, "??)" is a trigraph but "?" "?)" isn't.

Yes, the GCC page above says:

The nine trigraphs and their replacements are

          Trigraph:       ??(  ??)  ??<  ??>  ??=  ??/  ??'  ??!  ??-
          Replacement:      [    ]    {    }    #    \    ^    |    ~

It's also got some hints on how to avoid them, though it also seems to indicate that they're not portable.

  Changed 4 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.1

  Changed 4 years ago by igloo

  • failure set to None/Unknown
  • milestone changed from 6.12.1 to 6.12 branch

  Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

  Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

  Changed 3 years ago by kchugalinskiy

  • owner set to kchugalinskiy

  Changed 2 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

  Changed 2 years ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

  Changed 21 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

  Changed 16 months ago by igloo

  • priority changed from low to lowest
  • milestone changed from 7.4.1 to 7.6.1

  Changed 9 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2
Note: See TracTickets for help on using tickets.