[cfe-commits] r153628 - in /cfe/trunk: include/clang/Sema/DeclSpec.h test/Parser/cxx-class.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Wed Mar 28 18:46:00 PDT 2012
Author: rsmith
Date: Wed Mar 28 20:46:00 2012
New Revision: 153628
URL: http://llvm.org/viewvc/llvm-project?rev=153628&view=rev
Log:
Don't try to parse a malformed parameter list after a constructor or operator
name as a direct initializer.
Modified:
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/test/Parser/cxx-class.cpp
Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=153628&r1=153627&r2=153628&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Wed Mar 28 20:46:00 2012
@@ -1655,6 +1655,10 @@
Context != FileContext)
return false;
+ // Special names can't have direct initializers.
+ if (Name.getKind() != UnqualifiedId::IK_Identifier)
+ return false;
+
switch (Context) {
case FileContext:
case BlockContext:
Modified: cfe/trunk/test/Parser/cxx-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=153628&r1=153627&r2=153628&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-class.cpp (original)
+++ cfe/trunk/test/Parser/cxx-class.cpp Wed Mar 28 20:46:00 2012
@@ -72,17 +72,16 @@
Ctor(x[5]); // expected-error{{incomplete type}}
Ctor(UnknownType *); // expected-error{{unknown type name 'UnknownType'}}
+ void operator+(UnknownType*); // expected-error{{unknown type name 'UnknownType'}}
};
Ctor::Ctor (x) = { 0 }; // \
// expected-error{{qualified reference to 'Ctor' is a constructor name}}
- // FIXME: These diagnostics are terrible.
Ctor::Ctor(UnknownType *) {} // \
- // expected-error{{'Ctor' cannot be the name of a variable or data member}} \
- // expected-error{{use of undeclared identifier 'UnknownType'}} \
- // expected-error{{expected expression}} \
- // expected-error{{expected ';' after top level declarator}}
+ // expected-error{{unknown type name 'UnknownType'}}
+ void Ctor::operator+(UnknownType*) {} // \
+ // expected-error{{unknown type name 'UnknownType'}}
}
// PR11109 must appear at the end of the source file
More information about the cfe-commits
mailing list