Thread overview
[Issue 23693] compilable/testcstuff3.i:7:1: error: stray '#' in program
Feb 12, 2023
Iain Buclaw
Feb 16, 2023
Iain Buclaw
Feb 20, 2023
Walter Bright
Feb 20, 2023
Iain Buclaw
[Issue 23693] ImportC: Unclear documentation of #line and linemarker support
Feb 20, 2023
Iain Buclaw
Feb 27, 2023
Iain Buclaw
Dec 04, 2023
Walter Bright
Dec 05, 2023
Iain Buclaw
February 12, 2023
https://issues.dlang.org/show_bug.cgi?id=23693

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, ImportC
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=23689
         Depends on|                            |23689


Referenced Issues:

https://issues.dlang.org/show_bug.cgi?id=23689
[Issue 23689] ImportC: C tests in the testsuite are not valid C
--
February 16, 2023
https://issues.dlang.org/show_bug.cgi?id=23693

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #1 from Iain Buclaw <ibuclaw@gdcproject.org> ---
The discrepancy here between GCC and ImportC is that ImportC recognizes and parses `#line` directives.

In GCC `#line` is a CPP-only directive, instead replaces them all with gcc-specific linemarkers.


The linemarker tests in the testsuite are not representative of real line markers emitted from gcc, hence why they fail.

--
February 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23693

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
linemarkers are a gcc extension, not a standard:

https://gcc.gnu.org/onlinedocs/gcc-11.1.0/cpp/Preprocessor-Output.html

Microsoft's preprocessor generates #line linemarkers, too.

ImportC has to work with the output of C preprocessors other than gcc's. There's not much I can do about that. I recommend gcc simply not run those tests.

--
February 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23693

--- Comment #3 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Walter Bright from comment #2)
> ImportC has to work with the output of C preprocessors other than gcc's. There's not much I can do about that. I recommend gcc simply not run those tests.
The point of this is to find code that is not valid C. Be it because the standard says it's not supported, or it's a vendor-specific extension of C that we're testing in the wrong way. After all if they reject the way we're testing their own extensions, maybe we should reject them too.

The ImportC documentation is pretty scant on actually saying what is accepted.

https://dlang.org/spec/importc.html#preprocessor-directives

Perhaps obvious enough to close this as wontfix (though I'd prefer to fix the GCC linemarker tests so they are *valid* examples of lines the preprocessor will pipe to ImportC).  But not obvious enough that they are accepted even if there's been no preprocessing done on the input file.  Maybe a couple examples of what forms of #line directive and linemarker are supported - same as the #pragma paragraph.

--
February 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23693

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|dmd                         |dlang.org
            Summary|compilable/testcstuff3.i:7: |ImportC: Unclear
                   |1: error: stray '#' in      |documentation of #line and
                   |program                     |linemarker support

--
February 27, 2023
https://issues.dlang.org/show_bug.cgi?id=23693

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
December 04, 2023
https://issues.dlang.org/show_bug.cgi?id=23693

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
There are two different things:

1. #line directives described as part of the preprocessing pass, in C11 6.10.4. They were asked for for D, and I didn't see an issue with leaving them in for C.

2. linemarkers

The linemarker tests:

    # 1020 "cstuff3.c" 1 2 3 4

conform to gcc's specification of them:

"After the file name comes zero or more flags, which are ‘1’, ‘2’, ‘3’, or ‘4’. If there are multiple flags, spaces separate them."

https://gcc.gnu.org/onlinedocs/gcc-11.1.0/cpp/Preprocessor-Output.html

gcc does indeed barf on more than one flag, but that's a bug in gcc, according to gcc's spec.

Both are documented by referring to the respective documents for them. I don't want to write an equivalent specification that is identical but different in order to avoid copyright issues.

And, lastly, the test suite is for testing ImportC, not for testing gcc. Although your work in running them through gcc is valuable and has uncovered problems with ImportC, and I appreciate your efforts in doing this.

I'm going to mark this as wontfix.

--
December 05, 2023
https://issues.dlang.org/show_bug.cgi?id=23693

--- Comment #5 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Walter Bright from comment #4)
> There are two different things:
> 
> 1. #line directives described as part of the preprocessing pass, in C11 6.10.4. They were asked for for D, and I didn't see an issue with leaving them in for C.
> 
> 2. linemarkers
> 
> The linemarker tests:
> 
>     # 1020 "cstuff3.c" 1 2 3 4
> 
> conform to gcc's specification of them:
> 
> "After the file name comes zero or more flags, which are ‘1’, ‘2’, ‘3’, or ‘4’. If there are multiple flags, spaces separate them."
> 
> https://gcc.gnu.org/onlinedocs/gcc-11.1.0/cpp/Preprocessor-Output.html
> 
> gcc does indeed barf on more than one flag, but that's a bug in gcc, according to gcc's spec.
> 
There is no spec on them.  Line markers are machine-generated code inserted into the preprocessed source file, human-written tests don't make much sense to be present in the testsuite unless they are the product of copying from a compiler generated `.i` file.

--
December 15, 2023
https://issues.dlang.org/show_bug.cgi?id=23693
Issue 23693 depends on issue 23689, which changed state.

Issue 23689 Summary: ImportC: C tests in the testsuite are not valid C https://issues.dlang.org/show_bug.cgi?id=23689

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--