Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: Re: [cdt-dev] Compiler supports keyword "__restrict__" instead of keyword "restrict"

Please raise a bugzilla on this and attach your patch:
Thanks, Markus.

From: Abeer Bagul [mailto:abeer4eclipse@xxxxxxxxx]
Sent: Thursday, February 21, 2008 1:02 PM
To: cdt-dev@xxxxxxxxxxx
Cc: Schorn, Markus
Subject: Re: Re: [cdt-dev] Compiler supports keyword "__restrict__" instead of keyword "restrict"
Importance: Low

Hi Markus,

Thanks for your reply.

The extra macro definitions are added to the class GNUScannerExtensionConfiguration to record that the keyword "restrict" can have alternatives "__restrict__" and "__restrict".
These extra marco definitions are useful in clients such as the Outline view.

More specifically what I had intially observed was that the keywords "__restrict__" and "__restrict" were not being highlighted in the C Editor with the syntax highlighting.
This had prompted me to ask the question.
The current macro definitions do not seem to address the lack of syntax highlighting for the two keywords.

Syntax highlighting can be enabled for these keywords in the C Editor if two entries are added to the class GCCScannerExtensionConfiguration which is a subclass of GNUScannerExtensionConfiguration.

The patch below shows how I added the entries for "__restrict__" and "__restrict" in the class GCCScannerExtensionConfiguration.

1: Patch to class GCCKeywords

### Eclipse Workspace Patch 1.0
#P org.eclipse.cdt.core
Index: parser/org/eclipse/cdt/core/parser/
RCS file: /cvsroot/tools/org.eclipse.cdt-releng/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/,v
retrieving revision 1.9
diff -u -r1.9
--- parser/org/eclipse/cdt/core/parser/    14 Jun 2007 18:04:00 -0000    1.9
+++ parser/org/eclipse/cdt/core/parser/    21 Feb 2008 11:54:57 -0000
@@ -22,10 +22,14 @@
     public static final String __ALIGNOF__ = "__alignof__"; //$NON-NLS-1$
     public static final String __ATTRIBUTE__ = "__attribute__"; //$NON-NLS-1$
     public static final String __DECLSPEC = "__declspec"; //$NON-NLS-1$
+    public static final String __RESTRICT__ = "__restrict__"; //$NON-NLS-1$
+    public static final String __RESTRICT = "__restrict"; //$NON-NLS-1$
     public static final char [] cpTYPEOF = TYPEOF.toCharArray();
     public static final char [] cp__ALIGNOF__ = __ALIGNOF__.toCharArray();
     public static final char [] cp__ATTRIBUTE__ = __ATTRIBUTE__.toCharArray();
     public static final char [] cp__DECLSPEC = __DECLSPEC.toCharArray();
+    public static final char [] cp__RESTRICT__ = __RESTRICT__.toCharArray();
+    public static final char [] cp__RESTRICT = __RESTRICT.toCharArray();


2: Patch to class GCCScannerExtensionConfiguration

### Eclipse Workspace Patch 1.0
#P org.eclipse.cdt.core
Index: parser/org/eclipse/cdt/core/dom/parser/c/
RCS file: /cvsroot/tools/org.eclipse.cdt-releng/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/,v
retrieving revision 1.3
diff -u -r1.3
--- parser/org/eclipse/cdt/core/dom/parser/c/    21 Dec 2007 09:35:52 -0000    1.3
+++ parser/org/eclipse/cdt/core/dom/parser/c/    21 Feb 2008 11:56:49 -0000
@@ -54,6 +54,8 @@
         result.put( GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
         result.put( GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );
         result.put( GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec );
+        result.put( GCCKeywords.cp__RESTRICT__, IToken.t_restrict);
+        result.put( GCCKeywords.cp__RESTRICT, IToken.t_restrict);
         return result;



Tensilica India


From: "Schorn, Markus" <Markus.Schorn@xxxxxxxxxxxxx>
Subject: RE: [cdt-dev] Compiler supports keyword "__restrict__"
       instead ofkeyword "restrict"
To: "CDT General developers list." <cdt-dev@xxxxxxxxxxx>,
       <shaijup@xxxxxxxxxxxxx>, <pmac@xxxxxxxxxxxxx>
Content-Type: text/plain; charset="us-ascii"

This should work without the modification, the parser is configured with
an extra  macro definition:
-D__restrict__=restrict, see GNUScannerExtensionConfigurati



       From: cdt-dev-bounces@xxxxxxxxxxx
[mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Abeer Bagul
       Sent: Wednesday, February 20, 2008 6:17 AM
       To: cdt-dev@xxxxxxxxxxx; shaijup@xxxxxxxxxxxxx;
       Subject: [cdt-dev] Compiler supports keyword "__restrict__"
instead ofkeyword "restrict"
       Importance: Low

       Hi All,

       The file contains an
entry for the keyword "restrict". This keyword is supported by compilers
which implement the c99 standard. To use a compiler which does not
support the c99 standard, but supports GNU extensions to C, the C
programmer has to use the keyword "__restrict__" or "__restrict" to
achieve the same functionality.

       Currently, we have modified this java file to change the value
of the "restrict" keyword to "__restrict__".

       Is there any way apart from modifying this file to
let CDT know that the compiler supports "__restrict__" rather than


       Tensilica India

Back to the top