Commit 41dc91a8 by Simon Baldwin Committed by Ian Lance Taylor

re PR c++/23689 (Malformed typedef silently ignored)

cp/:
	PR c++/23689
	* decl.c (check_tag_decl): Added new warning for typedef ignored
	when it precedes an otherwise valid non-typedef declaration.
testsuite/:
	PR c++/23689
	* warn/ignored_typedef.C: New.
	* init/ctor8.C: Added dg-warning to consume ignored typedef
	warning. 
	* template/typedef2.C: Ditto.  Moved dg-error onto its own line
	and added an explicit line number.

From-SVN: r122434
parent ceca734e
2007-03-01 Simon Baldwin <simonb@google.com>
PR c++/23689
* decl.c (check_tag_decl): Added new warning for typedef ignored
when it precedes an otherwise valid non-typedef declaration.
2007-02-28 Sandra Loosemore <sandra@codesourcery.com> 2007-02-28 Sandra Loosemore <sandra@codesourcery.com>
* typeck.c (build_function_call): Store converted arguments * typeck.c (build_function_call): Store converted arguments
......
...@@ -3694,6 +3694,8 @@ check_tag_decl (cp_decl_specifier_seq *declspecs) ...@@ -3694,6 +3694,8 @@ check_tag_decl (cp_decl_specifier_seq *declspecs)
|| declspecs->specs[(int)ds_thread]) || declspecs->specs[(int)ds_thread])
error ("qualifiers can only be specified for objects " error ("qualifiers can only be specified for objects "
"and functions"); "and functions");
else if (saw_typedef)
warning (0, "%<typedef%> was ignored in this declaration");
} }
return declared_type; return declared_type;
......
2007-03-01 Simon Baldwin <simonb@google.com>
PR c++/23689
* warn/ignored_typedef.C: New.
* init/ctor8.C: Added dg-warning to consume ignored typedef
warning.
* template/typedef2.C: Ditto. Moved dg-error onto its own line
and added an explicit line number.
2007-02-28 Richard Guenther <rguenther@suse.de> 2007-02-28 Richard Guenther <rguenther@suse.de>
PR middle-end/30364 PR middle-end/30364
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
typedef struct S { // { dg-error "reference" } typedef struct S { // { dg-error "reference" }
int &r; int &r;
}; }; // { dg-warning "'typedef' was ignored" }
S f () { S f () {
return S (); // { dg-error "synthesized" } return S (); // { dg-error "synthesized" }
} }
// PR c++/18155 // PR c++/18155
template<int> typedef struct A; // { dg-error "" } template<int> typedef struct A; // { dg-warning "'typedef' was ignored" }
// { dg-error "" "" { target *-*-* } 3 }
// PR c++/23689
// Test that malformed typedef's produce a compiler warning.
typedef char valid_0;
typedef int valid_1;
typedef long valid_2;
typedef float valid_3;
typedef double valid_4;
typedef unsigned valid_5;
typedef int *valid_6;
typedef struct valid_7 {} valid_8;
typedef struct {} valid_9;
typedef int temp_0; typedef temp_0 valid_10;
struct temp_1 {}; typedef temp_1 valid_11;
union temp_2 {}; typedef temp_2 valid_12;
typedef void (*valid_13) (int);
typedef struct invalid_0 {}; // { dg-warning "'typedef' was ignored" }
typedef class invalid_1 {}; // { dg-warning "'typedef' was ignored" }
typedef enum invalid_2 { INVALID_2 }; // { dg-warning "'typedef' was ignored" }
typedef enum { INVALID_3 }; // { dg-warning "'typedef' was ignored" }
typedef union invalid_4 {}; // { dg-warning "'typedef' was ignored" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment