Author: Shengxin Pei Date: 2026-10-04T13:46:42Z New Revision: 5f9b69e99d5f1949273c3bf407b631072a15cac4
URL: https://github.com/llvm/llvm-project/commit/5f9b69e99d5f1949273c3bf407b631072a15cac4 DIFF: https://github.com/llvm/llvm-project/commit/5f9b69e99d5f1949273c3bf407b631072a15cac4.diff LOG: [clang][test] Combine and clean up decltype parser tests NFC (#228889) Follow-up #211221 Added: Modified: clang/test/Parser/decltype-crash.cpp Removed: clang/test/Parser/decltype-gh188014.cpp clang/test/Parser/gh114815.cpp ################################################################################ diff --git a/clang/test/Parser/decltype-crash.cpp b/clang/test/Parser/decltype-crash.cpp index 8471309665f1d..9f22baef698d5 100644 --- a/clang/test/Parser/decltype-crash.cpp +++ b/clang/test/Parser/decltype-crash.cpp @@ -1,20 +1,27 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s -// A 'decltype' that is not followed by '(' fails to parse as a -// decltype-specifier. ParseOptionalCXXScopeSpecifier used to still annotate it -// and treat it as a nested-name-specifier, which tripped an assertion in -// Preprocessor::AnnotatePreviousCachedTokens. It should just diagnose the -// error instead. -int decltype = 0; -// expected-error@-1 {{expected '(' after 'decltype'}} -// expected-error@-2 {{expected unqualified-id}} +namespace GH114815{ + #define ID(X) X + extern int ID(decltype); + // expected-error@-1 {{expected '(' after 'decltype'}} + // expected-error@-2 {{expected unqualified-id}} +} -int *decltype = 0; -// expected-error@-1 {{expected '(' after 'decltype'}} -// expected-error@-2 {{expected unqualified-id}} +namespace GH165246 { + int decltype {}; + // expected-error@-1 {{expected '(' after 'decltype'}} + // expected-error@-2 {{expected unqualified-id}} +} -// GH165246 -int decltype {}; -// expected-error@-1 {{expected '(' after 'decltype'}} -// expected-error@-2 {{expected unqualified-id}} +namespace GH211207 { + int decltype = 0; + // expected-error@-1 {{expected '(' after 'decltype'}} + // expected-error@-2 {{expected unqualified-id}} + + int *decltype = 0; + // expected-error@-1 {{expected '(' after 'decltype'}} + // expected-error@-2 {{expected unqualified-id}} +} + +// GH188014 +& decltype ( ( union { // expected-error {{expected ';' after union}} expected-error {{expected '}'}} expected-error {{expected ')'}} expected-error {{expected expression}} expected-error {{expected unqualified-id}} expected-note {{to match this '('}} expected-note {{to match this '{'}} diff --git a/clang/test/Parser/decltype-gh188014.cpp b/clang/test/Parser/decltype-gh188014.cpp deleted file mode 100644 index e8403bdcbe3bb..0000000000000 --- a/clang/test/Parser/decltype-gh188014.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// GH188014 -& decltype ( ( union { // expected-error {{expected ';' after union}} expected-error {{expected '}'}} expected-error {{expected ')'}} expected-error {{expected expression}} expected-error {{expected unqualified-id}} expected-note {{to match this '('}} expected-note {{to match this '{'}} diff --git a/clang/test/Parser/gh114815.cpp b/clang/test/Parser/gh114815.cpp deleted file mode 100644 index 6a89384e9e66d..0000000000000 --- a/clang/test/Parser/gh114815.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -verify %s -std=c++11 -fsyntax-only - -#define ID(X) X -extern int ID(decltype); -// expected-error@-1 {{expected '(' after 'decltype'}} \ -// expected-error@-1 {{expected unqualified-id}} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
