summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate/fibonacci.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-26 00:10:35 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-26 00:10:35 +0000
commit97f1f1c46e7ba0a208cef09406ca6301607027e2 (patch)
tree79f1dac387132f302e9e666c39435eeaabc8ec52 /clang/test/SemaTemplate/fibonacci.cpp
parent4555618854c409cb804cd454b97771fa9f2d4b20 (diff)
downloadbcm5719-llvm-97f1f1c46e7ba0a208cef09406ca6301607027e2.tar.gz
bcm5719-llvm-97f1f1c46e7ba0a208cef09406ca6301607027e2.zip
The injected-class-name of class templates and class template
specializations can be treated as a template. Finally, we can parse and process the first implementation of Fibonacci I wrote! Note that this code does not handle all of the cases where injected-class-names can be treated as templates. In particular, there's an ambiguity case that we should be able to handle (but can't), e.g., template <class T> struct Base { }; template <class T> struct Derived : Base<int>, Base<char> { typename Derived::Base b; // error: ambiguous typename Derived::Base<double> d; // OK }; llvm-svn: 67720
Diffstat (limited to 'clang/test/SemaTemplate/fibonacci.cpp')
-rw-r--r--clang/test/SemaTemplate/fibonacci.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/clang/test/SemaTemplate/fibonacci.cpp b/clang/test/SemaTemplate/fibonacci.cpp
index e8a1ec772e8..6cd50157e2b 100644
--- a/clang/test/SemaTemplate/fibonacci.cpp
+++ b/clang/test/SemaTemplate/fibonacci.cpp
@@ -1,7 +1,5 @@
// RUN: clang-cc -fsyntax-only %s
-// FIXME: The Fibonacci/FibonacciEval dance is here to work around our
-// inability to parse injected-class-name<template-argument-list>.
template<unsigned I>
struct FibonacciEval;
@@ -50,3 +48,19 @@ template<> struct Fibonacci2<1> {
int array5_2[Fibonacci2<5>::value == 5? 1 : -1];
int array10_2[Fibonacci2<10>::value == 55? 1 : -1];
+
+template<unsigned I>
+struct Fibonacci3 {
+ static const unsigned value = Fibonacci3<I-1>::value + Fibonacci3<I-2>::value;
+};
+
+template<> struct Fibonacci3<0> {
+ static const unsigned value = 0;
+};
+
+template<> struct Fibonacci3<1> {
+ static const unsigned value = 1;
+};
+
+int array5_3[Fibonacci3<5>::value == 5? 1 : -1];
+int array10_3[Fibonacci3<10>::value == 55? 1 : -1];
OpenPOWER on IntegriCloud