From: Richard Smith Date: Sun, 10 May 2020 20:39:23 +0000 (-0700) Subject: Fix typo in enum-base disambiguation. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d3f5a62de8e5d2cc25aaa49d0a00d31ed32544a;p=platform%2Fupstream%2Fllvm.git Fix typo in enum-base disambiguation. --- diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp index fd868b8..ff941cf 100644 --- a/clang/lib/Parse/ParseTentative.cpp +++ b/clang/lib/Parse/ParseTentative.cpp @@ -450,7 +450,7 @@ bool Parser::isEnumBase(bool AllowSemi) { // If we get to the end of the enum-base, we hit either a '{' or a ';'. // Don't bother checking the enumerator-list. - if (Tok.is(tok::colon) || (AllowSemi && Tok.is(tok::semi))) + if (Tok.is(tok::l_brace) || (AllowSemi && Tok.is(tok::semi))) return true; // A second decl-specifier unambiguously indicatges an enum-base. diff --git a/clang/test/Parser/cxx0x-ambig.cpp b/clang/test/Parser/cxx0x-ambig.cpp index b4f066b..2dd53dd 100644 --- a/clang/test/Parser/cxx0x-ambig.cpp +++ b/clang/test/Parser/cxx0x-ambig.cpp @@ -86,6 +86,8 @@ namespace bitfield { // be ill-formed. It cannot be an elaborated-type-specifier. struct S { enum : undeclared_type { v = 0 }; // expected-error {{unknown type name 'undeclared_type'}} + enum E : undeclared_type { w = 0 }; // expected-error {{unknown type name 'undeclared_type'}} + enum X : undeclared_type { x = 0 }; // expected-error {{unknown type name 'undeclared_type'}} }; } diff --git a/clang/test/Parser/cxx98-enum.cpp b/clang/test/Parser/cxx98-enum.cpp new file mode 100644 index 0000000..ed85ade --- /dev/null +++ b/clang/test/Parser/cxx98-enum.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -std=c++98 -verify %s + +enum E {}; +enum F {}; + +struct A { + // OK, this is an enumeration bit-field. + enum E : int(0); + enum F : int{0}; // expected-error {{expected '(' for function-style cast}} +}; diff --git a/clang/test/Parser/objcxx-enum.mm b/clang/test/Parser/objcxx-enum.mm new file mode 100644 index 0000000..2d68aa0 --- /dev/null +++ b/clang/test/Parser/objcxx-enum.mm @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -verify -std=c++98 %s +// expected-no-diagnostics + +// Objective-C allows C++11 enumerations in C++98 mode. We disambiguate in +// order to make this a backwards-compatible extension. +struct A { + enum E : int{a}; // OK, enum definition + enum E : int(a); // OK, bit-field declaration +}; +_Static_assert(A::a == 0, "");