[PATCH] D127400: [pseudo] Add xfail tests for a simple-declaration/function-definition ambiguity
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 9 05:14:17 PDT 2022
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang-tools-extra.
I expect to eliminate this ambiguity at the grammar level by use of guards,
because it interferes with brace-based error recvoery.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127400
Files:
clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
Index: clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
===================================================================
--- /dev/null
+++ clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
@@ -0,0 +1,12 @@
+// The standard grammar allows an function-body to use any declarator, including
+// a non-function declarator. This creates an ambiguity where a
+// simple-declaration is misparsed as a function-definition.
+// FIXME: eliminate this false parse.
+// XFAIL: *
+
+// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest |
+// FileCheck %s
+void (*s)(){};
+// CHECK-NOT: function-definition
+// CHECK: init-declarator := declarator initializer
+// CHECK-NOT: function-definition
Index: clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
===================================================================
--- /dev/null
+++ clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
@@ -0,0 +1,12 @@
+// The standard grammar allows an init-list with any declarator, including
+// a function declarator. This creates an ambiguity where a function-definition
+// is misparsed as a simple-declaration.
+// FIXME: eliminate this false parse.
+// XFAIL: *
+
+// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest |
+// FileCheck %s
+void s(){};
+// CHECK-NOT: simple-declaration
+// CHECK: function-definition := decl-specifier-seq declarator
+// function-body CHECK-NOT: simple-declaration
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127400.435510.patch
Type: text/x-patch
Size: 1474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220609/88c08a59/attachment-0001.bin>
More information about the cfe-commits
mailing list