summaryrefslogtreecommitdiffstats
path: root/test/Parser/cxx-default-args.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-03-30 22:14:32 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-03-30 22:14:32 +0000
commit7fd3a6456a88cdd225b92ae1606144f24c7f51d4 (patch)
tree6b296f963187dd660d103c1bb2bcdd62be09760d /test/Parser/cxx-default-args.cpp
parent3be9678105f10c49c4ebc5ce353f770c3a50f9c7 (diff)
When "delayed parsing" C++ default arguments, if there is an error, there may be tokens left in the token stream
that will interfere (they will be parsed as if they are after the class' '}') and a crash will occur because the CachedTokens that holds them will be deleted while the lexer is still using them. Make sure that the tokens of default args are removed from the token stream. Fixes PR6647. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99939 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser/cxx-default-args.cpp')
-rw-r--r--test/Parser/cxx-default-args.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/Parser/cxx-default-args.cpp b/test/Parser/cxx-default-args.cpp
new file mode 100644
index 0000000000..a084fb0812
--- /dev/null
+++ b/test/Parser/cxx-default-args.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR6647
+class C {
+ // After the error, the rest of the tokens inside the default arg should be
+ // skipped, avoiding a "expected ';' after class" after 'undecl'.
+ void m(int x = undecl + 0); // expected-error {{use of undeclared identifier 'undecl'}}
+};
+