"|in non-static union member|in non-static class member|in interface member"
"|in exception declaration|in template parameter|in block literal"
"|in template argument|in typedef|in type alias|in function return type"
- "|here}0">;
+ "|in conversion function type|here}0">;
def err_auto_var_requires_init : Error<
"declaration of variable %0 with type %1 requires an initializer">;
def err_auto_new_requires_ctor_arg : Error<
CXXNewContext, // C++ new-expression.
CXXCatchContext, // C++ catch exception-declaration
ObjCCatchContext, // Objective-C catch exception-declaration
- BlockLiteralContext, // Block literal declarator.
+ BlockLiteralContext, // Block literal declarator.
LambdaExprContext, // Lambda-expression declarator.
+ ConversionIdContext, // C++ conversion-type-id.
TrailingReturnContext, // C++11 trailing-type-specifier.
TemplateTypeArgContext, // Template type argument.
AliasDeclContext, // C++11 alias-declaration.
case ObjCCatchContext:
case BlockLiteralContext:
case LambdaExprContext:
+ case ConversionIdContext:
case TemplateTypeArgContext:
case TrailingReturnContext:
return true;
case ObjCResultContext:
case BlockLiteralContext:
case LambdaExprContext:
+ case ConversionIdContext:
case TemplateTypeArgContext:
case TrailingReturnContext:
return false;
case AliasTemplateContext:
case BlockLiteralContext:
case LambdaExprContext:
+ case ConversionIdContext:
case TemplateTypeArgContext:
case TrailingReturnContext:
return false;
case ObjCCatchContext:
case BlockLiteralContext:
case LambdaExprContext:
+ case ConversionIdContext:
case TemplateTypeArgContext:
case TrailingReturnContext:
return false;
// Parse the conversion-declarator, which is merely a sequence of
// ptr-operators.
- Declarator D(DS, Declarator::TypeNameContext);
+ Declarator D(DS, Declarator::ConversionIdContext);
ParseDeclaratorInternal(D, /*DirectDeclParser=*/0);
// Finish up the type.
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:
}
}
+ 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 &&
D.setInvalidType(true);
break;
case Declarator::TypeNameContext:
+ case Declarator::ConversionIdContext:
case Declarator::TemplateParamContext:
case Declarator::CXXNewContext:
case Declarator::CXXCatchContext:
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
// Note, this is not permitted: conversion-declarator cannot have a trailing return type.
// FIXME: don't issue the second diagnostic for this.
- operator auto(*)()->int(); // expected-error{{'auto' not allowed here}} expected-error {{C++ requires a type specifier}}
+ operator auto(*)()->int(); // expected-error{{'auto' not allowed in conversion function type}} expected-error {{C++ requires a type specifier}}
};
typedef auto Fun(int a) -> decltype(a + a);
friend auto; // expected-error{{'auto' not allowed in non-static struct member}}
- operator auto(); // expected-error{{'auto' not allowed here}}
+ operator auto(); // expected-error{{'auto' not allowed in conversion function type}}
};
// PR 9278: auto is not allowed in typedefs, except with a trailing return type.