overload-decl.cpp revision a5728872c7702ddd09537c95bc3cbd20e1f2fb09
1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fsyntax-only -verify %s 28e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregorvoid f(); 38e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregorvoid f(int); 48e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregorvoid f(int, float); 58e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregorvoid f(int, int); 68e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregorvoid f(int, ...); 78e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor 88e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregortypedef float Float; 95f4a6829dc58cab2f76e2b98492859aa3b91e3f2Chris Lattnervoid f(int, Float); // expected-note {{previous declaration is here}} 108e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor 115f4a6829dc58cab2f76e2b98492859aa3b91e3f2Chris Lattnerint f(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}} 128e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor 135f4a6829dc58cab2f76e2b98492859aa3b91e3f2Chris Lattnervoid g(void); // expected-note {{previous declaration is here}} 145f4a6829dc58cab2f76e2b98492859aa3b91e3f2Chris Lattnerint g(); // expected-error {{functions that differ only in their return type cannot be overloaded}} 158e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor 169e7d9de3ef538c1473248238b76a6d7b16f5f684Douglas Gregortypedef int INT; 179e7d9de3ef538c1473248238b76a6d7b16f5f684Douglas Gregor 188e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregorclass X { 198e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor void f(); 209e7d9de3ef538c1473248238b76a6d7b16f5f684Douglas Gregor void f(int); // expected-note {{previous declaration is here}} 211ca50c3f541dd637063b9d186a7ea193e3440a48Douglas Gregor void f() const; 228e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor 239e7d9de3ef538c1473248238b76a6d7b16f5f684Douglas Gregor void f(INT); // expected-error{{cannot be redeclared}} 249e7d9de3ef538c1473248238b76a6d7b16f5f684Douglas Gregor 255f4a6829dc58cab2f76e2b98492859aa3b91e3f2Chris Lattner void g(int); // expected-note {{previous declaration is here}} 265f4a6829dc58cab2f76e2b98492859aa3b91e3f2Chris Lattner void g(int, float); // expected-note {{previous declaration is here}} 275f4a6829dc58cab2f76e2b98492859aa3b91e3f2Chris Lattner int g(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}} 288e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor 298e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor static void g(float); 305f4a6829dc58cab2f76e2b98492859aa3b91e3f2Chris Lattner static void g(int); // expected-error {{static and non-static member functions with the same parameter types cannot be overloaded}} 318e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor}; 32