[clang-tools-extra] 6b187fd - [pseudo] Add xfail tests for a simple-declaration/function-definition ambiguity

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 23 06:52:39 PDT 2022


Author: Sam McCall
Date: 2022-06-23T15:52:22+02:00
New Revision: 6b187fdf3bb409061b6a235487517f478b09afed

URL: https://github.com/llvm/llvm-project/commit/6b187fdf3bb409061b6a235487517f478b09afed
DIFF: https://github.com/llvm/llvm-project/commit/6b187fdf3bb409061b6a235487517f478b09afed.diff

LOG: [pseudo] Add xfail tests for a simple-declaration/function-definition ambiguity

I expect to eliminate this ambiguity at the grammar level by use of guards,
because it interferes with brace-based error recvoery.

Differential Revision: https://reviews.llvm.org/D127400

Added: 
    clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
    clang-tools-extra/pseudo/test/cxx/declarator-var.cpp

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/pseudo/test/cxx/declarator-function.cpp b/clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
new file mode 100644
index 0000000000000..0de4ec14ffcd0
--- /dev/null
+++ b/clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
@@ -0,0 +1,11 @@
+// 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

diff  --git a/clang-tools-extra/pseudo/test/cxx/declarator-var.cpp b/clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
new file mode 100644
index 0000000000000..a5adb43dc3c5c
--- /dev/null
+++ b/clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
@@ -0,0 +1,11 @@
+// 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


        


More information about the cfe-commits mailing list