public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* preprocessor/9688: pasting "<" and "ValidStruct" does not give a valid preprocessing token
@ 2003-02-13 9:46 ediaz
0 siblings, 0 replies; 3+ messages in thread
From: ediaz @ 2003-02-13 9:46 UTC (permalink / raw)
To: gcc-gnats
>Number: 9688
>Category: preprocessor
>Synopsis: pasting "<" and "ValidStruct" does not give a valid preprocessing token
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Thu Feb 13 09:46:02 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: ediaz@veridis.com
>Release: 3.3 branch, pre-release. 2003-02-12
>Organization:
>Environment:
SuSE 7.3/Linux
>Description:
When I try to compile a file using macros of templates, I get a 'MyFileStruct.h:541:67: pasting "<" and "MyStruct" does not give a valid preprocessing token' message.
It worked perfectly with the 2.95.x serie and with the 3.2.1 version.
I've tryied to do it in two passes, with a --save-temps and a g++ thefile.ii -c and it worked. Like if the processed code was not the same as the preprocessor's output.
I've tried to make a dummy example which get that strange behaviour.
sh-2.05$ g++ test.cpp -o t1
test.cpp:57:32: pasting "<" and "Field" does not give a valid preprocessing token
Got a failure, but in two passes :
sh-2.05$ g++ test.cpp --save-temps
test.cpp:57:32: pasting "<" and "Field" does not give a valid preprocessing token
sh-2.05$ g++ test.ii -o t2
sh-2.05$
Works fine.
>How-To-Repeat:
Just try the test.cpp file with the command lines in the description field.
>Fix:
A (IMHO dirty) workaround is to do it in two passes.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="test.cpp"
Content-Disposition: inline; filename="test.cpp"
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
template <class T>
class C
{
T hold;
public:
C(T to_hold)
{
hold=to_hold;
}
static void process(T a_value)
{
// NOP
puts("Generic");
return 0;
}
};
#define CM(x,va,vg) \
template<> \
class C < ##x > \
{ \
public: \
static void process(x a_value) \
{ \
va \
vg \
} \
};
#define V(y) puts( #y );
struct Field
{
char* name;
char* value;
bool operator==(const Field& o) const
{
return (strcmp(name,o.name)==0) && (strcmp(value,o.value)==0);
}
bool operator!=(const Field& o) const
{
return (strcmp(name,o.name)!=0) || (strcmp(value,o.value)!=0);
}
};
CM( Field , V(name1) , V(name2));
int main(int argc,char* argv[])
{
Field f1;
f1.name="afield";
f1.name="avalue";
C<Field>::process(f1);
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: preprocessor/9688: pasting "<" and "ValidStruct" does not give a valid preprocessing token
@ 2003-02-13 10:26 Eric Diaz
0 siblings, 0 replies; 3+ messages in thread
From: Eric Diaz @ 2003-02-13 10:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/9688; it has been noted by GNATS.
From: Eric Diaz <ediaz@veridis.com>
To: neil@gcc.gnu.org,
ediaz@veridis.com,
gcc-bugs@gcc.gnu.org,
gcc-prs@gcc.gnu.org,
nobody@gcc.gnu.org,
gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: preprocessor/9688: pasting "<" and "ValidStruct" does not give a valid preprocessing token
Date: Thu, 13 Feb 2003 11:22:45 +0100
On Thursday 13 February 2003 11:12, you wrote:
> Synopsis: pasting "<" and "ValidStruct" does not give a valid preprocessing
> token
>
> State-Changed-From-To: open->closed
> State-Changed-By: neil
> State-Changed-When: Thu Feb 13 10:12:26 2003
> State-Changed-Why:
> Not a bug. Two passes are different coz only one is doing macro
> expansion!
doh ... I had forgotten that ...
Thank you very much.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: preprocessor/9688: pasting "<" and "ValidStruct" does not give a valid preprocessing token
@ 2003-02-13 10:12 neil
0 siblings, 0 replies; 3+ messages in thread
From: neil @ 2003-02-13 10:12 UTC (permalink / raw)
To: ediaz, gcc-bugs, gcc-prs, nobody
Synopsis: pasting "<" and "ValidStruct" does not give a valid preprocessing token
State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Thu Feb 13 10:12:26 2003
State-Changed-Why:
Not a bug. Two passes are different coz only one is doing macro expansion!
Remove the ##. And no, 3.2.1 was no different, but just a warning.
2.95 accepted invalid constructs.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9688
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-02-13 10:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-13 9:46 preprocessor/9688: pasting "<" and "ValidStruct" does not give a valid preprocessing token ediaz
2003-02-13 10:12 neil
2003-02-13 10:26 Eric Diaz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).