Uploaded image for project: 'SonarCFamily'
  1. SonarCFamily
  2. CPP-1421

Fix resolution of ambiguities according to CPP14 8.2p1 and 8.2p7

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.6
    • Fix Version/s: 3.11
    • Component/s: Semantic Analysis
    • Labels:
      None

      Description

      The following cpp snippet:

      template<typename T>
      struct S {
        T v;
      };
      void func(S<S<int> > arg);
      

      Provides a syntax tree with GREATER_THAN and LESS_THAN instead of TEMPLATE_ARGUMENT_... for "void func(...":

          [1] = SIMPLE_DECLARATION @77307458 line:8 
            attributes = []
            typeSpecifier = @1fc0053e [
              [0] = TYPE_SPECIFIER_SIMPLE @290b1b2e 
            ]
            initDeclarators = @47874b25 [
              [0] = DECLARATOR_INIT @33617539 symbol:func@2c177f9e owner:5db4c359 
                attributes = []
                declarator? = DECLARATOR_ID @209775a9 
                  name = ID @18e7143f binding:2c177f9e <null> 
                    identifierToken = TOKEN_IDENTIFIER @f9b7332 func
                  attributes = []
                virtSpecifiers = []
                initializer? = COMPOUND_INITIALIZER @74cec793 <not found> 
                  clauses = @6fefce9e [
                    [0] = GREATER_THAN @4f8969b0 <not found> 
                      leftOperand = LESS_THAN @1bdf8190 <not found> 
                        leftOperand = ID @192f2f27 <not found> 
                          identifierToken = TOKEN_IDENTIFIER @8a589a2 S
                        rightOperand = TEMPLATE_ID @c65a5ef <null> 
                          name = ID @6b5176f2 <null> 
                            identifierToken = TOKEN_IDENTIFIER @b672aa8 S
                          arguments = @2fab4aff [
                            [0] = TEMPLATE_ARGUMENT_TYPE @ec0c838 
                              type = TYPE_ID @6e46d9f4 <null> 
                                attributes = []
                                typeSpecifier = @5cc69cfe [
                                  [0] = TYPE_SPECIFIER_SIMPLE @29cfd92b 
                                ]
                                initDeclarator = DECLARATOR_INIT @21c64522 line:-1 
                                  attributes = []
                                  virtSpecifiers = []
                          ]
                      rightOperand = ID @7997b197 line:8 <not found> 
                        identifierToken = TOKEN_IDENTIFIER @11dee337 arg
                  ]
            ]
      

      And surprising, by replacing "> >" by ">>", the result become AMBIGUOUS:

      template<typename T>
      struct S {
        T v;
      };
      void func(S<S<int>> arg);
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              evgeny.mandrikov Evgeny Mandrikov
              Reporter:
              alban.auzeill Alban Auzeill
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: