[cfe-commits] r168108 - in /cfe/trunk: lib/Parse/ParseDeclCXX.cpp test/Parser/cxx-decl.cpp test/Parser/cxx0x-decl.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Thu Nov 15 14:54:20 PST 2012
Author: rsmith
Date: Thu Nov 15 16:54:20 2012
New Revision: 168108
URL: http://llvm.org/viewvc/llvm-project?rev=168108&view=rev
Log:
PR9903: Recover from a member functon declared with the 'typedef' specifier by
dropping the specifier, just like we do for non-member functions and function
templates declared 'typedef'. Patch by Brian Brooks!
Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/Parser/cxx-decl.cpp
cfe/trunk/test/Parser/cxx0x-decl.cpp
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=168108&r1=168107&r2=168108&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu Nov 15 16:54:20 2012
@@ -1985,16 +1985,9 @@
if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
Diag(DeclaratorInfo.getIdentifierLoc(),
diag::err_function_declared_typedef);
- // This recovery skips the entire function body. It would be nice
- // to simply call ParseCXXInlineMethodDef() below, however Sema
- // assumes the declarator represents a function, not a typedef.
- ConsumeBrace();
- SkipUntil(tok::r_brace, /*StopAtSemi*/false);
- // Consume the optional ';'
- if (Tok.is(tok::semi))
- ConsumeToken();
- return;
+ // Recover by treating the 'typedef' as spurious.
+ DS.ClearStorageClassSpecs();
}
Decl *FunDecl =
Modified: cfe/trunk/test/Parser/cxx-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=168108&r1=168107&r2=168108&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Thu Nov 15 16:54:20 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic -fcxx-exceptions -fexceptions %s
const char const *x10; // expected-warning {{duplicate 'const' declaration specifier}}
@@ -124,6 +124,14 @@
// PR4111
void f(sqrgl); // expected-error {{unknown type name 'sqrgl'}}
+// PR9903
+struct S {
+ typedef void a() { }; // expected-error {{function definition declared 'typedef'}}
+ typedef void c() try { } catch(...) { } // expected-error {{function definition declared 'typedef'}}
+ int n, m;
+ typedef S() : n(1), m(2) { } // expected-error {{function definition declared 'typedef'}}
+};
+
// PR8380
extern "" // expected-error {{unknown linkage language}}
test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \
Modified: cfe/trunk/test/Parser/cxx0x-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-decl.cpp?rev=168108&r1=168107&r2=168108&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-decl.cpp Thu Nov 15 16:54:20 2012
@@ -34,3 +34,8 @@
};
static_assert(something, ""); // expected-error {{undeclared identifier}}
+
+// PR9903
+struct SS {
+ typedef void d() = default; // expected-error {{function definition declared 'typedef'}} expected-error {{only special member functions may be defaulted}}
+};
More information about the cfe-commits
mailing list