diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-04-12 07:48:19 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-04-12 07:48:19 +0000 |
| commit | 940bca7b93ef664533f3277c9f342c5fd6615a57 (patch) | |
| tree | eeac968b1ab0e3a313273d11ab402464b6ea9e65 /clang/test/SemaTemplate | |
| parent | f76210ead802a3fc69308466f1f04bb3d061f504 (diff) | |
| download | bcm5719-llvm-940bca7b93ef664533f3277c9f342c5fd6615a57.tar.gz bcm5719-llvm-940bca7b93ef664533f3277c9f342c5fd6615a57.zip | |
Be sure to instantiate the parameters of a function, even when the
function's type is (strictly speaking) non-dependent. This ensures
that, e.g., default function arguments get instantiated properly.
And, since I couldn't resist, collapse the two implementations of
function-parameter instantiation into calls to a single, new function
(Sema::SubstParmVarDecl), since the two had nearly identical code (and
each had bugs the other didn't!). More importantly, factored out the
semantic analysis of a parameter declaration into
Sema::CheckParameter, which is called both by
Sema::ActOnParamDeclarator (when parameters are parsed) and when a
parameter is instantiated. Previously, we were missing some
Objective-C and address-space checks on instantiated function
parameters.
Fixes PR6733.
llvm-svn: 101029
Diffstat (limited to 'clang/test/SemaTemplate')
| -rw-r--r-- | clang/test/SemaTemplate/default-expr-arguments-2.cpp | 19 | ||||
| -rw-r--r-- | clang/test/SemaTemplate/instantiate-method.cpp | 2 |
2 files changed, 20 insertions, 1 deletions
diff --git a/clang/test/SemaTemplate/default-expr-arguments-2.cpp b/clang/test/SemaTemplate/default-expr-arguments-2.cpp new file mode 100644 index 00000000000..88cc43d6445 --- /dev/null +++ b/clang/test/SemaTemplate/default-expr-arguments-2.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -ast-dump %s 2>&1 | FileCheck %s + +// This is a wacky test to ensure that we're actually instantiating +// the default rguments of the constructor when the function type is +// otherwise non-dependent. +namespace PR6733 { + template <class T> + class bar { + public: enum { kSomeConst = 128 }; + bar(int x = kSomeConst) {} + }; + + // CHECK: void f() + void f() { + // CHECK: bar<int> tmp = + // CHECK: CXXDefaultArgExpr{{.*}}'int' + bar<int> tmp; + } +} diff --git a/clang/test/SemaTemplate/instantiate-method.cpp b/clang/test/SemaTemplate/instantiate-method.cpp index 357ea261775..635d839b2bd 100644 --- a/clang/test/SemaTemplate/instantiate-method.cpp +++ b/clang/test/SemaTemplate/instantiate-method.cpp @@ -5,7 +5,7 @@ public: void f(T x); // expected-error{{argument may not have 'void' type}} void g(T*); - static int h(T, T); // expected-error 2{{argument may not have 'void' type}} + static int h(T, T); // expected-error {{argument may not have 'void' type}} }; int identity(int x) { return x; } |

