Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 348018

Summary: [XLC++ Parser] restrict keyword in parameter results in parse error when restrict keyword is enabled
Product: [Tools] CDT Reporter: John Liu <jwsliu>
Component: cdt-parserAssignee: Project Inbox <cdt-parser-inbox>
Status: REOPENED --- QA Contact: Jonah Graham <jonah>
Severity: normal    
Priority: P3 CC: cdtdoug, mikekucera, yevshif
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description John Liu CLA 2011-06-01 16:52:30 EDT
In the following example I can't navigate from the call to matmul to the definition. The definition of matmul is not highlighted as a function in the editor.

If I remove the 'restrict' keywords from the parameters then it works. 

#define N 2500
typedef double matrix[N][N];

matrix A, B, C;

extern "C" inline double fma(double a1, double m1, double m2) {
   return a1 + m1 * m2 ;
}

extern "C" void matmul(matrix& restrict a, matrix& restrict b, matrix& restrict c) {
   for (int i=0; i < N; i++)
      for (int j=0; j < N; j++)
         for (int k=0; k < N; k++)
            c[i][j] += a[i][k]*b[k][j];
}

extern "C" void initialize(matrix mat, int seed, int mod) {
   for (int i=0; i < N; i++)
      for (int j=0; j < N; j++)
         mat[i][j] = (double)((seed + N*i + j) % mod);
}


int main(int argc, char* argv[]) {
   initialize(A, 5, 19);
//   cout << A[0][0] << endl;
   initialize(B, 7, 23);
//   cout << B[0][0] << endl;
   matmul(A, B, C);
//   cout << C[0][0] << endl;
}
Comment 1 Markus Schorn CLA 2011-06-06 05:42:23 EDT
There is a syntax error, 'restrict' is not a keyword in c++. The parser accepts the gnu-extension '__restrict'. In case your c++-compiler supports 'restrict' you can either provide a macro definition '-Drestrict=__restrict', or configure it as a keyword via an IScannerExtensionConfiguration.
Comment 2 Mike Kucera CLA 2011-06-08 10:28:32 EDT
I think this is still a bug against the XLC++ parser. 

The XLC++ compiler supports a command line option that turns on the 'restrict' keyword for C++. CDT supports this when you have the XLC++ parser installed, there is a preference page "XL C/C++ language options" that lets you turn on the restrict keyword for XLC++. However this doesn't seem to be working.

I've reopened the bug and refiled it against the XLC++ parser.

It might also be a good idea to test all the language options to see if they are working.