Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception ambiguous node while parsing boost::variant header #28

Open
PeterSommerlad opened this issue Jul 11, 2019 · 0 comments
Open
Labels
bug Something isn't working

Comments

@PeterSommerlad
Copy link

Expected Behavior

parsing succeeds...

//-----------------------------------------------------------------------------
// boost variant/detail/apply_visitor_binary.hpp header file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2002-2003 Eric Friedman
// Copyright (c) 2014-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_VARIANT_DETAIL_APPLY_VISITOR_BINARY_HPP
#define BOOST_VARIANT_DETAIL_APPLY_VISITOR_BINARY_HPP

#include <boost/config.hpp>

#include <boost/variant/detail/apply_visitor_unary.hpp>

#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
#   include <boost/variant/detail/has_result_type.hpp>
#endif

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
#   include <boost/core/enable_if.hpp>
#   include <boost/type_traits/is_lvalue_reference.hpp>
#   include <boost/type_traits/is_same.hpp>
#   include <boost/move/move.hpp>
#   include <boost/move/utility.hpp>
#endif

namespace boost {

//////////////////////////////////////////////////////////////////////////
// function template apply_visitor(visitor, visitable1, visitable2)
//
// Visits visitable1 and visitable2 such that their values (which we
// shall call x and y, respectively) are used as arguments in the
// expression visitor(x, y).
//

namespace detail { namespace variant {

template <typename Visitor, typename Value1, bool MoveSemantics>
class apply_visitor_binary_invoke
{
public: // visitor typedefs

    typedef typename Visitor::result_type
        result_type;

private: // representation

    Visitor& visitor_;
    Value1& value1_;

public: // structors

    apply_visitor_binary_invoke(Visitor& visitor, Value1& value1) BOOST_NOEXCEPT
        : visitor_(visitor)
        , value1_(value1)
    {
    }

public: // visitor interfaces

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES

    template <typename Value2>
        typename enable_if_c<MoveSemantics && is_same<Value2, Value2>::value, result_type>::type
    operator()(Value2&& value2)
    {
        return visitor_(::boost::move(value1_), ::boost::forward<Value2>(value2));
    }

    template <typename Value2>
        typename disable_if_c<MoveSemantics && is_same<Value2, Value2>::value, result_type>::type
    operator()(Value2&& value2)
    {
        return visitor_(value1_, ::boost::forward<Value2>(value2));
    }

#else

    template <typename Value2>
        result_type
    operator()(Value2& value2)
    {
        return visitor_(value1_, value2);
    }

#endif

private:
    apply_visitor_binary_invoke& operator=(const apply_visitor_binary_invoke&);
};

template <typename Visitor, typename Visitable2, bool MoveSemantics>
class apply_visitor_binary_unwrap
{
public: // visitor typedefs

    typedef typename Visitor::result_type
        result_type;

private: // representation

    Visitor& visitor_;
    Visitable2& visitable2_;

public: // structors

    apply_visitor_binary_unwrap(Visitor& visitor, Visitable2& visitable2) BOOST_NOEXCEPT
        : visitor_(visitor)
        , visitable2_(visitable2)
    {
    }

public: // visitor interfaces

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES

    template <typename Value1>
        typename enable_if_c<MoveSemantics && is_same<Value1, Value1>::value, result_type>::type
    operator()(Value1&& value1)
    {
        apply_visitor_binary_invoke<
              Visitor
            , Value1
            , ! ::boost::is_lvalue_reference<Value1>::value
            > invoker(visitor_, value1);

        return boost::apply_visitor(invoker, ::boost::move(visitable2_));
    }

    template <typename Value1>
        typename disable_if_c<MoveSemantics && is_same<Value1, Value1>::value, result_type>::type
    operator()(Value1&& value1)
    {
        apply_visitor_binary_invoke<
              Visitor
            , Value1
            , ! ::boost::is_lvalue_reference<Value1>::value
            > invoker(visitor_, value1);

        return boost::apply_visitor(invoker, visitable2_);
    }

#else

    template <typename Value1>
        result_type
    operator()(Value1& value1)
    {
        apply_visitor_binary_invoke<
              Visitor
            , Value1
            , false
            > invoker(visitor_, value1);

        return boost::apply_visitor(invoker, visitable2_);
    }

#endif

private:
    apply_visitor_binary_unwrap& operator=(const apply_visitor_binary_unwrap&);

};

}} // namespace detail::variant

//
// nonconst-visitor version:
//

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES

template <typename Visitor, typename Visitable1, typename Visitable2>
inline typename Visitor::result_type
apply_visitor( Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2)
{
    ::boost::detail::variant::apply_visitor_binary_unwrap<
          Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
        > unwrapper(visitor, visitable2);

    return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
}

#else

template <typename Visitor, typename Visitable1, typename Visitable2>
inline typename Visitor::result_type
apply_visitor( Visitor& visitor, Visitable1& visitable1, Visitable2& visitable2)
{
    ::boost::detail::variant::apply_visitor_binary_unwrap<
          Visitor, Visitable2, false
        > unwrapper(visitor, visitable2);

    return boost::apply_visitor(unwrapper, visitable1);
}

#endif

//
// const-visitor version:
//

#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES

template <typename Visitor, typename Visitable1, typename Visitable2>
inline typename Visitor::result_type
apply_visitor( const Visitor& visitor , Visitable1&& visitable1 , Visitable2&& visitable2)
{
    ::boost::detail::variant::apply_visitor_binary_unwrap<
          const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
        > unwrapper(visitor, visitable2);

    return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
}

#else

template <typename Visitor, typename Visitable1, typename Visitable2>
inline typename Visitor::result_type
apply_visitor( const Visitor& visitor , Visitable1& visitable1 , Visitable2& visitable2)
{
    ::boost::detail::variant::apply_visitor_binary_unwrap<
          const Visitor, Visitable2, false
        > unwrapper(visitor, visitable2);

    return boost::apply_visitor(unwrapper, visitable1);
}

#endif


#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)

//////////////////////////////////////////////////////////////////////////
// function template apply_visitor(visitor, visitable1, visitable2)
//
// C++14 part.
//

namespace detail { namespace variant {

template <typename Visitor, typename Value1, bool MoveSemantics>
class apply_visitor_binary_invoke_cpp14
{
    Visitor& visitor_;
    Value1& value1_;

public: // structors

    apply_visitor_binary_invoke_cpp14(Visitor& visitor, Value1& value1) BOOST_NOEXCEPT
        : visitor_(visitor)
        , value1_(value1)
    {
    }

public: // visitor interfaces

    template <typename Value2>
    decltype(auto) operator()(Value2&& value2, typename enable_if_c<MoveSemantics && is_same<Value2, Value2>::value>::type* = 0)
    {
        return visitor_(::boost::move(value1_), ::boost::forward<Value2>(value2));
    }

    template <typename Value2>
    decltype(auto) operator()(Value2&& value2, typename disable_if_c<MoveSemantics && is_same<Value2, Value2>::value>::type* = 0)
    {
        return visitor_(value1_, ::boost::forward<Value2>(value2));
    }

private:
    apply_visitor_binary_invoke_cpp14& operator=(const apply_visitor_binary_invoke_cpp14&);
};

template <typename Visitor, typename Visitable2, bool MoveSemantics>
class apply_visitor_binary_unwrap_cpp14
{
    Visitor& visitor_;
    Visitable2& visitable2_;

public: // structors

    apply_visitor_binary_unwrap_cpp14(Visitor& visitor, Visitable2& visitable2) BOOST_NOEXCEPT
        : visitor_(visitor)
        , visitable2_(visitable2)
    {
    }

public: // visitor interfaces

    template <typename Value1>
    decltype(auto) operator()(Value1&& value1, typename enable_if_c<MoveSemantics && is_same<Value1, Value1>::value>::type* = 0)
    {
        apply_visitor_binary_invoke_cpp14<
              Visitor
            , Value1
            , ! ::boost::is_lvalue_reference<Value1>::value
            > invoker(visitor_, value1);

        return boost::apply_visitor(invoker, ::boost::move(visitable2_));
    }

    template <typename Value1>
    decltype(auto) operator()(Value1&& value1, typename disable_if_c<MoveSemantics && is_same<Value1, Value1>::value>::type* = 0)
    {
        apply_visitor_binary_invoke_cpp14<
              Visitor
            , Value1
            , ! ::boost::is_lvalue_reference<Value1>::value
            > invoker(visitor_, value1);

        return boost::apply_visitor(invoker, visitable2_);
    }

private:
    apply_visitor_binary_unwrap_cpp14& operator=(const apply_visitor_binary_unwrap_cpp14&);
};

}} // namespace detail::variant

template <typename Visitor, typename Visitable1, typename Visitable2>
inline decltype(auto) apply_visitor(Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2,
    typename boost::disable_if<
        boost::detail::variant::has_result_type<Visitor>
    >::type* = 0)
{
    ::boost::detail::variant::apply_visitor_binary_unwrap_cpp14<
          Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
        > unwrapper(visitor, visitable2);

    return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
}

template <typename Visitor, typename Visitable1, typename Visitable2>
inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2,
    typename boost::disable_if<
        boost::detail::variant::has_result_type<Visitor>
    >::type* = 0)
{
    ::boost::detail::variant::apply_visitor_binary_unwrap_cpp14<
          const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
        > unwrapper(visitor, visitable2);

    return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
}


#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)

} // namespace boost

#endif // BOOST_VARIANT_DETAIL_APPLY_VISITOR_BINARY_HPP

Actual Behavior

eclipse.buildId=unknown
java.version=9.0.4
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_CH
Framework arguments:  -keyring /Users/sop/.eclipse_keyring
Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -keyring /Users/sop/.eclipse_keyring

org.eclipse.cdt.core
Error
Thu Jul 11 10:21:35 CEST 2019
Error: Encountered an ambiguous node "::boost::forward<Visitable1>(visitable1)" at /usr/local/include/boost/variant/detail/apply_visitor_binary.hpp, line 349 while parsing /usr/local/include/boost/variant/detail/apply_visitor_binary.hpp

org.eclipse.cdt.internal.core.parser.ParserException: Encountered an ambiguous node "::boost::forward<Visitable1>(visitable1)" at /usr/local/include/boost/variant/detail/apply_visitor_binary.hpp, line 349 while parsing /usr/local/include/boost/variant/detail/apply_visitor_binary.hpp
	at org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode.logAmbiguousNodeError(ASTAmbiguousNode.java:191)
	at org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode.getEvaluation(ASTAmbiguousNode.java:181)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionCallExpression.checkForExplicitTypeConversion(CPPASTFunctionCallExpression.java:329)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionCallExpression.computeEvaluation(CPPASTFunctionCallExpression.java:304)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionCallExpression.getEvaluation(CPPASTFunctionCallExpression.java:295)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor$ReturnTypeDeducer.onReturnStatement(CPPVisitor.java:2416)
	at org.eclipse.cdt.core.dom.ast.util.ReturnStatementVisitor.visit(ReturnStatementVisitor.java:73)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReturnStatement.accept(CPPASTReturnStatement.java:79)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement.accept(CPPASTCompoundStatement.java:103)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.deduceReturnType(CPPVisitor.java:2469)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.createAutoFunctionType(CPPVisitor.java:2536)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.createAutoType(CPPVisitor.java:2250)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.createType(CPPVisitor.java:2141)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.createType(CPPVisitor.java:2109)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.resolveFunctionDeclaration(CPPSemantics.java:2890)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.resolveFunction(CPPSemantics.java:2667)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.resolveAmbiguities(CPPSemantics.java:2381)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.resolveAmbiguities(CPPSemantics.java:2032)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScope.getBinding(CPPScope.java:132)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScope.getBinding(CPPScope.java:401)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.createBinding(CPPVisitor.java:855)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.createBinding(CPPVisitor.java:326)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName.createIntermediateBinding(CPPASTName.java:67)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase.resolveBinding(CPPASTNameBase.java:111)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPDependentEvaluation$DeferredResolutionBinding.resolve(CPPDependentEvaluation.java:180)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPDependentEvaluation.getTemplateDefinition(CPPDependentEvaluation.java:52)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPDependentEvaluation.getTemplateDefinitionScope(CPPDependentEvaluation.java:59)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary.computeOverload(EvalBinary.java:337)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary.getOverload(EvalBinary.java:318)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary.getValue(EvalBinary.java:182)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument.<init>(CPPTemplateNonTypeArgument.java:40)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.createTemplateArgumentArray(CPPTemplates.java:2306)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.createBinding(CPPTemplates.java:805)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateId.createIntermediateBinding(CPPASTTemplateId.java:126)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase.resolvePreBinding(CPPASTNameBase.java:98)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.getContainingScopeOrNull(CPPVisitor.java:1300)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.getContainingScope(CPPVisitor.java:1259)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.getLookupScope(CPPSemantics.java:952)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.lookup(CPPSemantics.java:1064)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.resolveBinding(CPPSemantics.java:356)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.createBinding(CPPVisitor.java:297)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName.createIntermediateBinding(CPPASTName.java:67)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase.resolvePreBinding(CPPASTNameBase.java:98)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName.resolvePreBinding(CPPASTQualifiedName.java:105)
	at org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode.doResolveAmbiguity(ASTAmbiguousNode.java:130)
	at org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode.resolveAmbiguity(ASTAmbiguousNode.java:87)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAmbiguityResolver.visit(CPPASTAmbiguityResolver.java:87)
	at org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode.accept(ASTAmbiguousNode.java:70)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement.accept(CPPASTCompoundStatement.java:103)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition.accept(CPPASTFunctionDefinition.java:225)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAmbiguityResolver.visit(CPPASTAmbiguityResolver.java:181)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition.accept(CPPASTFunctionDefinition.java:191)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateDeclaration.accept(CPPASTTemplateDeclaration.java:131)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamespaceDefinition.accept(CPPASTNamespaceDefinition.java:144)
	at org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit.accept(ASTTranslationUnit.java:289)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit.resolveAmbiguities(CPPASTTranslationUnit.java:245)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.resolveAmbiguities(AbstractGNUSourceCodeParser.java:705)
	at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.parse(AbstractGNUSourceCodeParser.java:688)
	at org.eclipse.cdt.core.dom.parser.AbstractCLikeLanguage.getASTTranslationUnit(AbstractCLikeLanguage.java:171)
	at org.eclipse.cdt.internal.core.model.TranslationUnit.getAST(TranslationUnit.java:886)
	at org.eclipse.cdt.internal.core.model.CModelBuilder2.parse(CModelBuilder2.java:152)
	at org.eclipse.cdt.internal.core.model.TranslationUnit.parseUsingCModelBuilder(TranslationUnit.java:683)
	at org.eclipse.cdt.internal.core.model.TranslationUnit.parse(TranslationUnit.java:670)
	at org.eclipse.cdt.internal.core.model.TranslationUnit.buildStructure(TranslationUnit.java:469)
	at org.eclipse.cdt.internal.core.model.Openable.generateInfos(Openable.java:264)
	at org.eclipse.cdt.internal.core.model.CElement.openWhenClosed(CElement.java:429)
	at org.eclipse.cdt.internal.core.model.TranslationUnit.makeConsistent(TranslationUnit.java:573)
	at org.eclipse.cdt.internal.core.model.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:65)
	at org.eclipse.cdt.internal.core.model.CModelOperation.execute(CModelOperation.java:346)
	at org.eclipse.cdt.internal.core.model.CModelOperation.run(CModelOperation.java:613)
	at org.eclipse.cdt.internal.core.model.CModelOperation.runOperation(CModelOperation.java:641)
	at org.eclipse.cdt.internal.core.model.WorkingCopy.reconcile(WorkingCopy.java:365)
	at org.eclipse.cdt.internal.ui.text.CReconcilingStrategy.reconcile(CReconcilingStrategy.java:79)
	at org.eclipse.cdt.internal.ui.text.CReconcilingStrategy.reconcile(CReconcilingStrategy.java:64)
	at org.eclipse.cdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:89)
	at org.eclipse.cdt.internal.ui.text.CCompositeReconcilingStrategy.reconcile(CCompositeReconcilingStrategy.java:95)
	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:76)
	at org.eclipse.cdt.internal.ui.text.CReconciler.process(CReconciler.java:351)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:210)

Cevelop Version, Operating System and Compiler

Cevelop C++ IDE

Version: 1.12.1-201907081203

macos mojave.

@fmorgner fmorgner transferred this issue from Cevelop/Issues Feb 23, 2021
@fmorgner fmorgner added the bug Something isn't working label Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants