Bug 28768 - [4.0/4.1/4.2 Regression] Preprocessor doesn't parse tokens correctly?
Summary: [4.0/4.1/4.2 Regression] Preprocessor doesn't parse tokens correctly?
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.0
: P2 minor
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2006-08-18 05:07 UTC by Steve
Modified: 2006-09-13 02:28 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.3
Known to fail: 3.4.0 4.0.0 4.1.0 4.2.0
Last reconfirmed: 2006-08-18 05:11:28


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve 2006-08-18 05:07:30 UTC
The following C program will not compile with the command "gcc file.c":

#define FIRST "This is a split
int main() {
   printf( FIRST string");
}

It gives the expected error message about the malformed preprocessor token. However if the output of "cpp file.c" or "gcc -E file.c" is saved and fed back into gcc then it DOES compile and run. Here is the output of "gcc -E file.c":

int main() {
   printf( "This is a split string");
}

I checked the ANSI standard and this is indeed an illegal program. Shouldn't the preprocessor give an error message when run alone?
Comment 1 Andrew Pinski 2006-08-18 05:11:28 UTC
Confirmed, a regression from 3.3.3.
Comment 2 Steve 2006-08-18 06:31:31 UTC
On a related note, is macro prescanning of arguments part of the ANSI standard? In "Harbison and Steele" they seem to imply argument prescanning in macros is not ANSI-compliant...
Comment 3 jsm-csl@polyomino.org.uk 2006-08-20 23:07:24 UTC
Subject: Re:  [4.0/4.1/4.2 Regression] Preprocessor doesn't
 parse tokens correctly?

This bug is closely related to bug 14634 - not diagnosing these cases 
with -E looks like another case of the same ill-advised extensions (which 
I'd still be glad to revert to being mandatory errors).

Comment 4 Andrew Pinski 2006-08-21 05:11:57 UTC
There is a reference to this problem in:
http://gcc.gnu.org/ml/gcc-patches/2003-04/msg01827.html

But it says it was not the cause of the problem though.
--------------------------------------------------------
Janis,
  Could you do a regression hunt on this bug?

Thanks,
Andrew Pinski
Comment 5 Janis Johnson 2006-08-21 18:29:30 UTC
A regression hunt on powerpc-linux identified this patch:

                                                                                
    http://gcc.gnu.org/viewcvs?view=rev&rev=66019

    r66019 | neil | 2003-04-23 22:44:06 +0000 (Wed, 23 Apr 2003)
Comment 6 Neil Booth 2006-08-23 13:16:35 UTC
Subject: Re:  [4.0/4.1/4.2 Regression] Preprocessor doesn't parse tokens correctly?

pinskia at gcc dot gnu dot org wrote:-

> 
> 
> ------- Comment #1 from pinskia at gcc dot gnu dot org  2006-08-18 05:11 -------
> Confirmed, a regression from 3.3.3.

Rather, intended behaviour since 3.3.3.

Neil.
Comment 7 Joseph S. Myers 2006-09-13 01:04:29 UTC
Subject: Bug 28768

Author: jsm28
Date: Wed Sep 13 01:04:18 2006
New Revision: 116915

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116915
Log:
libcpp:
	PR c/28768
	PR preprocessor/14634
	* lex.c (lex_string): Pedwarn for unterminated literals.

libgomp:
	* configure.ac (HAVE_CLOCK_GETTIME): Add missing second argument
	to AC_DEFINE.
	* configure: Regenerate.

gcc/testsuite:
	* gcc.dg/cpp/include2.c, gcc.dg/cpp/macspace1.c,
	gcc.dg/cpp/macspace2.c, gcc.dg/cpp/multiline.c,
	gcc.dg/cpp/trad/literals-2.c: Update expected diagnostics.


Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/cpp/include2.c
    trunk/gcc/testsuite/gcc.dg/cpp/macspace1.c
    trunk/gcc/testsuite/gcc.dg/cpp/macspace2.c
    trunk/gcc/testsuite/gcc.dg/cpp/multiline.c
    trunk/gcc/testsuite/gcc.dg/cpp/trad/literals-2.c
    trunk/libcpp/ChangeLog
    trunk/libcpp/lex.c
    trunk/libgomp/ChangeLog
    trunk/libgomp/configure
    trunk/libgomp/configure.ac

Comment 8 Joseph S. Myers 2006-09-13 02:28:25 UTC
Fixed in 4.2.0 by making this a mandatory pedwarn; I don't consider this suitable to apply to past release branches which have had releases without the pedwarn.