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"

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/GCCKeywords.java
===================================================================
RCS file: /cvsroot/tools/org.eclipse.cdt-releng/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java,v
retrieving revision 1.9
diff -u -r1.9 GCCKeywords.java
--- parser/org/eclipse/cdt/core/parser/GCCKeywords.java    14 Jun 2007 18:04:00 -0000    1.9
+++ parser/org/eclipse/cdt/core/parser/GCCKeywords.java    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/GCCScannerExtensionConfiguration.java
===================================================================
RCS file: /cvsroot/tools/org.eclipse.cdt-releng/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java,v
retrieving revision 1.3
diff -u -r1.3 GCCScannerExtensionConfiguration.java
--- parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java    21 Dec 2007 09:35:52 -0000    1.3
+++ parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java    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;
     }
 

---------------------------------------------------------

Thanks,

Abeer
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>
Message-ID:
       <460801A4097E3D4CA04CC64EE6485848048B169E@xxxxxxxxxxxxxxxxxxxxxxxxxx>
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
on.java

Markus.


________________________________

       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;
pmac@xxxxxxxxxxxxx
       Subject: [cdt-dev] Compiler supports keyword "__restrict__"
instead ofkeyword "restrict"
       Importance: Low


       Hi All,

       The file org.eclipse.cdt.core.parser.Keywords.java 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 Keywords.java file to
let CDT know that the compiler supports "__restrict__" rather than
"restrict"?

       Thanks
       Abeer

       Tensilica India

Back to the top