Bug 2821 - const statements with '-' does not compile
Summary: const statements with '-' does not compile
Status: RESOLVED FIXED
Alias: None
Product: TAO
Classification: Unclassified
Component: IDL Compiler (show other bugs)
Version: 1.5.6
Hardware: All All
: P3 normal
Assignee: Chad Elliott
URL: http://www.omesc.com/content/download...
Depends on:
Blocks: 1824
  Show dependency tree
 
Reported: 2007-02-20 05:56 CST by Jules Colding
Modified: 2007-03-26 07:59 CDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jules Colding 2007-02-20 05:56:27 CST
Simple const devlaration does not work if the right-hand side has a
"-" operator in it. The following are simple const declarations that fails and
some that deosn't.       

This IDL code fails (with error message):
           const unsigned long TEST_CONST = 0x10 - 0x01;
           "Malformed const declaration"

and so does this:
           const unsigned long TEST_CONST = (0x10 - 0x01);
           "Missing value expr or illegal syntax following '='"

This does not fail:
           const unsigned long TEST_CONST = 0x10 + 0x01;

and neither does this:
           const unsigned long SIMPLE_CONST = 0x10;
           const unsigned long TEST_CONST = SIMPLE_CONST + 0x01;

But this one fails:
           const unsigned long SIMPLE_CONST = 0x10;
           const unsigned long TEST_CONST = SIMPLE_CONST - 0x01;
           "Malformed const declaration"

and this:
           const unsigned long SIMPLE_CONST = 0x10;
           const unsigned long TEST_CONST = (SIMPLE_CONST - 0x01);
           "Illegal component in scoped name"

This one fails:
        const unsigned long TEST_CONST = 0x10 - 0x01;
        "Malformed const declaration"

and this one:
        const unsigned long TEST_CONST = 0x10 + (-0x01);
        "coercion failure 16 +  to unsigned long"

and this one too:
        const long TEST_CONST = 0x10 - 0x01;
        "Malformed const declaration"

but this one does *NOT* fail:
        const long TEST_CONST = 0x10 + (-0x01);

I'm using the following tao_idl compile options:

           "tao_idl $(InputPath) -o $(InputDir) -I$(InputDir) -Ce -in -Ge 2 -GI
-GIh S_impl.h -GIs S_impl.cpp -si S.inl -ci C.inl
-Wb,export_macro=SERVANTLIB_API
-Wb,export_include=NT_Service/ServantLib/ServantLib.h"

Something bad must be up with the parsing in the idl compiler. This did 
work in earlier TAO releases such as TAO 1.5.3.
Comment 1 Johnny Willemsen 2007-02-22 04:03:28 CST
changed priority and severity
Comment 2 Jeff Parsons 2007-02-22 07:58:17 CST
Changed host and compiler values above to All
Comment 3 Jules Colding 2007-02-26 04:21:19 CST
OK, It juts dawned upon me that I've put some information about this bug into
#1824 which I'll promptly reproduce here.

The "meat" in that information is that all TAO releases up to and including TAO
1.5.4 is OK. In other words - the bug was introduced in TAO 1.5.5. The following
is a simple IDL file that shows how to reproduce the bug. Just compile it with
tao_idl with no options.


############### Sample IDL ##################
#ifndef _DEFINES_DEF_
#define _DEFINES_DEF_

#pragma prefix "omc.brutus"

module BRUTUS {

        typedef unsigned long BDEFINE;
	typedef BDEFINE PT_TYPE;

        const PT_TYPE BRUTUS_PT_LONG = 0x00000004;

        const BDEFINE BRUTUS_pidExchangeXmitReservedMin = 0x3FE0;

	const BDEFINE BRUTUS_PR_AUTO_RESPONSE_SUPPRESS = BRUTUS_PT_LONG |
((BRUTUS_pidExchangeXmitReservedMin - 0x01)<<16);
}; // End of module BRUTUS


#endif
####################### END ##########################

A mail from Doug seems to indicate that changes submitted to "idl.ll" by Chad
Elliott <elliott_c@ociweb.com> are responsible for this bug. These changes was
commented in ChangeLog-07a under the entry:

 Tue Nov 28 19:32:46 UTC 2006  Jeff Parsons <j.parsons@vanderbilt.edu>
 - Added patches to the lex file and to the corresponding
   generated C++ file that (1) corrects inconsistencies
   between these two files and (2) fixes problems with
   the SunCC preprocessor. Also patched the corresponding
   lex.yy.cpp.diff file. Thanks to Chad Elliott
   <elliott_c@ociweb.com> for supplying the patches.

They correspond to this changeset:

https://svn.dre.vanderbilt.edu/viewvc/Middleware/trunk/TAO/TAO_IDL/fe/idl.ll?r1=75647&r2=75650

HTH,
  jules

Comment 4 Johnny Willemsen 2007-02-26 04:28:42 CST
Chad, can you check this bugzilla report, it could be caused by some changes at
your side
Comment 5 Jules Colding 2007-02-26 06:47:26 CST
I think it would be useful if I copy the content of another mail from Doug as it
explicitly points to the regular expressions that might be responsible for the
bug. Please forgive me for the whitespace disaster that bugzilla comments
continue to be :-(

################### Mail from Doug #######################
Hi Jeff,

According to SVN you made a bunch of changes to idl.ll last fall.  A
bunch of these changes affected the regular expressions with '-' in
them, e.g.:

parsons 2006-11-28 13:43:35 -0600 (Tue, 28 Nov 2006) ("-"[
\t]*)?(([0-9]+"."[0-9]*)|("."[0-9]+))([eE][+-]?[0-9]+)?[lLfF]?
parsons 2006-11-28 13:43:35 -0600 (Tue, 28 Nov 2006) ("-"[
\t]*)?[0-9]+[eE][+-]?[0-9]+[lLfF]?  {
parsons 2006-11-28 13:43:35 -0600 (Tue, 28 Nov 2006) "-"[ \t]*[1-9][0-9]* {
parsons 2006-11-28 13:43:35 -0600 (Tue, 28 Nov 2006) "-"[ \t]*0[xX][a-fA-F0-9]+ {
parsons 2006-11-28 13:43:35 -0600 (Tue, 28 Nov 2006) 0[xX][a-fA-F0-9]+ {
parsons 2006-11-28 13:43:35 -0600 (Tue, 28 Nov 2006) "-"[ \t]*0[0-7]* {

Can you please take a look at this stuff to see how that may have
affected the problems that Jules reported?

Thanks,

Doug
Comment 6 Chad Elliott 2007-02-26 06:59:37 CST
I can't think of a way to do this to where the initial problem doesn't come
back.  I will probably have to revert the change since it now seems kind of
strange that this should be an acceptable negative integer:  - 9.

I think the SunCC preprocessor is just wrong.
Comment 7 Chad Elliott 2007-02-26 08:47:36 CST
Mon Feb 26 14:44:07 UTC 2007  Chad Elliott  <elliott_c@ociweb.com>

        * TAO_IDL/fe/idl.ll:
        * TAO_IDL/fe/lex.yy.cpp:

          Reverted my change (committed by Jeff Parsons on my behalf) from
          Tue Nov 28 19:32:46 UTC 2006.  While it fixed an issues with the
          Sun preprocessor (e.g., negative numbers coming out like "- 9"),
          it causes problems with normal subtraction.  Thanks to Jules
          Colding <olding at omesc dot com> for reporting this.  This fixes
          bugzilla bug #2821.

Comment 8 Jules Colding 2007-02-26 08:49:50 CST
Will check tomorrow.
Comment 9 Johnny Willemsen 2007-02-26 12:39:23 CST
Chad, I am reopening this because I think we need this in our regression test
suite. Can you take the test idl Jules added to 1824 and add it to idl_test? I
think then with a ifdef you can disable this idl file for the suncc
preprocessors that are broken to handle this correctly. Can you report the
preprocessor problem to sun?
Comment 10 Chad Elliott 2007-02-26 13:29:55 CST
I added the following lines to constants.idl in my workspace:

// const values created through mathematic operations
const long neg = -8;
const long sub1 = 0x10 - 0x01;
const long sub2 = 0x10 + (-0x01);
const unsigned long add1 = 16 + 1;
const unsigned long mul1 = 0x80 * 0x70;
const unsigned long div1 = 99 / 12;

And with CC: Sun C++ 5.8 Patch 121017-08 2006/12/06, this caused no problems at
all.  I'm going to check it in as is and see which Sun compilers have the problem.
Comment 11 Johnny Willemsen 2007-02-27 02:56:09 CST
Chad, check the Solaris10_Studio11_Debug build on the scoreboard, this now gives
an error after the revert. Maybe change the example that gives the error to not
use negative numbers and move the idl that gives a problem also to the idl-test
and ifdef it out for the broken sun preprocessor
Comment 12 Johnny Willemsen 2007-02-27 07:10:28 CST
Chad, can you disable the broken example code just for the 5.8 version of
sunc++? That is the only version that we know is broken. You can report issues
to sun online at http://bugs.sun.com/services/bugreport/index.jsp
Comment 13 Chad Elliott 2007-02-27 07:22:26 CST
Actually, I was able to test SunCC 5.0 through SunCC 5.8 and all of the
preprocessor output looked the same.
Comment 14 Johnny Willemsen 2007-02-27 07:36:50 CST
it looks the same but the difference between a tab or a space is not real
visible from a plain editor. For example the studio 10 build on the scoreboard
which uses CC: Sun C++ 5.7 Patch 117831-08 2006/07/12 doesn't show the error in
the example, only the 5.8 compiler. Can you disable the code just for 5.8 and
then check the scoreboard tomorrow again?
Comment 15 Chad Elliott 2007-02-27 07:54:01 CST
The type of whitespace is irrelevant.  They are treated exactly the same by the
lexer.  As far as the versions, I just tested processing the union.idl (with the
SunCC guard commented out) with the following versions of SunCC.

CC: Sun C++ 5.8 Patch 121017-08 2006/12/06
CC: Sun C++ 5.7 Patch 117830-09 2006/11/01
CC: Sun C++ 5.6 2004/07/15
CC: Sun C++ 5.5 2003/03/12                
CC: Forte Developer 7 C++ 5.4 2002/03/09
CC: Sun WorkShop 6 update 2 C++ 5.3 2001/05/15
CC: Sun WorkShop 6 update 1 C++ 5.2 Patch 109508-03 2001/04/07
CC: Sun WorkShop 6 2000/08/30 C++ 5.1 Patch 109490-01

They all give the same results.
Comment 16 Chad Elliott 2007-02-27 08:04:21 CST
The Solaris10-x86-Studio10 build on corona has the following in the config.h:

#define TAO_IDL_PREPROCESSOR "cc"

This would explain why it doesn't have the problem.
Comment 17 Jules Colding 2007-02-27 08:08:54 CST
I've just tried to test this today. svn HEAD (or whatever it is called in
subversion) failed to compile on Windows 2003 with VC++ 8:

MCAST_Parser.cpp
.\MCAST_Parser.cpp(61) : error C2146: syntax error : missing ')' before
identifier 'ACE_ENV_ARG_PARAMETER'
.\MCAST_Parser.cpp(61) : error C2059: syntax error : ')'


Comment 18 Johnny Willemsen 2007-02-27 08:11:05 CST
head is broken at this moment, see http://remedy.nl, can always happen, we are
waiting for Ossama, he broke it but he is probably not online yet
Comment 19 Chad Elliott 2007-02-27 12:21:55 CST
I believe that the bug is not in the SunCC preprocessor, but the tao_idl parser
or related code.  According to the IDL grammar, the following idl should be legal:

union foo switch (short)
{
  case 10 >> 1: string foo_str_member;
  case +1: long foof;
}; 

However, neither case label is accepted.  I think that if these are fixed, the
"case - 1:" problem would come along for the ride.
Comment 20 Jules Colding 2007-03-26 07:39:59 CDT
OK, I can confirm that all of my IDL files now compiles with tao_idl. 
Comment 21 Jules Colding 2007-03-26 07:40:53 CDT
in TAO 1.5.7....
Comment 22 Chad Elliott 2007-03-26 07:59:05 CDT
Closing