Skip to content

Commit

Permalink
CPP14.g4 bugfix - relational ops in template arguments
Browse files Browse the repository at this point in the history
Consider the signature
void TestFunc(vector< ClassA > args, vector < ClassB > args2)

Right now this is parsed as 
- a declaration of a variable args2 
- the type of args2 is vector <A, B> 
    where A = (ClassA > args) 
               B = (vector < B) 
   i.e. a a template instantiation that has two relational expressions that are the arguments

This stems from the priority order of the template argument list which is 
templateargument : constantexpression | typeid | idexpression;

Changing the order to : typeid | constantexpression| idexpression; fixes this.

Tested that this is the same behavior as observed in Microsoft c++ compiler, gcc, clang and icc.
  • Loading branch information
shravanrn authored Nov 12, 2016
1 parent 1099b73 commit 77c6970
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cpp/CPP14.g4
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,8 @@ templateargumentlist

templateargument
:
constantexpression
| typeid
typeid
| constantexpression
| idexpression
;

Expand Down

0 comments on commit 77c6970

Please sign in to comment.