Bug 36088 - Unevaluated PP expression rejected
Summary: Unevaluated PP expression rejected
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 4.1.3
: P3 normal
Target Milestone: 4.4.0
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks: 16989 16620
  Show dependency treegraph
 
Reported: 2008-04-30 15:42 UTC by Neil Booth
Modified: 2008-05-30 15:15 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.0
Known to fail:
Last reconfirmed: 2008-05-01 19:31:47


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Booth 2008-04-30 15:42:20 UTC
Compile with pedantic-errors, C99 or C90.

extern int x;
#if 1 ? 0: 1 ? 1/0: 1/0
#endif

Code is fine as the divisions by zero are unevaluated.
Comment 1 Tom Tromey 2008-04-30 17:51:38 UTC
Confirmed.

The bug is that we look at top[-1].value after overwriting it with the
value of the 'true' branch of the condition.
Comment 2 Tom Tromey 2008-05-01 19:31:47 UTC
Testing a patch.
Comment 3 Tom Tromey 2008-05-06 17:15:59 UTC
Subject: Bug 36088

Author: tromey
Date: Tue May  6 17:15:07 2008
New Revision: 134989

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134989
Log:
gcc/testsuite
	PR preprocessor/35313, PR preprocessor/36088:
	* gcc.dg/cpp/pr35313.c: New file.
	* gcc.dg/cpp/if-oppr.c: Remove test for ',' in a conditional
	expression.
	* gcc.dg/cpp/if-oppr2.c: New file.
libcpp
	PR preprocessor/35313, PR preprocessor/36088:
	* expr.c (optab) <QUERY, COMMA>: Set precedence to 4.
	(reduce) <case CPP_QUERY>: Special case CPP_COMMA and CPP_COLON.

Added:
    trunk/gcc/testsuite/gcc.dg/cpp/if-oppr2.c
    trunk/gcc/testsuite/gcc.dg/cpp/pr35313.c
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/cpp/if-oppr.c
    trunk/libcpp/ChangeLog
    trunk/libcpp/expr.c

Comment 4 Tom Tromey 2008-05-06 18:10:17 UTC
Fixed on trunk.
Comment 5 Tom Tromey 2008-05-30 15:15:37 UTC
Not a regression, so I'm closing it.