mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
C++, suppress some warnings that can never be fixed
This commit is contained in:
parent
82a465c3b6
commit
3231b84827
2
CHANGES
2
CHANGES
@ -53,6 +53,8 @@ Bugs fixed
|
|||||||
function overloads.
|
function overloads.
|
||||||
* #5078: C++, fix cross reference lookup when a directive contains multiple
|
* #5078: C++, fix cross reference lookup when a directive contains multiple
|
||||||
declarations.
|
declarations.
|
||||||
|
* C++, suppress warnings for directly dependent typenames in cross references
|
||||||
|
generated automatically in signatures.
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -4300,8 +4300,10 @@ class Symbol:
|
|||||||
|
|
||||||
def find_name(self, nestedName: ASTNestedName, templateDecls: List[Any],
|
def find_name(self, nestedName: ASTNestedName, templateDecls: List[Any],
|
||||||
typ: str, templateShorthand: bool, matchSelf: bool,
|
typ: str, templateShorthand: bool, matchSelf: bool,
|
||||||
recurseInAnon: bool, searchInSiblings: bool) -> List["Symbol"]:
|
recurseInAnon: bool, searchInSiblings: bool) -> Tuple[List["Symbol"], str]:
|
||||||
# templateShorthand: missing template parameter lists for templates is ok
|
# templateShorthand: missing template parameter lists for templates is ok
|
||||||
|
# If the first component is None,
|
||||||
|
# then the second component _may_ be a string explaining why.
|
||||||
if Symbol.debug_lookup:
|
if Symbol.debug_lookup:
|
||||||
Symbol.debug_indent += 1
|
Symbol.debug_indent += 1
|
||||||
Symbol.debug_print("find_name:")
|
Symbol.debug_print("find_name:")
|
||||||
@ -4316,6 +4318,9 @@ class Symbol:
|
|||||||
Symbol.debug_print("recurseInAnon: ", recurseInAnon)
|
Symbol.debug_print("recurseInAnon: ", recurseInAnon)
|
||||||
Symbol.debug_print("searchInSiblings: ", searchInSiblings)
|
Symbol.debug_print("searchInSiblings: ", searchInSiblings)
|
||||||
|
|
||||||
|
class QualifiedSymbolIsTemplateParam(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
def onMissingQualifiedSymbol(parentSymbol: "Symbol",
|
def onMissingQualifiedSymbol(parentSymbol: "Symbol",
|
||||||
identOrOp: Union[ASTIdentifier, ASTOperator],
|
identOrOp: Union[ASTIdentifier, ASTOperator],
|
||||||
templateParams: Any,
|
templateParams: Any,
|
||||||
@ -4324,28 +4329,39 @@ class Symbol:
|
|||||||
# Though, the correctPrimaryTemplateArgs does
|
# Though, the correctPrimaryTemplateArgs does
|
||||||
# that for primary templates.
|
# that for primary templates.
|
||||||
# Is there another case where it would be good?
|
# Is there another case where it would be good?
|
||||||
|
if parentSymbol.declaration is not None:
|
||||||
|
if parentSymbol.declaration.objectType == 'templateParam':
|
||||||
|
raise QualifiedSymbolIsTemplateParam()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
lookupResult = self._symbol_lookup(nestedName, templateDecls,
|
try:
|
||||||
onMissingQualifiedSymbol,
|
lookupResult = self._symbol_lookup(nestedName, templateDecls,
|
||||||
strictTemplateParamArgLists=False,
|
onMissingQualifiedSymbol,
|
||||||
ancestorLookupType=typ,
|
strictTemplateParamArgLists=False,
|
||||||
templateShorthand=templateShorthand,
|
ancestorLookupType=typ,
|
||||||
matchSelf=matchSelf,
|
templateShorthand=templateShorthand,
|
||||||
recurseInAnon=recurseInAnon,
|
matchSelf=matchSelf,
|
||||||
correctPrimaryTemplateArgs=False,
|
recurseInAnon=recurseInAnon,
|
||||||
searchInSiblings=searchInSiblings)
|
correctPrimaryTemplateArgs=False,
|
||||||
|
searchInSiblings=searchInSiblings)
|
||||||
|
except QualifiedSymbolIsTemplateParam:
|
||||||
|
return None, "templateParamInQualified"
|
||||||
|
|
||||||
if lookupResult is None:
|
if lookupResult is None:
|
||||||
# if it was a part of the qualification that could not be found
|
# if it was a part of the qualification that could not be found
|
||||||
if Symbol.debug_lookup:
|
if Symbol.debug_lookup:
|
||||||
Symbol.debug_indent -= 2
|
Symbol.debug_indent -= 2
|
||||||
return None
|
return None, None
|
||||||
|
|
||||||
res = list(lookupResult.symbols)
|
res = list(lookupResult.symbols)
|
||||||
if len(res) != 0:
|
if len(res) != 0:
|
||||||
if Symbol.debug_lookup:
|
if Symbol.debug_lookup:
|
||||||
Symbol.debug_indent -= 2
|
Symbol.debug_indent -= 2
|
||||||
return res
|
return res, None
|
||||||
|
|
||||||
|
if lookupResult.parentSymbol.declaration is not None:
|
||||||
|
if lookupResult.parentSymbol.declaration.objectType == 'templateParam':
|
||||||
|
return None, "templateParamInQualified"
|
||||||
|
|
||||||
# try without template params and args
|
# try without template params and args
|
||||||
symbol = lookupResult.parentSymbol._find_first_named_symbol(
|
symbol = lookupResult.parentSymbol._find_first_named_symbol(
|
||||||
@ -4355,9 +4371,9 @@ class Symbol:
|
|||||||
if Symbol.debug_lookup:
|
if Symbol.debug_lookup:
|
||||||
Symbol.debug_indent -= 2
|
Symbol.debug_indent -= 2
|
||||||
if symbol is not None:
|
if symbol is not None:
|
||||||
return [symbol]
|
return [symbol], None
|
||||||
else:
|
else:
|
||||||
return None
|
return None, None
|
||||||
|
|
||||||
def find_declaration(self, declaration: ASTDeclaration, typ: str, templateShorthand: bool,
|
def find_declaration(self, declaration: ASTDeclaration, typ: str, templateShorthand: bool,
|
||||||
matchSelf: bool, recurseInAnon: bool) -> "Symbol":
|
matchSelf: bool, recurseInAnon: bool) -> "Symbol":
|
||||||
@ -6778,12 +6794,13 @@ class AliasTransform(SphinxTransform):
|
|||||||
templateDecls = ns.templatePrefix.templates
|
templateDecls = ns.templatePrefix.templates
|
||||||
else:
|
else:
|
||||||
templateDecls = []
|
templateDecls = []
|
||||||
symbols = parentSymbol.find_name(nestedName=name,
|
symbols, failReason = parentSymbol.find_name(
|
||||||
templateDecls=templateDecls,
|
nestedName=name,
|
||||||
typ='any',
|
templateDecls=templateDecls,
|
||||||
templateShorthand=True,
|
typ='any',
|
||||||
matchSelf=True, recurseInAnon=True,
|
templateShorthand=True,
|
||||||
searchInSiblings=False)
|
matchSelf=True, recurseInAnon=True,
|
||||||
|
searchInSiblings=False)
|
||||||
if symbols is None:
|
if symbols is None:
|
||||||
symbols = []
|
symbols = []
|
||||||
else:
|
else:
|
||||||
@ -7089,12 +7106,21 @@ class CPPDomain(Domain):
|
|||||||
templateDecls = []
|
templateDecls = []
|
||||||
# let's be conservative with the sibling lookup for now
|
# let's be conservative with the sibling lookup for now
|
||||||
searchInSiblings = (not name.rooted) and len(name.names) == 1
|
searchInSiblings = (not name.rooted) and len(name.names) == 1
|
||||||
symbols = parentSymbol.find_name(name, templateDecls, typ,
|
symbols, failReason = parentSymbol.find_name(
|
||||||
templateShorthand=True,
|
name, templateDecls, typ,
|
||||||
matchSelf=True, recurseInAnon=True,
|
templateShorthand=True,
|
||||||
searchInSiblings=searchInSiblings)
|
matchSelf=True, recurseInAnon=True,
|
||||||
# just refer to the arbitrarily first symbol
|
searchInSiblings=searchInSiblings)
|
||||||
s = None if symbols is None else symbols[0]
|
if symbols is None:
|
||||||
|
if typ == 'identifier':
|
||||||
|
if failReason == 'templateParamInQualified':
|
||||||
|
# this is an xref we created as part of a signature,
|
||||||
|
# so don't warn for names nested in template parameters
|
||||||
|
raise NoUri(str(name), typ)
|
||||||
|
s = None
|
||||||
|
else:
|
||||||
|
# just refer to the arbitrarily first symbol
|
||||||
|
s = symbols[0]
|
||||||
else:
|
else:
|
||||||
decl = ast # type: ASTDeclaration
|
decl = ast # type: ASTDeclaration
|
||||||
name = decl.name
|
name = decl.name
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
.. default-domain:: cpp
|
||||||
|
|
||||||
|
.. class:: template<typename T> A
|
||||||
|
|
||||||
|
.. type:: N1 = T::typeOk
|
||||||
|
|
||||||
|
- Not ok, warn: :type:`T::typeWarn`
|
||||||
|
|
||||||
|
.. type:: N2 = T::U::typeOk
|
||||||
|
|
||||||
|
- Not ok, warn: :type:`T::U::typeWarn`
|
@ -806,6 +806,15 @@ def test_build_domain_cpp_multi_decl_lookup(app, status, warning):
|
|||||||
assert len(ws) == 0
|
assert len(ws) == 0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.sphinx(testroot='domain-cpp', confoverrides={'nitpicky': True})
|
||||||
|
def test_build_domain_cpp_warn_template_param_qualified_name(app, status, warning):
|
||||||
|
app.builder.build_all()
|
||||||
|
ws = filter_warnings(warning, "warn-template-param-qualified-name")
|
||||||
|
assert len(ws) == 2
|
||||||
|
assert "WARNING: cpp:type reference target not found: T::typeWarn" in ws[0]
|
||||||
|
assert "WARNING: cpp:type reference target not found: T::U::typeWarn" in ws[1]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(testroot='domain-cpp')
|
@pytest.mark.sphinx(testroot='domain-cpp')
|
||||||
def test_build_domain_cpp_misuse_of_roles(app, status, warning):
|
def test_build_domain_cpp_misuse_of_roles(app, status, warning):
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
|
Loading…
Reference in New Issue
Block a user