diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-10-31 09:07:45 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-10-31 09:07:45 +0000 |
commit | b48fe3812047e84164925c8938ce82be0624c40c (patch) | |
tree | 8af13a860c7c055c80382ca3f0b1f9f2db7b7b23 /test/SemaCXX/constructor.cpp | |
parent | e10b0f236bc8487445bc99b8d14bd40666b1998d (diff) |
Add support for parsing and representing C++ constructor declarations.
Notes:
- Constructors are never found by name lookup, so they'll never get
pushed into any scope. Instead, they are stored as an
OverloadedFunctionDecl in CXXRecordDecl for easy overloading.
- There's a new action isCurrentClassName that determines whether an
identifier is the name of the innermost class currently being defined;
we use this to identify the declarator-id grammar rule that refers to
a type-name.
- MinimalAction does *not* support parsing constructors.
- We now handle virtual and explicit function specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58499 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/constructor.cpp')
-rw-r--r-- | test/SemaCXX/constructor.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/SemaCXX/constructor.cpp b/test/SemaCXX/constructor.cpp new file mode 100644 index 0000000000..4f9dd2b79d --- /dev/null +++ b/test/SemaCXX/constructor.cpp @@ -0,0 +1,14 @@ +// RUN: clang -fsyntax-only -verify %s + +class Foo { + Foo(); + (Foo)(float) { } + explicit Foo(int); + Foo(const Foo&); + + static Foo(short, short); // expected-error{{constructor cannot be declared 'static'}} + virtual Foo(double); // expected-error{{constructor cannot be declared 'virtual'}} + Foo(long) const; // expected-error{{'const' qualifier is not allowed on a constructor}} + + int Foo(int, int); // expected-error{{constructor cannot have a return type}} +}; |