summaryrefslogtreecommitdiffstats
path: root/clang/include
diff options
context:
space:
mode:
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/Basic/DiagnosticParseKinds.td13
-rw-r--r--clang/include/clang/Parse/Parser.h15
2 files changed, 24 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index cc6a74ac3e6..41f788e7d9b 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -33,10 +33,6 @@ def err_asm_goto_cannot_have_output : Error<
let CategoryName = "Parse Issue" in {
-def warn_cxx2a_compat_explicit_bool : Warning<
- "this expression will be parsed as explicit(bool) in C++2a">,
- InGroup<CXX2aCompat>, DefaultIgnore;
-
def ext_empty_translation_unit : Extension<
"ISO C requires a translation unit to contain at least one declaration">,
InGroup<DiagGroup<"empty-translation-unit">>;
@@ -684,6 +680,15 @@ def err_ms_property_expected_comma_or_rparen : Error<
def err_ms_property_initializer : Error<
"property declaration cannot have an in-class initializer">;
+def warn_cxx2a_compat_explicit_bool : Warning<
+ "this expression will be parsed as explicit(bool) in C++2a">,
+ InGroup<CXX2aCompat>, DefaultIgnore;
+def warn_cxx17_compat_explicit_bool : Warning<
+ "explicit(bool) is incompatible with C++ standards before C++2a">,
+ InGroup<CXXPre2aCompat>, DefaultIgnore;
+def ext_explicit_bool : ExtWarn<"explicit(bool) is a C++2a extension">,
+ InGroup<CXX2a>;
+
/// C++ Templates
def err_expected_template : Error<"expected template">;
def err_unknown_template_name : Error<
diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h
index e320c964781..b7bed471399 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -806,6 +806,16 @@ public:
bool IsNewScope);
bool TryAnnotateCXXScopeToken(bool EnteringContext = false);
+ bool MightBeCXXScopeToken() {
+ return Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
+ (Tok.is(tok::annot_template_id) &&
+ NextToken().is(tok::coloncolon)) ||
+ Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super);
+ }
+ bool TryAnnotateOptionalCXXScopeToken(bool EnteringContext = false) {
+ return MightBeCXXScopeToken() && TryAnnotateCXXScopeToken(EnteringContext);
+ }
+
private:
enum AnnotatedNameKind {
/// Annotation has failed and emitted an error.
@@ -2395,6 +2405,11 @@ private:
/// rather than a less-than expression.
TPResult isTemplateArgumentList(unsigned TokensToSkip);
+ /// Determine whether an '(' after an 'explicit' keyword is part of a C++20
+ /// 'explicit(bool)' declaration, in earlier language modes where that is an
+ /// extension.
+ TPResult isExplicitBool();
+
/// Determine whether an identifier has been tentatively declared as a
/// non-type. Such tentative declarations should not be found to name a type
/// during a tentative parse, but also should not be annotated as a non-type.
OpenPOWER on IntegriCloud