aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-05-04 01:26:46 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-05-04 01:26:46 +0000
commit14f78f4a11df4c06667e2cbb87eeb179e4cb46fe (patch)
tree392bceb2e768c1f45098628ec63adfabc953e358 /lib/Sema
parent15676bec6fa9ad9466d93c163f2d1b8a3f559b3a (diff)
Separate out and special-case the diagnostic for 'auto' in a
conversion-type-id, in preparation for this becoming valid in c++1y mode. No functionality change; small diagnostic improvement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaType.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 2503b49a61..4bf15f0360 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -2103,8 +2103,11 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
case Declarator::TrailingReturnContext:
Error = 11; // Function return type
break;
+ case Declarator::ConversionIdContext:
+ Error = 12; // conversion-type-id
+ break;
case Declarator::TypeNameContext:
- Error = 12; // Generic
+ Error = 13; // Generic
break;
case Declarator::FileContext:
case Declarator::BlockContext:
@@ -2140,15 +2143,19 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
}
}
+ SourceRange AutoRange = D.getDeclSpec().getTypeSpecTypeLoc();
+ if (D.getName().getKind() == UnqualifiedId::IK_ConversionFunctionId)
+ AutoRange = D.getName().getSourceRange();
+
if (Error != -1) {
- SemaRef.Diag(D.getDeclSpec().getTypeSpecTypeLoc(),
- diag::err_auto_not_allowed)
- << Error;
+ SemaRef.Diag(AutoRange.getBegin(), diag::err_auto_not_allowed)
+ << Error << AutoRange;
T = SemaRef.Context.IntTy;
D.setInvalidType(true);
} else
- SemaRef.Diag(D.getDeclSpec().getTypeSpecTypeLoc(),
- diag::warn_cxx98_compat_auto_type_specifier);
+ SemaRef.Diag(AutoRange.getBegin(),
+ diag::warn_cxx98_compat_auto_type_specifier)
+ << AutoRange;
}
if (SemaRef.getLangOpts().CPlusPlus &&
@@ -2180,6 +2187,7 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
D.setInvalidType(true);
break;
case Declarator::TypeNameContext:
+ case Declarator::ConversionIdContext:
case Declarator::TemplateParamContext:
case Declarator::CXXNewContext:
case Declarator::CXXCatchContext:
@@ -3092,6 +3100,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
case Declarator::ObjCCatchContext:
case Declarator::BlockLiteralContext:
case Declarator::LambdaExprContext:
+ case Declarator::ConversionIdContext:
case Declarator::TrailingReturnContext:
case Declarator::TemplateTypeArgContext:
// FIXME: We may want to allow parameter packs in block-literal contexts