From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17829 invoked by alias); 13 Feb 2003 09:46:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 17802 invoked by uid 71); 13 Feb 2003 09:46:02 -0000 Resent-Date: 13 Feb 2003 09:46:02 -0000 Resent-Message-ID: <20030213094602.17801.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, ediaz@veridis.com Received: (qmail 15885 invoked by uid 48); 13 Feb 2003 09:39:09 -0000 Message-Id: <20030213093909.15883.qmail@sources.redhat.com> Date: Thu, 13 Feb 2003 09:46:00 -0000 From: ediaz@veridis.com Reply-To: ediaz@veridis.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: preprocessor/9688: pasting "<" and "ValidStruct" does not give a valid preprocessing token X-SW-Source: 2003-02/txt/msg00558.txt.bz2 List-Id: >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 #include #include template 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::process(f1); return 0; }